"The Github toolkit contains tools that enable an LLM agent to interact with a github repository. The tools are a wrapper for the [PyGitHub](https://github.com/PyGithub/PyGithub) library. \n",
"\n",
"## Quickstart\n",
"1. Install the pygithub library\n",
"2. Create a Github app\n",
"3. Set your environmental variables\n",
"4. Pass the tools to your agent with `toolkit.get_tools()`\n",
"\n",
"Each of these steps will be explained in greate detail below.\n",
"\n",
"1. **Get Issues**- fetches issues from the repository.\n",
"\n",
"2. **Get Issue**- feteches details about a specific issue.\n",
"\n",
"3. **Comment on Issue**- posts a comment on a specific issue.\n",
"\n",
"4. **Create Pull Request**- creates a pull request from the bot's working branch to the base branch.\n",
"\n",
"5. **Create File**- creates a new file in the repository.\n",
"\n",
"6. **Read File**- reads a file from the repository.\n",
"\n",
"7. **Update File**- updates a file in the repository.\n",
"\n",
"8. **Delete File**- deletes a file from the repository.\n",
"[Follow the instructions here](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) to create and register a Github app. Make sure your app has the following [repository permissions:](https://docs.github.com/en/rest/overview/permissions-required-for-github-apps?apiVersion=2022-11-28)\n",
"* Commit statuses (read only)\n",
"* Contents (read and write)\n",
"* Issues (read and write)\n",
"* Metadata (read only)\n",
"* Pull requests (read and write)\n",
"\n",
"\n",
"\n",
"Once the app has been registered, add it to the repository you wish the bot to act upon.\n",
"\n",
"## 3. Set Environmental Variables\n",
"\n",
"Before initializing your agent, the following environmental variables need to be set:\n",
"\n",
"* **GITHUB_APP_ID**- A six digit number found in your app's general settings\n",
"* **GITHUB_APP_PRIVATE_KEY**- The location of your app's private key .pem file\n",
"* **GITHUB_REPOSITORY**- The name of the Github repository you want your bot to act upon. Must follow the format {username}/{repo-name}. Make sure the app has been added to this repository first!\n",
"* **GITHUB_BRANCH**- The branch where the bot will make its commits. Defaults to 'master.'\n",
"* **GITHUB_BASE_BRANCH**- The base branch of your repo, usually either 'main' or 'master.' This is where pull requests will base from. Defaults to 'master.'\n"
"Observation: \u001b[33;1m\u001b[1;3m{\"title\": \"Update README file\", \"body\": \"Find what the most popular frontend framework is right now and add a short blurb to the readme.md file about how this website will take advantage of it.\", \"comments\": \"[]\"}\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I need to update the README file.\n",
"Action: Create File\n",
"Action Input: README.md\u001b[0m\n",
"Observation: \u001b[33;1m\u001b[1;3mFile already exists at README.md. Use update_file instead\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I need to update the existing README file.\n",
"Observation: \u001b[36;1m\u001b[1;3mFile content was not updated because old content was not found.It may be helpful to use the read_file action to get the current file contents.\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3m I need to get the current file contents.\n",
" \"You have the software engineering capabilities of a Google Principle engineer. You are tasked with completing issues on a github repository. Please look at the existing issues and complete them.\"\n",
"If your agent does not need to use all 8 tools, you can build tools individually to use. For this example, we'll make an agent that does not use the create_file, delete_file or create_pull_request tools, but can also use duckduckgo-search."
"\u001b[1m> Entering new AgentExecutor chain...\u001b[0m\n",
"\u001b[32;1m\u001b[1;3mTo complete this issue, I need to find the most popular frontend framework and add a blurb about how this website will utilize it to the readme.md file. I should start by researching the most popular frontend frameworks and then update the readme file accordingly. I will use the \"Search\" tool to research the most popular frontend framework.\n",
"\n",
"Action: Search\n",
"Action Input: \"most popular frontend framework\"\u001b[0m\n",
"Observation: \u001b[33;1m\u001b[1;3mAlex Ivanovs February 25, 2023 Table of Contents What are the current Front-end trends? Top Front-end Frameworks for 2023 #1 - React #2 - Angular #3 - Vue #4 - Svelte #5 - Preact #6 - Ember #7 - Solid #8 - Lit #9 - Alpine #10 - Stencil #11 - Qwik Front-end Frameworks: A Summary Top 6 Frontend Frameworks To Use in 2022 by Nwose Lotanna Victor August 26, 2022 Web 0 Comments This post reveals the top six frontend libraries to use in 2022. The list is fresh and very different from the previous years. State of JS Though React is the most popular framework for frontend development, it also has some shortcomings. Due to its limitations, the idea was to design a small-size framework that will offer the same features as React. This is how a tiny version of React — Preact — appeared. Top 10 Popular Frontend Frameworks to Use in 2023 Sep 26, 2022 10 min Сontents 1. What is a framework? 2. Front-end frameworks vs backend frameworks 3. The best front-end frameworks in 2023 React Vue.js Angular Svelte JQuery Ember Backbone Semantic UI 4. Final words Technostacks Jan 11 2023 Top Frontend Frameworks of 2023 for Web Development Developing what the users see on their screens is the role of a front-end web developer. Unarguably, front-end developers worldwide are trying to use the best front-end frameworks to provide the best user experience.\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mBased on my research, the most popular frontend framework right now is React. I will now update the readme.md file to include a blurb about how this website will take advantage of React.\n",
"\n",
"Action: Update File\n",
"Action Input:\n",
"README.md\n",
"OLD <<<<\n",
"This is the readme file for the website.\n",
">>>> OLD\n",
"NEW <<<<\n",
"This is the readme file for the website.\n",
"\n",
"This website takes advantage of the React framework, which allows for efficient and reusable UI components. With React, we can easily manage the state of our application and create interactive user interfaces. It provides a smooth and seamless user experience, making this website highly responsive and dynamic.\n",
">>>> NEW\n",
"\u001b[0m\n",
"Observation: \u001b[36;1m\u001b[1;3mFile content was not updated because old content was not found.It may be helpful to use the read_file action to get the current file contents.\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mI need to first read the contents of the README.md file to get the current content. Then I can update the file with the new content.\n",
"\n",
"Action: Read File\n",
"Action Input: README.md\u001b[0m\n",
"Observation: \u001b[38;5;200m\u001b[1;3mThis is my awesome website that uses the most popular frontend framework.\n",
"\u001b[0m\n",
"Thought:\u001b[32;1m\u001b[1;3mThe current content of the README.md file is \"This is my awesome website that uses the most popular frontend framework.\" I can now update the file with the new content.\n",
"\n",
"Action: Update File\n",
"Action Input:\n",
"README.md\n",
"OLD <<<<\n",
"This is my awesome website that uses the most popular frontend framework.\n",
">>>> OLD\n",
"NEW <<<<\n",
"This is my awesome website that uses the most popular frontend framework.\n",
"\n",
"This website takes advantage of the React framework, which allows for efficient and reusable UI components. With React, we can easily manage the state of our application and create interactive user interfaces. It provides a smooth and seamless user experience, making this website highly responsive and dynamic.\n",
"Thought:\u001b[32;1m\u001b[1;3mI have successfully updated the README.md file with the blurb about how this website will take advantage of the React framework.\n",
"\n",
"Final Answer: The most popular frontend framework right now is React. This website takes advantage of React to create efficient and reusable UI components, manage application state, and provide a smooth and seamless user experience.\u001b[0m\n",
"\n",
"\u001b[1m> Finished chain.\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'The most popular frontend framework right now is React. This website takes advantage of React to create efficient and reusable UI components, manage application state, and provide a smooth and seamless user experience.'"
]
},
"execution_count": 73,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# The GitHubAPIWrapper can be used outside of an agent, too\n",
"# This gets the info about issue number 9, since we want to\n",
"# force the agent to address this specific issue.\n",
"\n",
"issue = github.get_issue(9)\n",
"\n",
"prompt = f\"\"\"\n",
"You are a seinor frontend developer who is experienced in HTML, CSS, and JS- especially React.\n",
"You have been assigned the below issue. Complete it to the best of your ability.\n",
"Remember to first make a plan and pay attention to details like file names and commonsense.\n",
"Then execute the plan and use tools appropriately.\n",
"Finally, make a pull request to merge your changes.\n",