(username: str, repo: str, github_pat: str | None = None)
| 34 | # cache github data to avoid double API calls from cost and generate |
| 35 | @lru_cache(maxsize=100) |
| 36 | def get_cached_github_data(username: str, repo: str, github_pat: str | None = None): |
| 37 | # Create a new service instance for each call with the appropriate PAT |
| 38 | current_github_service = GitHubService(pat=github_pat) |
| 39 | |
| 40 | default_branch = current_github_service.get_default_branch(username, repo) |
| 41 | if not default_branch: |
| 42 | default_branch = "main" # fallback value |
| 43 | |
| 44 | file_tree = current_github_service.get_github_file_paths_as_list(username, repo) |
| 45 | readme = current_github_service.get_github_readme(username, repo) |
| 46 | |
| 47 | return {"default_branch": default_branch, "file_tree": file_tree, "readme": readme} |
| 48 | |
| 49 | |
| 50 | class ApiRequest(BaseModel): |
no test coverage detected