diff --git a/libs/community/langchain_community/document_loaders/github.py b/libs/community/langchain_community/document_loaders/github.py index ee647d42401..df02a7894fb 100644 --- a/libs/community/langchain_community/document_loaders/github.py +++ b/libs/community/langchain_community/document_loaders/github.py @@ -206,7 +206,10 @@ class GithubFileLoader(BaseGitHubLoader, ABC): ] def get_file_content_by_path(self, path: str) -> str: - base_url = f"{self.github_api_url}/repos/{self.repo}/contents/{path}" + queryparams = f"?ref={self.branch}" if self.branch else "" + base_url = ( + f"{self.github_api_url}/repos/{self.repo}/contents/{path}{queryparams}" + ) response = requests.get(base_url, headers=self.headers) response.raise_for_status()