RepoOpenBMB (MiniCPM)OpenBMB (MiniCPM)published Nov 28, 2023seen 5d

OpenBMB/RepoAgent

Python

Open original ↗

Captured source

source ↗
published Nov 28, 2023seen 5dcaptured 9hhttp 200method plain

OpenBMB/RepoAgent

Description: An LLM-powered repository agent designed to assist developers and teams in generating documentation and understanding repositories quickly.

Language: Python

License: Apache-2.0

Stars: 983

Forks: 139

Open issues: 11

Created: 2023-11-28T10:41:28Z

Pushed: 2024-12-23T11:48:52Z

Default branch: main

Fork: no

Archived: no

README:

RepoAgent: An LLM-Powered Framework for Repository-level Code Documentation Generation.

English readme • 简体中文 readme

:tv: Demo

![Watch the video](https://youtu.be/YPPJBVOP71M)

👾 Background

In the realm of computer programming, the significance of comprehensive project documentation, including detailed explanations for each Python file, cannot be overstated. Such documentation serves as the cornerstone for understanding, maintaining, and enhancing the codebase. It provides essential context and rationale for the code, making it easier for current and future developers to comprehend the purpose, functionality, and structure of the software. It not only facilitates current and future developers in grasping the project's purpose and structure but also ensures that the project remains accessible and modifiable over time, significantly easing the learning curve for new team members.

Traditionally, creating and maintaining software documentation demanded significant human effort and expertise, a challenge for small teams without dedicated personnel. The introduction of Large Language Models (LLMs) like GPT has transformed this, enabling AI to handle much of the documentation process. This shift allows human developers to focus on verification and fine-tuning, greatly reducing the manual burden of documentation.

🏆 Our goal is to create an intelligent document assistant that helps people read and understand repositories and generate documents, ultimately helping people improve efficiency and save time.

✨ Features

  • 🤖 Automatically detects changes in Git repositories, tracking additions, deletions, and modifications of files.
  • 📝 Independently analyzes the code structure through AST, generating documents for individual objects.
  • 🔍 Accurate identification of inter-object bidirectional invocation relationships, enriching the global perspective of document content.
  • 📚 Seamlessly replaces Markdown content based on changes, maintaining consistency in documentation.
  • 🕙 Executes multi-threaded concurrent operations, enhancing the efficiency of document generation.
  • 👭 Offer a sustainable, automated documentation update method for team collaboration.
  • 😍 Display Code Documentation in an amazing way. (with document book per project powered by Gitbook)

🚀 Getting Started

Installation Method

Using GitHub Actions

This repository supports GitHub Actions for automating workflows such as building, testing, and deploying. For detailed instructions on setting up and using GitHub Actions with this repository, please refer to the actions/run-repoagent.

Using pip (Recommended for Users)

Install the repoagent package directly using pip:

pip install repoagent

Development Setup Using PDM

If you're looking to contribute or set up a development environment:

  • Install PDM: If you haven't already, install PDM.
  • Use CodeSpace, or Clone the Repository:
  • Use CodeSpace

The easiest way to get RepoAgent enviornment. Click below to use the GitHub Codespace, then go to the next step.

![Open in GitHub Codespaces](https://codespaces.new/LOGIC-10/RepoAgent?quickstart=1)

  • Clone the Repository
git clone https://github.com/LOGIC-10/RepoAgent.git
cd RepoAgent
  • Setup with PDM
  • Initialize the Python virtual environment. Make sure to run the below cmd in /RepoAgent directory:
pdm venv create --name repoagent
  • Install dependencies using PDM
pdm install

Configuring RepoAgent

Before configuring specific parameters for RepoAgent, please ensure that the OpenAI API is configured as an environment variable in the command line:

export OPENAI_API_KEY=YOUR_API_KEY # on Linux/Mac
set OPENAI_API_KEY=YOUR_API_KEY # on Windows
$Env:OPENAI_API_KEY = "YOUR_API_KEY" # on Windows (PowerShell)

Run RepoAgent

Enter the root directory of RepoAgent and try the following command in the terminal:

repoagent run #this command will generate doc, or update docs(pre-commit-hook will automatically call this)
repoagent run --print-hierarchy # Print how repo-agent parse the target repo

The run command supports the following optional flags (if set, will override config defaults):

  • -m, --model TEXT: Specifies the model to use for completion. Default: gpt-3.5-turbo
  • -t, --temperature FLOAT: Sets the generation temperature for the model. Lower values make the model more deterministic. Default: 0.2
  • -r, --request-timeout INTEGER: Defines the timeout in seconds for the API request. Default: 60
  • -b, --base-url TEXT: The base URL for the API calls. Default: https://api.openai.com/v1
  • -tp, --target-repo-path PATH: The file system path to the target repository. Used as the root for documentation generation. Default: path/to/your/target/repository
  • -hp, --hierarchy-path TEXT: The name or path for the project hierarchy file, used to organize documentation structure. Default: .project_doc_record
  • -mdp, --markdown-docs-path TEXT: The folder path where Markdown documentation will be stored or generated. Default: markdown_docs
  • -i, --ignore-list TEXT: A list of files or directories to ignore during documentation generation, separated by commas.
  • -l, --language TEXT: The ISO 639 code or language name for the documentation. Default: Chinese
  • -ll, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]: Sets the logging level for the application. Default: INFO

You can also try the following feature

repoagent clean # Remove repoagent-related cache
repoagent diff # Check what docs will be updated/generated based on current code change

If it's your first time generating documentation for the target repository, RepoAgent will automatically…

Excerpt shown — open the source for the full document.