Solving github issues#
In this notebook we will explore capabilities of LLMs to solve github issues. In order to run this notebook, you need to configure a “GITHUB_API_KEY” in your environment variables. You can get such a key here, after logging in to github.
We will be using these libraries:
from blablado import Assistant
The actual implementation of the interaction with github can be found in the github_utilities.py file in this folder.
from github_utilities import get_github_issue_details, list_issues, list_repository_files, get_repository_file_contents, update_file_in_new_branch, send_pull_request
First, we define the repository we want to work on.
repository = "scads/git-demo-dataweek2024"
Next, we define a blablado assistant, which can call functions using instructions from a human operator in English language. Note: These functions all have a proper docstring, telling the LLM what the functions can be used for.
assistant = Assistant()
# enabling the assistant to interact with github issues
assistant.register_tool(list_issues)
assistant.register_tool(get_github_issue_details)
# allow it to interact with files in the repository.
assistant.register_tool(list_repository_files)
assistant.register_tool(get_repository_file_contents)
# modifying files
assistant.register_tool(update_file_in_new_branch)
assistant.register_tool(send_pull_request)
Listing github issues#
We start by exploring existing issues on the repository.
assistant.do(f"List all open issues on {repository}")
Here are the open issues on scads/git-demo-dataweek2024
:
Issue #11: Long texts
Issue #10: Missing content
Issue #9: Typo
Issue #8: Update README.md
Issue #7: sonnige Grüße
Issue #6: Fix typo
Issue #3: Update README.md
Issue #2: Update README.md
We then pick one issue and ask for details.
assistant.do("Tell me the most important details of issue #9")
Issue #9: Typo
State: Open
Created at: 2024-07-23 07:29:11
Author: haesleinhuepf
Description: There is a typo in the file “content.md”.
Accessing files in the repository#
In order to determine which file might need modifications to solve the issue, we first list all files.
assistant.do(f"List all files in the repository {repository}")
The repository scads/git-demo-dataweek2024
contains the following files:
LICENSE
README.md
content.md
Then, we ask the LLM which of the files might be related to the issue.
filename = assistant.tell("Which of these files might be relevant for issue 9 ? Respond ONLY the filename.")
filename
'content.md'
assistant.do(f"Load the entire content of {filename} from the in the repository {repository} .")
The content of content.md
is:
# History of a sentence
This sentence contains a tpyo.
Let's see what is going to happen with it.
May it stay here forever? Or does an AI find it and fix it?
Time will tell.
Best,
Robert
Modifying content#
After identifying the file, we can ask the LLM to fix the issue in the file.
assistant.do(f"Modify the file content of {filename} to fix the issue in a new branch.")
The file content.md
has been modified to fix the issue and saved in a new branch mod-YZ5ZVRtibO
.
Submitting a pull-request#
In order to let developers of the repository know that we would like to change something, we send a pull-request.
assistant.do("Send a pull-request of the new branch explaining what we changed.")
The pull request has been created: Fix typo in content.md.