Closed renxida closed 6 days ago
Hey @renxida, long time no type! Hope you're doing fantastically well and haven't been swallowed whole by any code monstrosities lately. 🐍✨
Based on the error message you're receiving, it seems like you're trying to pass a github_token
directly to the GithubRepositoryReader
constructor. However, the GithubRepositoryReader
does not accept a github_token
as a parameter. Instead, it expects an instance of BaseGithubClient
(or a subclass thereof) as its first argument.
Here's how you should be using it:
First, create an instance of GithubClient
(which is a subclass of BaseGithubClient
) using your github_token
:
github_client = GithubClient(github_token=os.environ["GITHUB_TOKEN"], verbose=True)
Then, pass this github_client
instance to the GithubRepositoryReader
constructor:
reader1 = GithubRepositoryReader(
github_client=github_client,
owner="run-llama",
repo="llama_index",
use_parser=False,
verbose=True,
...
)
This is the correct way to use the GithubRepositoryReader
class according to the provided class definition and example usage. If you're encountering an error related to an unexpected keyword argument github_token
, it's likely because you're trying to directly pass a github_token
to the GithubRepositoryReader
constructor, which is not supported.
For more details, you can refer to the source code of the GithubRepositoryReader
class in the LlamaIndex repository.
This solution was also suggested in a similar open issue [Question]: llama-index-readers-github which was last updated on March 12, 2024. This issue was referenced by [Documentation]: Update GithubRepositoryReader documentation which was last updated on March 14, 2024.
@dosubot that's helpful. Could you draft an update to https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/docs/examples/data_connectors/GithubRepositoryReaderDemo.ipynb that fixes it? There seems to be also other errors caused by other updates
I'm glad you found the information helpful! Unfortunately, I can't directly draft updates to notebooks or any other files in repositories. However, I can guide you through what changes need to be made to address the issue you're encountering with the GithubRepositoryReaderDemo.ipynb
notebook.
Instantiate GithubClient
with github_token
:
Replace the section where GithubRepositoryReader
is instantiated with a github_token
with the following code to first create a GithubClient
instance:
from llama_index.integrations.clients import GithubClient
github_client = GithubClient(github_token=os.environ["GITHUB_TOKEN"], verbose=True)
Ensure you have imported GithubClient
from the correct module.
Update GithubRepositoryReader
Instantiation:
Use the github_client
instance created above when instantiating GithubRepositoryReader
:
from llama_index.readers.github import GithubRepositoryReader
reader = GithubRepositoryReader(
github_client=github_client,
owner="run-llama",
repo="llama_index",
use_parser=False,
verbose=True
)
This correctly passes the github_client
instead of the unsupported github_token
argument.
Review Other Errors: For other errors caused by updates, review the notebook for any deprecated methods or parameters. Ensure all used libraries and their methods are up to date with the current versions. This might involve checking the latest documentation for each library and adjusting the code accordingly.
Test the Notebook: After making the necessary updates, run the entire notebook to ensure all cells execute without errors. This step is crucial to verify that all changes have resolved the issues and that there are no new errors introduced.
Document Changes: It might be helpful to add comments or a section in the notebook detailing the changes made and why. This can assist future users who might encounter similar issues or are curious about the update history.
Since I can't make these changes directly, I recommend either making these updates yourself if you have the necessary permissions or reaching out to the repository maintainers with the suggested changes. If there are specific errors beyond the GithubRepositoryReader
instantiation issue, feel free to share them, and I can provide further guidance on how to address them.
For any more assistance or if you have additional questions, feel free to ask!
Documentation Issue Description
https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/docs/examples/data_connectors/GithubRepositoryReaderDemo.ipynb
TypeError Traceback (most recent call last) in <cell line: 18>()
16
17 # Using the retrieved GitHub token in GithubRepositoryReader
---> 18 documents = GithubRepositoryReader(
19 github_token=github_token,
20 owner=owner,
TypeError: GithubRepositoryReader.init() got an unexpected keyword argument 'github_token'
Documentation Link
https://colab.research.google.com/github/run-llama/llama_index/blob/main/docs/docs/examples/data_connectors/GithubRepositoryReaderDemo.ipynb