You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
14
32
15
33
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.
@@ -76,75 +94,81 @@ If you're looking to contribute or set up a development environment:
76
94
77
95
### Configuring RepoAgent
78
96
79
-
First, configure the OpenAI API parameters in the config.yml file.
80
-
For details on obtaining these, please refer to [OpenAI API](https://beta.openai.com/docs/developer-quickstart/your-api-keys).
81
-
82
-
In the `config.yml` file, configure other parameters like OpenAI API, the destination repository path, document language, and so on:
83
-
84
-
```yaml
85
-
api_keys:
86
-
gpt-3.5-turbo-16k:
87
-
- api_key: sk-XXXX
88
-
base_url: https://example.com/v1/
89
-
api_type: azure
90
-
api_version: XXX
91
-
engine: GPT-35-Turbo-16k
92
-
# you can use any kwargs supported by openai.ChatCompletion here
93
-
- api_key: sk-xxxxx
94
-
organization: org-xxxxxx
95
-
model: gpt-3.5-turbo-16k
96
-
...
97
-
98
-
default_completion_kwargs:
99
-
model: gpt-4-1106
100
-
temperature: 0.2
101
-
request_timeout: 60
102
-
103
-
repo_path: /path/to/your/repo
104
-
project_hierarchy: .project_hierarchy # This is a folder, where we store the project hierarchy and metainfo. This can be shared with your team members.
105
-
Markdown_Docs_folder: Markdown_Docs # The folder in the root directory of your target repository to store the documentation.
106
-
ignore_list: ["ignore_file1.py", "ignore_file2.py", "ignore_directory"] # Ignore some py files or folders that you don't want to generate documentation for by giving relative paths in ignore_list.
107
-
108
-
language: en # Two-letter language codes (ISO 639-1 codes), e.g. `language: en`for English. Refer to Supported Language for more languages.
109
-
max_thread_count: 10 # We support multiprocessing to speedup the process
110
-
max_document_tokens: 1024 # the maximum number of tokens in a document generated
111
-
log_level: info
97
+
You can use RepoAgent with OpenAI API for the moment.
98
+
99
+
```sh
100
+
export OPENAI_API_KEY=YOUR_API_KEY # on Linux/Mac
101
+
set OPENAI_API_KEY=YOUR_API_KEY # on Windows
102
+
$Env:OPENAI_API_KEY = "YOUR_API_KEY" # on Windows (PowerShell)
103
+
```
104
+
105
+
Use `repoagent configure`if you need to running parameters.
106
+
107
+
```sh
108
+
Enter the path to target repository:
109
+
Enter the project hierarchy file name [.project_doc_record]:
110
+
Enter the Markdown documents folder name [markdown_docs]:
111
+
Enter files or directories to ignore, separated by commas []:
112
+
Enter the language (ISO 639 code or language name, e.g., 'en', 'eng', 'English') [Chinese]:
113
+
Enter the maximum number of threads [4]:
114
+
Enter the maximum number of document tokens [1024]:
115
+
Enter the log level (DEBUG, INFO, WARNING, ERROR, CRITICAL) [INFO]:
116
+
Enter the model [gpt-3.5-turbo]:
117
+
Enter the temperature [0.2]:
118
+
Enter the request timeout (seconds) [60.0]:
119
+
Enter the base URL [https://api.openai.com/v1]:
112
120
```
113
121
114
-
### Run RepoAgent
122
+
## Run RepoAgent
115
123
116
124
Enter the root directory of RepoAgent and try the following commandin the terminal:
117
125
```sh
118
-
python -m repo_agent #this command will generate doc, or update docs(pre-commit-hook will automatically call this)
126
+
repo_agent run #this command will generate doc, or update docs(pre-commit-hook will automatically call this)
127
+
```
128
+
129
+
The run command supports the following optional flags (if set, will override config defaults):
130
+
131
+
- `-m`, `--model` TEXT: Specifies the model to use for completion. Default: `gpt-3.5-turbo`
132
+
- `-t`, `--temperature` FLOAT: Sets the generation temperature for the model. Lower values make the model more deterministic. Default: `0.2`
133
+
- `-r`, `--request-timeout` INTEGER: Defines the timeout in seconds for the API request. Default: `60`
134
+
- `-b`, `--base-url` TEXT: The base URL for the API calls. Default: `https://api.openai.com/v1`
135
+
- `-tp`, `--target-repo-path` PATH: The file system path to the target repository. Used as the root for documentation generation. Default: `/home/test/arno`
136
+
- `-hp`, `--hierarchy-path` TEXT: The name or path for the project hierarchy file, used to organize documentation structure. Default: `.project_doc_record`
137
+
- `-mdp`, `--markdown-docs-path` TEXT: The folder path where Markdown documentation will be stored or generated. Default: `markdown_docs`
138
+
- `-i`, `--ignore-list` TEXT: A list of files or directories to ignore during documentation generation, separated by commas.
139
+
- `-l`, `--language` TEXT: The ISO 639 code or language name for the documentation. Default: `Chinese`
140
+
- `-ll`, `--log-level` [DEBUG|INFO|WARNING|ERROR|CRITICAL]: Sets the logging level for the application. Default: `INFO`
141
+
142
+
143
+
You can also try the following feature
119
144
120
-
# you can also try the follow feature
121
-
python -m repo_agent clean #this command will remove repoagent-related cache
122
-
python -m repo_agent print #this command will print how repo-agent parse the target repo
123
-
python -m repo_agent diff #this command will check what docs will be updated/generated based on current code change
145
+
```sh
146
+
repo_agent clean # Remove repoagent-related cache
147
+
repo_agent print-hierarchy # Print how repo-agent parse the target repo
148
+
repo_agent diff # Check what docs will be updated/generated based on current code change
124
149
```
125
150
126
151
If it's your first time generating documentation for the target repository, RepoAgent will automatically create a JSON file maintaining the global structure information and a folder named Markdown_Docs in the root directory of the target repository for storing documents.
127
152
128
-
The paths of the global structure information json file and the documentation folder can be configured in `config.yml`.
129
-
130
-
Once you have initially generated the global documentation for the target repository, or if the project you cloned already contains global documentation information, you can then seamlessly and automatically maintain internal project documentation with your team by configuring the **pre-commit hook** in the target repository!
153
+
Once you have initially generated the global documentation for the target repository, or if the project you cloned already contains global documentation information, you can then seamlessly and automatically maintain internal project documentation with your team by configuring the **pre-commit hook** in the target repository!
131
154
132
-
### Configuring the Target Repository
155
+
### Use `pre-commit`
133
156
134
157
RepoAgent currently supports generating documentation for projects, which requires some configuration in the target repository.
135
158
136
159
First, ensure that the target repository is a git repository and has been initialized.
137
-
```
160
+
161
+
```sh
138
162
git init
139
163
```
140
164
Install pre-commit in the target repository to detect changes in the git repository.
141
165
142
-
```
166
+
```sh
143
167
pip install pre-commit
144
168
```
145
169
Create a file named `.pre-commit-config.yaml` in the root directory of the target repository. An example is as follows:
146
170
147
-
```
171
+
```yml
148
172
repos:
149
173
- repo: local
150
174
hooks:
@@ -155,11 +179,14 @@ repos:
155
179
# You can specify the file types that trigger the hook, but currently only python is supported.
156
180
types: [python]
157
181
```
182
+
158
183
For specific configuration methods of hooks, please refer to [pre-commit](https://pre-commit.com/#plugins).
159
184
After configuring the yaml file, execute the following command to install the hook.
160
-
```
185
+
186
+
```sh
161
187
pre-commit install
162
188
```
189
+
163
190
In this way, each git commit will trigger the RepoAgent's hook, automatically detecting changes in the target repository and generating corresponding documents.
164
191
Next, you can make some modifications to the target repository, such as adding a new file to the target repository, or modifying an existing file.
165
192
You just need to follow the normal git workflow: git add, git commit -m "your commit message", git push
@@ -177,25 +204,21 @@ We utilized the default model **gpt-3.5-turbo** to generate documentation for th
177
204
**In the end, you can flexibly adjust the output format, template, and other aspects of the document by customizing the prompt. We are excited about your exploration of a more scientific approach to Automated Technical Writing and your contributions to the community.**
178
205
179
206
### Exploring chat with repo
207
+
180
208
We conceptualize **Chat With Repo** as a unified gateway for these downstream applications, acting as a connector that links RepoAgent to human users and other AI agents. Our future research will focus on adapting the interface to various downstream applications and customizing it to meet their unique characteristics and implementation requirements.
181
209
182
210
Here we demonstrate a preliminary prototype of one of our downstream tasks: Automatic Q&A for Issues and Code Explanation. You can start the server by running the following code.
183
-
```bash
184
-
python -m repo_agent.chat_with_repo
211
+
212
+
```sh
213
+
repoagent chat-with-repo
185
214
```
186
215
187
216
## ✅ Future Work
188
217
189
-
- [x] Identification and maintenance of parent-child relationship hierarchy structure between objects
- [x] **chat with repo** Chat with the repository by giving code and document at the same time
193
-
- [x] Automatically generate better visualizations such as Gitbook
218
+
- [x] Support install and configure via `pip install repoagent`
194
219
- [ ] Generate README.md automatically combining with the global documentation
195
220
- [ ] **Multi-programming-language support** Support more programming languages like Java, C or C++, etc.
196
221
- [ ] Local model support like Llama, chatGLM, Qwen, GLM4, etc.
197
-
- [ ] Support install and configure via `pip install repoagent`
198
-
- [X] Automatically generate Gitbook for better visualization effects
199
222
200
223
## 🥰 Featured Cases
201
224
@@ -205,45 +228,6 @@ Here are featured cases that have adopted RepoAgent.
205
228
- [ChatDev](https://github.com/OpenBMB/ChatDev): Collaborative AI agents for software development.
206
229
- [XAgent](https://github.com/OpenBMB/XAgent): An Autonomous LLM Agent for Complex Task Solving.
207
230
208
-
## 🇺🇳 Supported Language
209
-
210
-
Set the target language with the two-letter language codes (ISO 639-1 codes), Click on the 'Languages List' section below to expand the list of supported languages.
0 commit comments