Skip to content

Commit

Permalink
fix: use [] for ignore_list default value
Browse files Browse the repository at this point in the history
- Rename `repo_agent` to `repoagent`.
- Fix settings attribute for max tokens in ChatEngine.
- Update README to use correct command.
- bump version to v0.1.1
  • Loading branch information
Umpire2018 committed Mar 8, 2024
1 parent 7ffcc1b commit e4b071c
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 90 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Enter the base URL [https://api.openai.com/v1]:

Enter the root directory of RepoAgent and try the following command in the terminal:
```sh
repo_agent run #this command will generate doc, or update docs(pre-commit-hook will automatically call this)
repoagent run #this command will generate doc, or update docs(pre-commit-hook will automatically call this)
```

The run command supports the following optional flags (if set, will override config defaults):
Expand Down Expand Up @@ -174,7 +174,7 @@ repos:
hooks:
- id: repo-agent
name: RepoAgent
entry: python path/to/your/repo_agent/runner.py
entry: repoagent
language: system
# You can specify the file types that trigger the hook, but currently only python is supported.
types: [python]
Expand Down
8 changes: 4 additions & 4 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ run 命令支持以下可选标志(如果设置,将覆盖配置默认值)
你也可以尝试以下功能

```sh
python -m repo_agent clean # 此命令将删除与repoagent相关的缓存
python -m repo_agent print # 此命令将打印repo-agent如何解析目标仓库
python -m repo_agent diff # 此命令将检查基于当前代码更改将更新/生成哪些文档
repoagent clean # 此命令将删除与repoagent相关的缓存
repoagent print # 此命令将打印repo-agent如何解析目标仓库
repoagent diff # 此命令将检查基于当前代码更改将更新/生成哪些文档
```

如果您是第一次对目标仓库生成文档,此时RepoAgent会自动生成一个维护全局结构信息的json文件,并在目标仓库根目录下创建一个名为Markdown_Docs的文件夹,用于存放文档。
Expand All @@ -163,7 +163,7 @@ repos:
hooks:
- id: repo-agent
name: RepoAgent
entry: python path/to/your/repo_agent/runner.py
entry: repoagent
language: system
# 可以指定钩子触发的文件类型,但是目前只支持python
types: [python]
Expand Down
76 changes: 38 additions & 38 deletions pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ dependencies = [
"pyyaml>=6.0.1",
"jedi>=0.19.1",
"GitPython>=3.1.41",
"llama-index<0.10.0",
"chromadb>=0.4.22",
"prettytable>=3.9.0",
"python-iso639>=2024.2.7",
"pydantic-settings>=2.2.1",
"tomli>=2.0.1",
"tomli-w>=1.0.0",
"llama-index<0.10.0",
]
name = "repoagent"
version = "0.1.0"
version = "0.1.1"
description = "An Agent designed to offer an intelligent approach for generating project documentation."
readme = "README.md"

Expand All @@ -47,6 +47,7 @@ test = [
[tool.pdm.build]
includes = [
"repo_agent",
"assets/"
]


Expand Down
2 changes: 1 addition & 1 deletion repo_agent/chat_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def get_relationship_description(referencer_content, reference_letter):
else:
return ""

max_tokens = setting.chat_completion.max_document_tokens
max_tokens = setting.project.max_document_tokens

code_type_tell = "Class" if code_type == "ClassDef" else "Function"
parameters_or_attribute = (
Expand Down
2 changes: 1 addition & 1 deletion repo_agent/chat_with_repo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# repo_agent/chat_with_repo/__init__.py

from .main import main
from .main import main
6 changes: 3 additions & 3 deletions repo_agent/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def get_config_path() -> Path:
os_name = os.name
if os_name == 'posix':
# 对于 Unix 和 macOS,使用家目录
home_config_path = Path.home() / '.repo_agent'
home_config_path = Path.home() / '.repoagent'
elif os_name == 'nt':
# 对于 Windows,使用 APPDATA 目录
home_config_path = Path(os.getenv('APPDATA')) / 'repo_agent' # type: ignore
home_config_path = Path(os.getenv('APPDATA')) / 'repoagent' # type: ignore
else:
# 如果操作系统检测失败,默认使用一个本地目录
home_config_path = Path.cwd() / 'repo_agent'
home_config_path = Path.cwd() / 'repoagent'

# 确保配置目录存在
home_config_path.mkdir(parents=True, exist_ok=True)
Expand Down
6 changes: 3 additions & 3 deletions repo_agent/doc_meta_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class DocItemStatus(Enum):
referencer_not_exist = auto() # 曾经引用他的obj被删除了,或者不再引用他了


def need_to_generate(doc_item: DocItem, ignore_list: List = []) -> bool:
def need_to_generate(doc_item: DocItem, ignore_list: List[str] = []) -> bool:
"""只生成item的,文件及更高粒度都跳过。另外如果属于一个blacklist的文件也跳过"""
if doc_item.item_status == DocItemStatus.doc_up_to_date:
return False
Expand Down Expand Up @@ -236,14 +236,14 @@ def find(self, recursive_file_path: list) -> Optional[DocItem]:
return now

@staticmethod
def check_has_task(now_item: DocItem, ignore_list: List = []):
def check_has_task(now_item: DocItem, ignore_list: List[str] = []):
if need_to_generate(now_item, ignore_list=ignore_list):
now_item.has_task = True
for _, child in now_item.children.items():
DocItem.check_has_task(child, ignore_list)
now_item.has_task = child.has_task or now_item.has_task

def print_recursive(self, indent=0, print_content=False, diff_status = False, ignore_list = []):
def print_recursive(self, indent=0, print_content=False, diff_status = False, ignore_list: List[str] = []):
"""递归打印repo对象"""

def print_indent(indent=0):
Expand Down
6 changes: 6 additions & 0 deletions repo_agent/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class ProjectSettings(BaseSettings):
max_document_tokens: PositiveInt = 1024
log_level: LogLevel = LogLevel.INFO

@field_serializer("ignore_list")
def serialize_ignore_list(self, ignore_list: list[str] = []):
if len(ignore_list) < 1:
return []
return ignore_list

@field_validator("language")
@classmethod
def validate_language_code(cls, v: str) -> str:
Expand Down
Loading

0 comments on commit e4b071c

Please sign in to comment.