/AutoCoder

Primary LanguagePythonApache License 2.0Apache-2.0

AutoCoder: An Experimental Coding Agent

AutoCoder is an experimental description-to-pull-request agent that leverages the power of LLM, ActionWeaver for function calling & orchestration, LLamaIndex for Retrieval-Augmented Generation (RAG), Langchain community and Langsmith for observability.

Please note that this demo app is not intended for production use. This bot is only looking at python files at the moment.

Demo video1

Demo video2

Example Pull Requests

All examples are executed using the Azure gpt-4-32k model

Prompt: [Code Change] Enhance the 'Example Pull Requests' section in the README.md to be more detailed and descriptive. (PR, LangSmith traces)

Prompt: [Code Change] Update the codebase to use OpenAI instead of AzureOpenAI client. (PR, LangSmith traces)

Prompt: [Code Change] Move all classes from autocoder/pydantic_models/file_ops.py into separate files, one for each class. Remove the code in original file. (PR, LangSmith traces)

Prompt: [Code Change] Implement all TODO items in autocoder/codebase.py PR, LangSmith traces

Prompt: [Code Change] rename every github_api variable to langchain_github_api within the codebase. Do not remove anything else. (PR, LangSmith traces)

Prompt: [Code Change] add structure logging into autocoder/index.py and configure it to log the output to a file. (PR, LangSmith traces)

Prompt: [Code Change] Optimize the code in autocoder/telemetry.py

  • refactor identity_decorator to be more compact
  • remove redundant code in traceable and trace_client (PR, LangSmith traces)

Features

AutoCoder is capable of following tasks:

  • GetIssues
    • Description: Fetches a list of issues from the GitHub repository.
    • Example Question: "Give me all active issues."
  • QuestionAnswer
    • Description: Answers questions about the codebase.
    • Example Question: "How is the AutoCoder class implemented?"
  • CreatePullRequest
    • Description: Creates a new Pull Request in a Git repository.
    • Example Question: "Create a PR."
  • PlanAndImplementCodeChange
    • Description: Plans and implements code changes based on a given description.
    • Example Question: "Update the autocoder/bot.py to use AzureOpenAI instead of OpenAI."

Local Setup Guide

Step 1: Create a GitHub App

  • Follow the instructions on creating a GitHub App on GitHub's documentation.
  • Grant the Autocoder app Read and Write access in GitHub App settings. It should have access to administration, code, discussions, issues, pull requests, and repository projects for the intended repository.

Step 2: Set Up Environment Variables

  • GitHub API Access: Set GITHUB_APP_ID and GITHUB_APP_PRIVATE_KEY.
  • OpenAI Access: Set OPENAI_API_KEY and specify the model in MODEL, e.g., MODEL=gpt-4-0613. Or AZURE_OPENAI_KEY and AZURE_OPENAI_ENDPOINT if using Azure OpenAI service.
  • Langchain Monitoring (Optional): Set LANGCHAIN_API_KEY.

Step 3: Talk to AutoCoder in notebooks/demo.ipynb or main.py

Tips

  • Precision in Requests: When requesting the bot to perform tasks, be precise with file paths and provide detailed, descriptive information instead of one-liner.
  • Handling Partial Implementations: The bot may occasionally insert comments such as "to-be-implemented" rather than fully writing out the code. In such cases, you can guide the bot towards the desired outcome through multiple rounds of conversation.

Contributing

We welcome contributions from the open-source community.

License

Apache License 2.0