From be62d4e3218c104ad99ade9e73d0879015b7f37d Mon Sep 17 00:00:00 2001 From: Umpire2018 <138990495+Umpire2018@users.noreply.github.com> Date: Mon, 11 Mar 2024 15:10:36 +0000 Subject: [PATCH] docs: update image URLs in `README` and `README_CN` - Bump version to v0.1.3 - Add release.yml for upload release to PyPI. --- .github/workflows/release.yml | 22 +++++++++++++++++++++ README.md | 9 ++++----- README_CN.md | 8 ++++---- pyproject.toml | 5 ++--- repo_agent/runner.py | 37 +++++++++++++++++++++-------------- 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..03aed5a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,22 @@ +name: Release + +on: + release: + types: [published] + +jobs: + pypi-publish: + name: upload release to PyPI + runs-on: ubuntu-latest + permissions: + # This permission is needed for private repositories. + contents: read + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + steps: + - uses: actions/checkout@v3 + + - uses: pdm-project/setup-pdm@v3 + + - name: Publish package distributions to PyPI + run: pdm publish diff --git a/README.md b/README.md index 260ec1a..14ab6ab 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@
- +
@@ -194,11 +194,11 @@ You just need to follow the normal git workflow: git add, git commit -m "your co The RepoAgent hook will automatically trigger at git commit, detect the files you added in the previous step, and generate corresponding documents. After execution, RepoAgent will automatically modify the staged files in the target repository and formally submit the commit. After the execution is completed, the green "Passed" will be displayed, as shown in the figure below: -![Execution Result](assets/images/ExecutionResult.png) +![Execution Result](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/ExecutionResult.png) The generated document will be stored in the specified folder in the root directory of the target warehouse. The rendering of the generated document is as shown below: -![Documentation](assets/images/Doc_example.png) -![Documentation](assets/images/8_documents.png) +![Documentation](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/Doc_example.png) +![Documentation](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/8_documents.png) We utilized the default model **gpt-3.5-turbo** to generate documentation for the [**XAgent**](https://github.com/OpenBMB/XAgent) project, which comprises approximately **270,000 lines** of code. You can view the results of this generation in the Markdown_Docs directory of the XAgent project on GitHub. For enhanced documentation quality, we suggest considering more advanced models like **gpt-4-1106** or **gpt-4-0125-preview**. @@ -216,7 +216,6 @@ repoagent chat-with-repo ## ✅ Future Work -- [x] Support install and configure via `pip install repoagent` - [ ] Generate README.md automatically combining with the global documentation - [ ] **Multi-programming-language support** Support more programming languages like Java, C or C++, etc. - [ ] Local model support like Llama, chatGLM, Qwen, GLM4, etc. diff --git a/README_CN.md b/README_CN.md index 6343afb..8a5a38c 100644 --- a/README_CN.md +++ b/README_CN.md @@ -17,7 +17,7 @@
- +
@@ -188,11 +188,11 @@ pre-commit install RepoAgent hook会在git commit时自动触发,检测前一步您git add的文件,并生成对应的文档。 执行后,RepoAgent会自动更改目标仓库中的已暂存文件并正式提交commit,执行完毕后会显示绿色的Passed,如下图所示: -![Execution Result](assets/images/ExecutionResult.png) +![Execution Result](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/ExecutionResult.png) 生成的文档将存放在目标仓库根目录下的指定文件夹中,生成的文档效果如下图所示: -![Documentation](assets/images/Doc_example.png) -![Documentation](assets/images/8_documents.png) +![Documentation](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/Doc_example.png) +![Documentation](https://raw.githubusercontent.com/OpenBMB/RepoAgent/main/assets/images/8_documents.png) 我们使用默认模型**gpt-3.5-turbo**对一个约**27万行**的中大型项目[**XAgent**](https://github.com/OpenBMB/XAgent)生成了文档。您可以前往XAgent项目的Markdown_Docs文件目录下查看生成效果。如果您希望得到更好的文档效果,我们建议您使用更先进的模型,如**gpt-4-1106** 或 **gpt-4-0125-preview**。 diff --git a/pyproject.toml b/pyproject.toml index 6927eef..ac52ac3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ "llama-index<0.10.0", ] name = "repoagent" -version = "0.1.2" +version = "0.1.3" description = "An LLM-Powered Framework for Repository-level Code Documentation Generation." readme = "README.md" classifiers = [ @@ -32,7 +32,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", - "Topic :: Scientific/Engineering :: Artificial Intelligence" + "Topic :: Scientific/Engineering :: Artificial Intelligence" ] [project.urls] @@ -54,7 +54,6 @@ test = [ [tool.pdm.build] includes = [ "repo_agent", - "assets/images/*.png" ] diff --git a/repo_agent/runner.py b/repo_agent/runner.py index f476f5c..6d3ff2d 100644 --- a/repo_agent/runner.py +++ b/repo_agent/runner.py @@ -70,22 +70,29 @@ def get_all_pys(self, directory): def generate_doc_for_a_single_item(self, doc_item: DocItem): """为一个对象生成文档""" - rel_file_path = doc_item.get_full_name() + try: + + rel_file_path = doc_item.get_full_name() + + if not need_to_generate(doc_item, setting.project.ignore_list): + print(f"Content ignored/Document generated, skipping: {doc_item.get_full_name()}") + else: + print(f" -- Generating document {Fore.LIGHTYELLOW_EX}{doc_item.item_type.name}: {doc_item.get_full_name()}{Style.RESET_ALL}") + file_handler = FileHandler(setting.project.target_repo, rel_file_path) + response_message = self.chat_engine.generate_doc( + doc_item=doc_item, + file_handler=file_handler, + ) + doc_item.md_content.append(response_message.content) + doc_item.item_status = DocItemStatus.doc_up_to_date + self.meta_info.checkpoint( + target_dir_path=self.absolute_project_hierarchy_path + ) + except Exception as e: + logger.info(f"Document generation failed after multiple attempts, skipping: {doc_item.get_full_name()}") + logger.error("Error:", e) + doc_item.item_status = DocItemStatus.doc_has_not_been_generated - if not need_to_generate(doc_item, setting.project.ignore_list): - print(f"Content ignored/Document generated, skipping: {doc_item.get_full_name()}") - else: - print(f" -- Generating document {Fore.LIGHTYELLOW_EX}{doc_item.item_type.name}: {doc_item.get_full_name()}{Style.RESET_ALL}") - file_handler = FileHandler(setting.project.target_repo, rel_file_path) - response_message = self.chat_engine.generate_doc( - doc_item=doc_item, - file_handler=file_handler, - ) - doc_item.md_content.append(response_message.content) - doc_item.item_status = DocItemStatus.doc_up_to_date - self.meta_info.checkpoint( - target_dir_path=self.absolute_project_hierarchy_path - ) def first_generate(self): """