auto-coder 0.1.78__tar.gz → 0.1.80__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {auto-coder-0.1.78 → auto-coder-0.1.80}/PKG-INFO +2 -2
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/PKG-INFO +2 -2
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/SOURCES.txt +7 -7
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/requires.txt +1 -1
- auto-coder-0.1.80/src/autocoder/agent/planner.py +204 -0
- auto-coder-0.1.80/src/autocoder/auto_coder.py +413 -0
- auto-coder-0.1.80/src/autocoder/auto_coder_server.py +273 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/command_args.py +43 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/__init__.py +4 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/index/for_command.py +17 -8
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/index/index.py +21 -8
- auto-coder-0.1.80/src/autocoder/index/symbols_utils.py +63 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/pyproject/__init__.py +1 -36
- auto-coder-0.1.80/src/autocoder/rag/simple_directory_reader.py +646 -0
- auto-coder-0.1.80/src/autocoder/rag/simple_rag.py +394 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/tsproject/__init__.py +1 -5
- auto-coder-0.1.80/src/autocoder/utils/tests.py +37 -0
- auto-coder-0.1.80/src/autocoder/version.py +1 -0
- auto-coder-0.1.80/tests/test_planner.py +49 -0
- auto-coder-0.1.80/tests/test_symbols_utils.py +97 -0
- auto-coder-0.1.78/src/autocoder/auto_coder.py +0 -325
- auto-coder-0.1.78/src/autocoder/rag/simple_rag.py +0 -311
- auto-coder-0.1.78/src/autocoder/version.py +0 -1
- auto-coder-0.1.78/tests/test_code_auto_merge.py +0 -44
- auto-coder-0.1.78/tests/test_image_to_page.py +0 -35
- auto-coder-0.1.78/tests/test_init_command.py +0 -21
- auto-coder-0.1.78/tests/test_llm_rerank.py +0 -53
- auto-coder-0.1.78/tests/test_shell_client.py +0 -28
- auto-coder-0.1.78/tests/test_simple_rag.py +0 -26
- auto-coder-0.1.78/tests/test_tsproject.py +0 -41
- {auto-coder-0.1.78 → auto-coder-0.1.80}/README.md +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/setup.cfg +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/setup.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/agent/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/agent/coder.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/JupyterClient.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/ShellClient.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/anything2images.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/audio.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/cleaner.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_execute.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_generate.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_generate_diff.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_merge.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_merge_diff.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/command_templates.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/const.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/git_utils.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/image_to_page.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/llm_rerank.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/screenshots.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/search.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/search_replace.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/common/types.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/db/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/db/store.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/action.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/copilot.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/index/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/lang.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/rag/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/rag/api_server.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/rag/llm_wrapper.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/rag/types.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/regexproject/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/suffixproject/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/utils/__init__.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/utils/llm_client_interceptors.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/utils/multi_turn.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/utils/print_table.py +0 -0
- {auto-coder-0.1.78 → auto-coder-0.1.80}/src/autocoder/utils/rest.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.80
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -41,7 +41,7 @@ Requires-Dist: websocket-client
|
|
|
41
41
|
Requires-Dist: sqlmodel
|
|
42
42
|
Requires-Dist: wudao
|
|
43
43
|
Requires-Dist: jieba
|
|
44
|
-
Requires-Dist: byzerllm>=0.1.
|
|
44
|
+
Requires-Dist: byzerllm>=0.1.98
|
|
45
45
|
Requires-Dist: patch
|
|
46
46
|
Requires-Dist: diff_match_patch
|
|
47
47
|
Requires-Dist: GitPython
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.80
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -41,7 +41,7 @@ Requires-Dist: websocket-client
|
|
|
41
41
|
Requires-Dist: sqlmodel
|
|
42
42
|
Requires-Dist: wudao
|
|
43
43
|
Requires-Dist: jieba
|
|
44
|
-
Requires-Dist: byzerllm>=0.1.
|
|
44
|
+
Requires-Dist: byzerllm>=0.1.98
|
|
45
45
|
Requires-Dist: patch
|
|
46
46
|
Requires-Dist: diff_match_patch
|
|
47
47
|
Requires-Dist: GitPython
|
|
@@ -8,11 +8,13 @@ src/auto_coder.egg-info/requires.txt
|
|
|
8
8
|
src/auto_coder.egg-info/top_level.txt
|
|
9
9
|
src/autocoder/__init__.py
|
|
10
10
|
src/autocoder/auto_coder.py
|
|
11
|
+
src/autocoder/auto_coder_server.py
|
|
11
12
|
src/autocoder/command_args.py
|
|
12
13
|
src/autocoder/lang.py
|
|
13
14
|
src/autocoder/version.py
|
|
14
15
|
src/autocoder/agent/__init__.py
|
|
15
16
|
src/autocoder/agent/coder.py
|
|
17
|
+
src/autocoder/agent/planner.py
|
|
16
18
|
src/autocoder/common/JupyterClient.py
|
|
17
19
|
src/autocoder/common/ShellClient.py
|
|
18
20
|
src/autocoder/common/__init__.py
|
|
@@ -49,10 +51,12 @@ src/autocoder/dispacher/actions/plugins/action_translate.py
|
|
|
49
51
|
src/autocoder/index/__init__.py
|
|
50
52
|
src/autocoder/index/for_command.py
|
|
51
53
|
src/autocoder/index/index.py
|
|
54
|
+
src/autocoder/index/symbols_utils.py
|
|
52
55
|
src/autocoder/pyproject/__init__.py
|
|
53
56
|
src/autocoder/rag/__init__.py
|
|
54
57
|
src/autocoder/rag/api_server.py
|
|
55
58
|
src/autocoder/rag/llm_wrapper.py
|
|
59
|
+
src/autocoder/rag/simple_directory_reader.py
|
|
56
60
|
src/autocoder/rag/simple_rag.py
|
|
57
61
|
src/autocoder/rag/types.py
|
|
58
62
|
src/autocoder/regexproject/__init__.py
|
|
@@ -63,10 +67,6 @@ src/autocoder/utils/llm_client_interceptors.py
|
|
|
63
67
|
src/autocoder/utils/multi_turn.py
|
|
64
68
|
src/autocoder/utils/print_table.py
|
|
65
69
|
src/autocoder/utils/rest.py
|
|
66
|
-
tests
|
|
67
|
-
tests/
|
|
68
|
-
tests/
|
|
69
|
-
tests/test_llm_rerank.py
|
|
70
|
-
tests/test_shell_client.py
|
|
71
|
-
tests/test_simple_rag.py
|
|
72
|
-
tests/test_tsproject.py
|
|
70
|
+
src/autocoder/utils/tests.py
|
|
71
|
+
tests/test_planner.py
|
|
72
|
+
tests/test_symbols_utils.py
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
from llama_index.core.agent import ReActAgent
|
|
2
|
+
from llama_index.core.tools import FunctionTool
|
|
3
|
+
from autocoder.index.index import IndexManager
|
|
4
|
+
from autocoder.pyproject import PyProject
|
|
5
|
+
from autocoder.tsproject import TSProject
|
|
6
|
+
from autocoder.suffixproject import SuffixProject
|
|
7
|
+
from autocoder.common import AutoCoderArgs,SourceCode
|
|
8
|
+
from autocoder.rag.simple_rag import SimpleRAG
|
|
9
|
+
from byzerllm.apps.llama_index.byzerai import ByzerAI
|
|
10
|
+
from loguru import logger
|
|
11
|
+
import os
|
|
12
|
+
import byzerllm
|
|
13
|
+
import yaml
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@byzerllm.prompt()
|
|
17
|
+
def context():
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
auto-coder 是一个命令行 + YAML 配置文件编程辅助工具。
|
|
21
|
+
程序员通过在 YAML 文件里撰写修改代码的逻辑,然后就可以通过下面的命令来执行:
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
auto-file --file actions/xxxx.yml
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
下面是 auto-coder YAML 文件的一个基本配置:
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
query: |
|
|
31
|
+
关注 byzerllm_client.py,command_args.py,common/__init__.py 等几个文件,
|
|
32
|
+
添加一个 byzerllm agent 命令
|
|
33
|
+
```
|
|
34
|
+
其中 query 部分就是对如何修改代码进行的一个较为详细的描述。 有了这个描述,auto-coder 会自动完成后续的代码修改工作。
|
|
35
|
+
所以 auto-coder 工具实现了代码的”设计“到”实现“。
|
|
36
|
+
|
|
37
|
+
如果你希望auto-coder能够在解决问题的时候自动查找知识库,那么在YAML中新增一个配置:
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
enable_rag_search: <你希望auto-coder自动查找的query>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
你的目标是根据用户的问题,从”需求/目标“到”设计“,生成一个或者多个 yaml 配置文件。
|
|
44
|
+
|
|
45
|
+
注意,用户的需求往往是一个"需求/目标",参考如下思路:
|
|
46
|
+
|
|
47
|
+
1. 你总是需要找到当前问题需要涉及到的文件。注意,你需要对问题进行理解,然后转换成一个查询。比如用户说:我想增加一个 agent命令。那我们的查询应该是:"项目的命令行入口相关文件"
|
|
48
|
+
2. 如果有必要,去查看你感兴趣的某个文件的源码。
|
|
49
|
+
3. 如果在生成的过程中遇到 yaml 配置相关的问题,可以查阅 auto-coder 的相关知识。
|
|
50
|
+
4. 生成 auto-coder 的 yaml 配置文件。
|
|
51
|
+
|
|
52
|
+
通常 auto-coder YAML 文件的 query 内容要覆盖以下几个方面:
|
|
53
|
+
|
|
54
|
+
1. 需要修改的文件是什么
|
|
55
|
+
2. 修改逻辑是什么
|
|
56
|
+
3. 具体的修改范例是什么(可选)
|
|
57
|
+
|
|
58
|
+
你需要将用户的原始问题修改成满足上面的描述。
|
|
59
|
+
|
|
60
|
+
比如用户说:我想增加一个 agent命令,因为我们查找了相关文件路径,
|
|
61
|
+
然后根据get_project_related_files这个工具我们知道用户的目标涉及到 byzerllm_client.py,command_args.py,common/__init__.py 等几个文件。
|
|
62
|
+
通过read_source_codes查看文件源码,我们确认 command_args.py 是最合适的文件,并且获得了更详细的信息,所以我们最终将 query 改成:
|
|
63
|
+
"关注command_args.py 以及它相关的文件,在里面参考 byzerllm deploy 实现一个新的命令 byzerllm agent 命令",
|
|
64
|
+
这样 auto-coder 就知道应该修改哪些文件,以及怎么修改,满足我们前面的要求。
|
|
65
|
+
|
|
66
|
+
如果用户的问题比较复杂,你可能需要拆解成多个步骤,每个步骤生成一个对应一个 yaml 配置文件。
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def get_tools(args: AutoCoderArgs, llm: byzerllm.ByzerLLM):
|
|
71
|
+
def get_project_related_files(query: str) -> str:
|
|
72
|
+
"""
|
|
73
|
+
该工具会根据查询描述,返回项目中与查询相关的文件。
|
|
74
|
+
返回文件路径列表。
|
|
75
|
+
"""
|
|
76
|
+
if args.project_type == "ts":
|
|
77
|
+
pp = TSProject(args=args, llm=llm)
|
|
78
|
+
elif args.project_type == "py":
|
|
79
|
+
pp = PyProject(args=args, llm=llm)
|
|
80
|
+
else:
|
|
81
|
+
pp = SuffixProject(args=args, llm=llm, file_filter=None)
|
|
82
|
+
pp.run()
|
|
83
|
+
sources = pp.sources
|
|
84
|
+
|
|
85
|
+
index_manager = IndexManager(llm=llm, sources=sources, args=args)
|
|
86
|
+
target_files = index_manager.get_target_files_by_query(query)
|
|
87
|
+
file_list = target_files.file_list
|
|
88
|
+
return ",".join([file.file_path for file in file_list])
|
|
89
|
+
|
|
90
|
+
def generate_auto_coder_yaml(yaml_file_name: str, yaml_str: str) -> str:
|
|
91
|
+
"""
|
|
92
|
+
该工具主要用于生成 auto-coder yaml 配置文件。
|
|
93
|
+
参数 yaml_file_name 不要带后缀名。
|
|
94
|
+
返回生成的 yaml 文件路径。
|
|
95
|
+
"""
|
|
96
|
+
actions_dir = os.path.join(args.source_dir, "actions")
|
|
97
|
+
if not os.path.exists(actions_dir):
|
|
98
|
+
print("Current directory does not have an actions directory")
|
|
99
|
+
return
|
|
100
|
+
|
|
101
|
+
action_files = [
|
|
102
|
+
f
|
|
103
|
+
for f in os.listdir(actions_dir)
|
|
104
|
+
if f[:3].isdigit() and f.endswith(".yml") and f[:3] != "101"
|
|
105
|
+
]
|
|
106
|
+
if not action_files:
|
|
107
|
+
max_seq = 0
|
|
108
|
+
else:
|
|
109
|
+
seqs = [int(f[:3]) for f in action_files]
|
|
110
|
+
max_seq = max(seqs)
|
|
111
|
+
|
|
112
|
+
new_seq = str(max_seq + 1).zfill(3)
|
|
113
|
+
prev_files = [f for f in action_files if int(f[:3]) < int(new_seq)]
|
|
114
|
+
|
|
115
|
+
if not prev_files:
|
|
116
|
+
new_file = os.path.join(actions_dir, f"{new_seq}_{yaml_file_name}.yml")
|
|
117
|
+
with open(new_file, "w") as f:
|
|
118
|
+
pass
|
|
119
|
+
else:
|
|
120
|
+
prev_file = sorted(prev_files)[-1] # 取序号最大的文件
|
|
121
|
+
with open(os.path.join(actions_dir, prev_file), "r") as f:
|
|
122
|
+
content = f.read()
|
|
123
|
+
|
|
124
|
+
yaml_content = yaml.safe_load(content)
|
|
125
|
+
if yaml_content is None:
|
|
126
|
+
raise Exception("The previous yaml file is empty. Please check it.")
|
|
127
|
+
|
|
128
|
+
new_temp_yaml_content = yaml.safe_load(yaml_str)
|
|
129
|
+
|
|
130
|
+
for k, v in new_temp_yaml_content.items():
|
|
131
|
+
del yaml_content[k]
|
|
132
|
+
|
|
133
|
+
new_content = yaml.safe_dump(yaml_content, encoding='utf-8',allow_unicode=True, default_flow_style=False).decode('utf-8')
|
|
134
|
+
new_file = os.path.join(actions_dir, f"{new_seq}_{yaml_file_name}.yml")
|
|
135
|
+
with open(new_file, "w") as f:
|
|
136
|
+
f.write(new_content + "\n" + yaml_str)
|
|
137
|
+
|
|
138
|
+
return new_file
|
|
139
|
+
|
|
140
|
+
def read_source_codes(paths:str)->str:
|
|
141
|
+
'''
|
|
142
|
+
你可以通过使用该工具获取相关文件的源代码。
|
|
143
|
+
输入参数 paths: 逗号分隔的文件路径列表,需要时绝对路径
|
|
144
|
+
返回值是文件的源代码
|
|
145
|
+
'''
|
|
146
|
+
paths = [p.strip() for p in paths.split(",")]
|
|
147
|
+
source_code_str = ""
|
|
148
|
+
for path in paths:
|
|
149
|
+
with open(path, "r") as f:
|
|
150
|
+
source_code = f.read()
|
|
151
|
+
sc = SourceCode(module_name=path, source_code=source_code)
|
|
152
|
+
source_code_str += f"##File: {sc.module_name}\n"
|
|
153
|
+
source_code_str += f"{sc.source_code}\n\n"
|
|
154
|
+
|
|
155
|
+
return source_code_str
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def get_auto_coder_knowledge(query: str):
|
|
159
|
+
"""
|
|
160
|
+
你可以通过使用该工具来获得 auto-coder 相关问题的回答。
|
|
161
|
+
返回相关的知识文本。
|
|
162
|
+
"""
|
|
163
|
+
old_enable_rag_search = args.enable_rag_search
|
|
164
|
+
old_collections = args.collections
|
|
165
|
+
|
|
166
|
+
if not args.enable_rag_search:
|
|
167
|
+
args.enable_rag_search= True,
|
|
168
|
+
if not args.collections:
|
|
169
|
+
args.collections="auto-coder"
|
|
170
|
+
|
|
171
|
+
logger.info(f"collections: {args.collections}")
|
|
172
|
+
rag = SimpleRAG(llm=llm, args=args, path="")
|
|
173
|
+
source_codes = rag.search(query)
|
|
174
|
+
|
|
175
|
+
args.enable_rag_search = old_enable_rag_search
|
|
176
|
+
args.collections = old_collections
|
|
177
|
+
|
|
178
|
+
return "\n".join([sc.source_code for sc in source_codes])
|
|
179
|
+
|
|
180
|
+
tools = [
|
|
181
|
+
FunctionTool.from_defaults(get_project_related_files),
|
|
182
|
+
FunctionTool.from_defaults(generate_auto_coder_yaml),
|
|
183
|
+
FunctionTool.from_defaults(get_auto_coder_knowledge),
|
|
184
|
+
FunctionTool.from_defaults(read_source_codes)
|
|
185
|
+
]
|
|
186
|
+
return tools
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
class Planner:
|
|
190
|
+
def __init__(self, args: AutoCoderArgs, llm: byzerllm.ByzerLLM):
|
|
191
|
+
self.llm = llm
|
|
192
|
+
self.args = args
|
|
193
|
+
self.tools = get_tools(args=args, llm=llm)
|
|
194
|
+
|
|
195
|
+
def run(self, query: str, max_iterations: int = 10):
|
|
196
|
+
agent = ReActAgent.from_tools(
|
|
197
|
+
tools=self.tools,
|
|
198
|
+
llm=ByzerAI(llm=self.llm),
|
|
199
|
+
verbose=True,
|
|
200
|
+
max_iterations=max_iterations,
|
|
201
|
+
context=context.prompt(),
|
|
202
|
+
)
|
|
203
|
+
r = agent.chat(message=query)
|
|
204
|
+
return r.response
|