An AI Agent that can answer questions about GitHub repositories for a user or an organization.
- Create a new repository using coloradocollective/ai-agent-assignment as a template.
- Create an OpenAI API Key and record the value.
- Add a repository secret
named
OPEN_AI_KEYand set your key from the previous step as the value. - Create a GitHub token with repository access and record the value.
- In GitHub actions start the test workflow to see that it passes.
- Clone your repository locally.
-
Copy the example environment file and fill in the necessary values.
cp .env.example .env source .env -
Run the app then visit localhost:5050.
uv run -m discovery
-
Paste your GitHub token into the login screen and ask a few queries.
-
Run fast tests
uv run -m unittest
-
Run slow tests
source .env RUN_SLOW_TESTS=true uv run -m unittest
Use the GitHub API documentation and add a new tool.
- In the GithubClient, define a method that calls the GitHub API endpoint you've chosen.
- Add a function to github_tools that calls your new method in the GitHub client. Return a JSON string of the data returned by the method.
- Add a Python docstring to your function that describes how OpenAI should use the function.
- Add the
@tool()decorator to the function. - Register the new tool by adding it to the list of tools that are returned by the
github_toolsmethod.
Run the application and see if you can have OpenAI use your tool to fetch data.
Now make sure the agent integrates properly with OpenAI to use your tool. This test will use the LLM and take more time to run. The focus of the test should be to check that the agent uses the correct tool to answer the question, but we have limited ability to check that the response is correct.
- Define a
test_method in test_repository_agent.py that will cover the new tool that was added. - Decorate the test method with the
@slowdecorator. - Add the
@responses.activatedecorator to the method to enable stubbing the API call. - Stub the API that your tool uses.
- Send a question to the agent and assert the correct tools are called
- Next, assert the response by spot-checking for relevant word(s).
- Make a commit and push your changes to the GitHub repository.
- Check to see that your test pass in the GitHub action, then submit your repository URL to Canvas.