auto-coder 0.1.4__tar.gz → 0.1.5__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.4 → auto-coder-0.1.5}/PKG-INFO +27 -10
- {auto-coder-0.1.4 → auto-coder-0.1.5}/README.md +26 -9
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/auto_coder.egg-info/PKG-INFO +27 -10
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/auto_coder.egg-info/SOURCES.txt +2 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/auto_coder.py +1 -1
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/common/__init__.py +37 -2
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/dispacher/actions/copilot.py +9 -44
- auto-coder-0.1.5/src/autocoder/index/__init__.py +0 -0
- auto-coder-0.1.5/src/autocoder/index/index.py +87 -0
- auto-coder-0.1.5/src/autocoder/version.py +1 -0
- auto-coder-0.1.4/src/autocoder/version.py +0 -1
- {auto-coder-0.1.4 → auto-coder-0.1.5}/setup.cfg +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/setup.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/__init__.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/common/JupyterClient.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/common/ShellClient.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/common/cleaner.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/common/const.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/dispacher/__init__.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/pyproject/__init__.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/suffixproject/__init__.py +0 -0
- {auto-coder-0.1.4 → auto-coder-0.1.5}/src/autocoder/tsproject/__init__.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.5
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -27,13 +27,34 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
27
27
|
|
|
28
28
|
*Latest News* 🔥
|
|
29
29
|
|
|
30
|
-
- [2024/03] Release Auto-Coder 0.1.
|
|
30
|
+
- [2024/03] Release Auto-Coder 0.1.5
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
🚀 Attention developers! 🚨 The game-changing Auto-Coder has arrived, and it's about to take your AI programming to a whole new level! 🌟
|
|
37
|
+
|
|
38
|
+
Fueled by the incredible power of Byzer-LLM, this command-line tool is packed with features that will blow your mind:
|
|
39
|
+
|
|
40
|
+
📂 Say goodbye to manual context gathering! Auto-Coder intelligently generates code based on the context of your source directory. It's like having a genius assistant that knows exactly what you need!
|
|
41
|
+
|
|
42
|
+
💡 Two modes, endless possibilities! Generate perfect prompts to paste into web-based large models, or let Auto-Coder work its magic directly with private models via Byzer-LLM. The choice is yours, and the results are always spectacular!
|
|
43
|
+
|
|
44
|
+
💻 Python? TypeScript? No problem! Auto-Coder supports all the cool kids on the programming block.
|
|
45
|
+
|
|
46
|
+
🌍 Going global is a breeze! Auto-Coder automatically translates your project files, so your code can conquer the world!
|
|
47
|
+
|
|
48
|
+
🤖 Copilot mode is here, and it's your new best friend! With its built-in shell/Jupyter engine, Auto-Coder breaks down tasks, sets up environments, creates projects, and even modifies code for you. It's like having a super-smart sidekick that never sleeps!
|
|
49
|
+
|
|
50
|
+
🧑💻 Developers, prepare to have your minds blown! Auto-Coder integrates seamlessly with the hottest AI models like ChatGPT, turbocharging your development process to lightning speeds! 🚀
|
|
51
|
+
|
|
52
|
+
🌟 Don't wait another second! Experience the raw power of Auto-Coder today and let AI be your ultimate coding companion! https://github.com/allwefantasy/auto-coder 🔥
|
|
53
|
+
|
|
54
|
+
#AutoCoder #AIProgramming #GameChanger #ByzerLLM #DevTools
|
|
55
|
+
|
|
34
56
|
## Table of Contents
|
|
35
57
|
|
|
36
|
-
- [Introduction](#introduction)
|
|
37
58
|
- [Brand new Installation](#brand-new-installation)
|
|
38
59
|
- [Existing Installation](#existing-installation)
|
|
39
60
|
- [Usage](#usage)
|
|
@@ -44,11 +65,7 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
44
65
|
- [Real-Auto](#real-auto)
|
|
45
66
|
|
|
46
67
|
|
|
47
|
-
## Introduction
|
|
48
68
|
|
|
49
|
-
Auto-Coder is a powerful tool powered by Byzer-LLM that streamlines code generation and project management. It collects source code from a specified directory and generates context based on user queries, which can be used with ChatGPT or other AI models. Auto-Coder also integrates with Byzer-LLM to generate results directly. It supports various project types, including Python, TypeScript, and offers advanced features like file translation and targeted code generation within specific modules and packages. With Auto-Coder, developers can significantly enhance their productivity and efficiently manage their projects, leveraging the power of AI-assisted coding.
|
|
50
|
-
|
|
51
|
-
The copilot project type can automatically do environment setup and project creation or create new classes and methods based on user queries. It is a powerful tool for developers to quickly create new projects and manage existing ones.
|
|
52
69
|
|
|
53
70
|
## Brand new Installation
|
|
54
71
|
|
|
@@ -219,8 +236,8 @@ Conda环境: byzerllm-dev
|
|
|
219
236
|
用户的问题是:用python打印你好,中国
|
|
220
237
|
|
|
221
238
|
每次生成一个执行步骤,然后询问我是否继续,当我回复继续,继续生成下一个执行步骤。
|
|
222
|
-
|
|
223
|
-
assistant:
|
|
239
|
+
|
|
240
|
+
assistant:
|
|
224
241
|
{
|
|
225
242
|
"code": "print('你好,中国')",
|
|
226
243
|
"lang": "python",
|
|
@@ -230,7 +247,7 @@ assistant: ```json
|
|
|
230
247
|
"timeout": -1,
|
|
231
248
|
"ignore_error": false
|
|
232
249
|
}
|
|
233
|
-
|
|
250
|
+
|
|
234
251
|
是否继续?
|
|
235
252
|
user: 继续
|
|
236
253
|
=================RESULT==================
|
|
@@ -18,13 +18,34 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
18
18
|
|
|
19
19
|
*Latest News* 🔥
|
|
20
20
|
|
|
21
|
-
- [2024/03] Release Auto-Coder 0.1.
|
|
21
|
+
- [2024/03] Release Auto-Coder 0.1.5
|
|
22
22
|
|
|
23
23
|
---
|
|
24
24
|
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
🚀 Attention developers! 🚨 The game-changing Auto-Coder has arrived, and it's about to take your AI programming to a whole new level! 🌟
|
|
28
|
+
|
|
29
|
+
Fueled by the incredible power of Byzer-LLM, this command-line tool is packed with features that will blow your mind:
|
|
30
|
+
|
|
31
|
+
📂 Say goodbye to manual context gathering! Auto-Coder intelligently generates code based on the context of your source directory. It's like having a genius assistant that knows exactly what you need!
|
|
32
|
+
|
|
33
|
+
💡 Two modes, endless possibilities! Generate perfect prompts to paste into web-based large models, or let Auto-Coder work its magic directly with private models via Byzer-LLM. The choice is yours, and the results are always spectacular!
|
|
34
|
+
|
|
35
|
+
💻 Python? TypeScript? No problem! Auto-Coder supports all the cool kids on the programming block.
|
|
36
|
+
|
|
37
|
+
🌍 Going global is a breeze! Auto-Coder automatically translates your project files, so your code can conquer the world!
|
|
38
|
+
|
|
39
|
+
🤖 Copilot mode is here, and it's your new best friend! With its built-in shell/Jupyter engine, Auto-Coder breaks down tasks, sets up environments, creates projects, and even modifies code for you. It's like having a super-smart sidekick that never sleeps!
|
|
40
|
+
|
|
41
|
+
🧑💻 Developers, prepare to have your minds blown! Auto-Coder integrates seamlessly with the hottest AI models like ChatGPT, turbocharging your development process to lightning speeds! 🚀
|
|
42
|
+
|
|
43
|
+
🌟 Don't wait another second! Experience the raw power of Auto-Coder today and let AI be your ultimate coding companion! https://github.com/allwefantasy/auto-coder 🔥
|
|
44
|
+
|
|
45
|
+
#AutoCoder #AIProgramming #GameChanger #ByzerLLM #DevTools
|
|
46
|
+
|
|
25
47
|
## Table of Contents
|
|
26
48
|
|
|
27
|
-
- [Introduction](#introduction)
|
|
28
49
|
- [Brand new Installation](#brand-new-installation)
|
|
29
50
|
- [Existing Installation](#existing-installation)
|
|
30
51
|
- [Usage](#usage)
|
|
@@ -35,11 +56,7 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
35
56
|
- [Real-Auto](#real-auto)
|
|
36
57
|
|
|
37
58
|
|
|
38
|
-
## Introduction
|
|
39
59
|
|
|
40
|
-
Auto-Coder is a powerful tool powered by Byzer-LLM that streamlines code generation and project management. It collects source code from a specified directory and generates context based on user queries, which can be used with ChatGPT or other AI models. Auto-Coder also integrates with Byzer-LLM to generate results directly. It supports various project types, including Python, TypeScript, and offers advanced features like file translation and targeted code generation within specific modules and packages. With Auto-Coder, developers can significantly enhance their productivity and efficiently manage their projects, leveraging the power of AI-assisted coding.
|
|
41
|
-
|
|
42
|
-
The copilot project type can automatically do environment setup and project creation or create new classes and methods based on user queries. It is a powerful tool for developers to quickly create new projects and manage existing ones.
|
|
43
60
|
|
|
44
61
|
## Brand new Installation
|
|
45
62
|
|
|
@@ -210,8 +227,8 @@ Conda环境: byzerllm-dev
|
|
|
210
227
|
用户的问题是:用python打印你好,中国
|
|
211
228
|
|
|
212
229
|
每次生成一个执行步骤,然后询问我是否继续,当我回复继续,继续生成下一个执行步骤。
|
|
213
|
-
|
|
214
|
-
assistant:
|
|
230
|
+
|
|
231
|
+
assistant:
|
|
215
232
|
{
|
|
216
233
|
"code": "print('你好,中国')",
|
|
217
234
|
"lang": "python",
|
|
@@ -221,7 +238,7 @@ assistant: ```json
|
|
|
221
238
|
"timeout": -1,
|
|
222
239
|
"ignore_error": false
|
|
223
240
|
}
|
|
224
|
-
|
|
241
|
+
|
|
225
242
|
是否继续?
|
|
226
243
|
user: 继续
|
|
227
244
|
=================RESULT==================
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -27,13 +27,34 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
27
27
|
|
|
28
28
|
*Latest News* 🔥
|
|
29
29
|
|
|
30
|
-
- [2024/03] Release Auto-Coder 0.1.
|
|
30
|
+
- [2024/03] Release Auto-Coder 0.1.5
|
|
31
31
|
|
|
32
32
|
---
|
|
33
33
|
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
🚀 Attention developers! 🚨 The game-changing Auto-Coder has arrived, and it's about to take your AI programming to a whole new level! 🌟
|
|
37
|
+
|
|
38
|
+
Fueled by the incredible power of Byzer-LLM, this command-line tool is packed with features that will blow your mind:
|
|
39
|
+
|
|
40
|
+
📂 Say goodbye to manual context gathering! Auto-Coder intelligently generates code based on the context of your source directory. It's like having a genius assistant that knows exactly what you need!
|
|
41
|
+
|
|
42
|
+
💡 Two modes, endless possibilities! Generate perfect prompts to paste into web-based large models, or let Auto-Coder work its magic directly with private models via Byzer-LLM. The choice is yours, and the results are always spectacular!
|
|
43
|
+
|
|
44
|
+
💻 Python? TypeScript? No problem! Auto-Coder supports all the cool kids on the programming block.
|
|
45
|
+
|
|
46
|
+
🌍 Going global is a breeze! Auto-Coder automatically translates your project files, so your code can conquer the world!
|
|
47
|
+
|
|
48
|
+
🤖 Copilot mode is here, and it's your new best friend! With its built-in shell/Jupyter engine, Auto-Coder breaks down tasks, sets up environments, creates projects, and even modifies code for you. It's like having a super-smart sidekick that never sleeps!
|
|
49
|
+
|
|
50
|
+
🧑💻 Developers, prepare to have your minds blown! Auto-Coder integrates seamlessly with the hottest AI models like ChatGPT, turbocharging your development process to lightning speeds! 🚀
|
|
51
|
+
|
|
52
|
+
🌟 Don't wait another second! Experience the raw power of Auto-Coder today and let AI be your ultimate coding companion! https://github.com/allwefantasy/auto-coder 🔥
|
|
53
|
+
|
|
54
|
+
#AutoCoder #AIProgramming #GameChanger #ByzerLLM #DevTools
|
|
55
|
+
|
|
34
56
|
## Table of Contents
|
|
35
57
|
|
|
36
|
-
- [Introduction](#introduction)
|
|
37
58
|
- [Brand new Installation](#brand-new-installation)
|
|
38
59
|
- [Existing Installation](#existing-installation)
|
|
39
60
|
- [Usage](#usage)
|
|
@@ -44,11 +65,7 @@ Auto-Coder (powered by Byzer-LLM)
|
|
|
44
65
|
- [Real-Auto](#real-auto)
|
|
45
66
|
|
|
46
67
|
|
|
47
|
-
## Introduction
|
|
48
68
|
|
|
49
|
-
Auto-Coder is a powerful tool powered by Byzer-LLM that streamlines code generation and project management. It collects source code from a specified directory and generates context based on user queries, which can be used with ChatGPT or other AI models. Auto-Coder also integrates with Byzer-LLM to generate results directly. It supports various project types, including Python, TypeScript, and offers advanced features like file translation and targeted code generation within specific modules and packages. With Auto-Coder, developers can significantly enhance their productivity and efficiently manage their projects, leveraging the power of AI-assisted coding.
|
|
50
|
-
|
|
51
|
-
The copilot project type can automatically do environment setup and project creation or create new classes and methods based on user queries. It is a powerful tool for developers to quickly create new projects and manage existing ones.
|
|
52
69
|
|
|
53
70
|
## Brand new Installation
|
|
54
71
|
|
|
@@ -219,8 +236,8 @@ Conda环境: byzerllm-dev
|
|
|
219
236
|
用户的问题是:用python打印你好,中国
|
|
220
237
|
|
|
221
238
|
每次生成一个执行步骤,然后询问我是否继续,当我回复继续,继续生成下一个执行步骤。
|
|
222
|
-
|
|
223
|
-
assistant:
|
|
239
|
+
|
|
240
|
+
assistant:
|
|
224
241
|
{
|
|
225
242
|
"code": "print('你好,中国')",
|
|
226
243
|
"lang": "python",
|
|
@@ -230,7 +247,7 @@ assistant: ```json
|
|
|
230
247
|
"timeout": -1,
|
|
231
248
|
"ignore_error": false
|
|
232
249
|
}
|
|
233
|
-
|
|
250
|
+
|
|
234
251
|
是否继续?
|
|
235
252
|
user: 继续
|
|
236
253
|
=================RESULT==================
|
|
@@ -16,6 +16,8 @@ src/autocoder/common/const.py
|
|
|
16
16
|
src/autocoder/dispacher/__init__.py
|
|
17
17
|
src/autocoder/dispacher/actions/__init__.py
|
|
18
18
|
src/autocoder/dispacher/actions/copilot.py
|
|
19
|
+
src/autocoder/index/__init__.py
|
|
20
|
+
src/autocoder/index/index.py
|
|
19
21
|
src/autocoder/pyproject/__init__.py
|
|
20
22
|
src/autocoder/suffixproject/__init__.py
|
|
21
23
|
src/autocoder/tsproject/__init__.py
|
|
@@ -18,7 +18,7 @@ def parse_args() -> AutoCoderArgs:
|
|
|
18
18
|
parser.add_argument("--script_path", default="", help="only works for py-script project type. The path to the Python script. default is empty.")
|
|
19
19
|
parser.add_argument("--model", default="", help="the model name to use")
|
|
20
20
|
parser.add_argument("--model_max_length", type=int, default=1024, help="the maximum length generated by the model. default is 1024 this only works when model is specified.")
|
|
21
|
-
parser.add_argument("--file", help="Path to the YAML configuration file")
|
|
21
|
+
parser.add_argument("--file", default=None, required=False, help="Path to the YAML configuration file")
|
|
22
22
|
parser.add_argument("--anti_quota_limit",type=int, default=1, help="After how much time to wait for the next request. default is 1s")
|
|
23
23
|
|
|
24
24
|
args = parser.parse_args()
|
|
@@ -3,6 +3,7 @@ import ast
|
|
|
3
3
|
import sys
|
|
4
4
|
import subprocess
|
|
5
5
|
import os
|
|
6
|
+
import time
|
|
6
7
|
from typing import List,Dict,Any,Optional
|
|
7
8
|
|
|
8
9
|
class SourceCode(pydantic.BaseModel):
|
|
@@ -63,7 +64,7 @@ class AutoCoderArgs(pydantic.BaseModel):
|
|
|
63
64
|
script_path: str = pydantic.Field("", description="only works for py-script project type. The path to the Python script. default is empty.")
|
|
64
65
|
model: str = pydantic.Field("", description="the model name to use")
|
|
65
66
|
model_max_length: int = pydantic.Field(1024, description="the maximum length generated by the model. default is 1024 this only works when model is specified.")
|
|
66
|
-
file: str = pydantic.Field(
|
|
67
|
+
file: Optional[str] = pydantic.Field(None, description="the configuration file to use")
|
|
67
68
|
anti_quota_limit: Optional[int] = pydantic.Field(1, description="After how much time to wait for the next request. default is 1s")
|
|
68
69
|
|
|
69
70
|
|
|
@@ -150,4 +151,38 @@ def detect_env() -> EnvInfo:
|
|
|
150
151
|
conda_env=conda_env,
|
|
151
152
|
virtualenv=virtualenv,
|
|
152
153
|
has_bash=has_bash
|
|
153
|
-
)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def chat_with_llm_step_by_step(llm,conversations, response_class, max_steps=30, anti_quota_limit=1):
|
|
158
|
+
result = []
|
|
159
|
+
t = llm.chat_oai(conversations=conversations, response_class=response_class)
|
|
160
|
+
total_steps = max_steps
|
|
161
|
+
current_step = 0
|
|
162
|
+
|
|
163
|
+
if not t[0].value:
|
|
164
|
+
total_steps = t[0].value.total_steps
|
|
165
|
+
if total_steps == 1:
|
|
166
|
+
current_step = 1
|
|
167
|
+
|
|
168
|
+
while current_step < total_steps and max_steps > 0 and t[0].value:
|
|
169
|
+
total_steps = t[0].value.total_steps
|
|
170
|
+
result.append(t[0].value)
|
|
171
|
+
conversations.append({
|
|
172
|
+
"role": "assistant",
|
|
173
|
+
"content": t[0].response.output
|
|
174
|
+
})
|
|
175
|
+
print(f"{conversations[-1]['role']}: {conversations[-1]['content']}\n", flush=True)
|
|
176
|
+
|
|
177
|
+
conversations.append({
|
|
178
|
+
"role": "user",
|
|
179
|
+
"content": "继续"
|
|
180
|
+
})
|
|
181
|
+
print(f"{conversations[-1]['role']}: {conversations[-1]['content']}\n", flush=True)
|
|
182
|
+
|
|
183
|
+
t = llm.chat_oai(conversations=conversations, response_class=response_class)
|
|
184
|
+
max_steps -= 1
|
|
185
|
+
current_step += 1
|
|
186
|
+
time.sleep(anti_quota_limit)
|
|
187
|
+
|
|
188
|
+
return result, conversations
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from autocoder.common import AutoCoderArgs,ExecuteSteps,ExecuteStep,EnvInfo,detect_env
|
|
1
|
+
from autocoder.common import AutoCoderArgs,ExecuteSteps,ExecuteStep,EnvInfo,detect_env,chat_with_llm_step_by_step
|
|
2
2
|
from autocoder.common.JupyterClient import JupyterNotebook
|
|
3
3
|
from autocoder.common.ShellClient import ShellClient
|
|
4
4
|
from autocoder.suffixproject import SuffixProject
|
|
@@ -42,25 +42,12 @@ class ActionCopilot():
|
|
|
42
42
|
用户的问题是:{{ s }}
|
|
43
43
|
|
|
44
44
|
每次生成一个执行步骤,然后询问我是否继续,当我回复继续,继续生成下一个执行步骤。
|
|
45
|
-
'''
|
|
46
|
-
|
|
47
|
-
@byzerllm.prompt(lambda self:self.llm,render="jinja2")
|
|
48
|
-
def get_all_file_symbols(self,path:str,code:str)->str:
|
|
49
|
-
'''
|
|
50
|
-
下列是文件 {{ path }} 的源码:
|
|
51
|
-
|
|
52
|
-
{{ code }}
|
|
53
|
-
|
|
54
|
-
从上述内容中获取文件中的符号。需要获取的符号类型包括:函数、类、变量、模块、包
|
|
55
|
-
按如下格式返回:
|
|
56
|
-
|
|
57
|
-
符号类型: 符号名称
|
|
58
|
-
'''
|
|
45
|
+
'''
|
|
59
46
|
|
|
60
47
|
def execute_steps(self, steps: ExecuteSteps) -> str:
|
|
61
48
|
jupyter_client = JupyterNotebook()
|
|
62
49
|
shell_client = ShellClient()
|
|
63
|
-
|
|
50
|
+
|
|
64
51
|
output = ""
|
|
65
52
|
for step in steps.steps:
|
|
66
53
|
if step.lang == "python":
|
|
@@ -130,36 +117,14 @@ class ActionCopilot():
|
|
|
130
117
|
}]
|
|
131
118
|
|
|
132
119
|
print(f"{conversations[0]['role']}: {conversations[0]['content']}\n",flush=True)
|
|
133
|
-
|
|
134
|
-
t = self.llm.chat_oai(conversations=conversations,response_class=ExecuteStep)
|
|
135
|
-
max_steps = 30
|
|
136
|
-
total_steps = max_steps
|
|
137
|
-
current_step = 0
|
|
138
|
-
|
|
139
|
-
if not t[0].value:
|
|
140
|
-
total_steps = t[0].value.total_steps
|
|
141
|
-
if total_steps == 1:
|
|
142
|
-
current_step = 1
|
|
143
120
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"role":"assistant",
|
|
149
|
-
"content":t[0].response.output
|
|
150
|
-
})
|
|
151
|
-
print(f"{conversations[-1]['role']}: {conversations[-1]['content']}\n",flush=True)
|
|
152
|
-
|
|
153
|
-
conversations.append({
|
|
154
|
-
"role":"user",
|
|
155
|
-
"content":"继续"
|
|
156
|
-
})
|
|
157
|
-
print(f"{conversations[-1]['role']}: {conversations[-1]['content']}\n",flush=True)
|
|
121
|
+
(result,_) = chat_with_llm_step_by_step(self.llm,conversations=conversations,
|
|
122
|
+
response_class=ExecuteStep,
|
|
123
|
+
max_steps=30,
|
|
124
|
+
anti_quota_limit=args.anti_quota_limit)
|
|
158
125
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
current_step += 1
|
|
162
|
-
time.sleep(args.anti_quota_limit)
|
|
126
|
+
for item in result:
|
|
127
|
+
final_v.steps.append(item)
|
|
163
128
|
|
|
164
129
|
# 执行步骤并保存结果
|
|
165
130
|
result = self.execute_steps(final_v)
|
|
File without changes
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
##File: /home/winubuntu/projects/ByzerRawCopilot/src/autocoder/index/index.py
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
import json
|
|
5
|
+
from typing import List
|
|
6
|
+
from datetime import datetime
|
|
7
|
+
from autocoder.common import SourceCode
|
|
8
|
+
|
|
9
|
+
from pydantic import BaseModel
|
|
10
|
+
import byzerllm
|
|
11
|
+
|
|
12
|
+
class IndexItem(BaseModel):
|
|
13
|
+
module_name: str
|
|
14
|
+
symbols: str
|
|
15
|
+
last_modified: str
|
|
16
|
+
|
|
17
|
+
class IndexManager:
|
|
18
|
+
def __init__(self, llm,sources: List[SourceCode], source_dir: str):
|
|
19
|
+
self.sources = sources
|
|
20
|
+
self.source_dir = source_dir
|
|
21
|
+
self.index_dir = os.path.join(source_dir, ".auto-coder")
|
|
22
|
+
self.index_file = os.path.join(self.index_dir, "index.json")
|
|
23
|
+
self.llm = llm
|
|
24
|
+
|
|
25
|
+
# 如果索引目录不存在,则创建它
|
|
26
|
+
if not os.path.exists(self.index_dir):
|
|
27
|
+
os.makedirs(self.index_dir)
|
|
28
|
+
|
|
29
|
+
@byzerllm.prompt(lambda self:self.llm,render="jinja2")
|
|
30
|
+
def get_all_file_symbols(self,path:str,code:str)->str:
|
|
31
|
+
'''
|
|
32
|
+
下列是文件 {{ path }} 的源码:
|
|
33
|
+
|
|
34
|
+
{{ code }}
|
|
35
|
+
|
|
36
|
+
从上述内容中获取文件中的符号。需要获取的符号类型包括:函数、类、变量、模块、包。 如果没有任何符号,返回"没有任何符号"。
|
|
37
|
+
按如下格式返回:
|
|
38
|
+
|
|
39
|
+
符号类型: 符号名称, 符号名称, ...
|
|
40
|
+
'''
|
|
41
|
+
|
|
42
|
+
def build_index(self):
|
|
43
|
+
if os.path.exists(self.index_file):
|
|
44
|
+
with open(self.index_file, "r") as file:
|
|
45
|
+
index_data = json.load(file)
|
|
46
|
+
else:
|
|
47
|
+
index_data = {}
|
|
48
|
+
|
|
49
|
+
updated_sources = []
|
|
50
|
+
|
|
51
|
+
for source in self.sources:
|
|
52
|
+
file_path = source.module_name
|
|
53
|
+
if os.path.exists(file_path):
|
|
54
|
+
last_modified = os.path.getmtime(file_path)
|
|
55
|
+
if source.module_name in index_data and index_data[source.module_name]["last_modified"] == last_modified:
|
|
56
|
+
continue
|
|
57
|
+
|
|
58
|
+
symbols = self.get_all_file_symbols(source.module_name, source.source_code)
|
|
59
|
+
index_data[source.module_name] = {
|
|
60
|
+
"symbols": symbols,
|
|
61
|
+
"last_modified": last_modified
|
|
62
|
+
}
|
|
63
|
+
updated_sources.append(source)
|
|
64
|
+
|
|
65
|
+
if updated_sources:
|
|
66
|
+
with open(self.index_file, "w") as file:
|
|
67
|
+
json.dump(index_data, file, ensure_ascii=False, indent=2)
|
|
68
|
+
|
|
69
|
+
return index_data
|
|
70
|
+
|
|
71
|
+
def read_index(self) -> List[IndexItem]:
|
|
72
|
+
if not os.path.exists(self.index_file):
|
|
73
|
+
return []
|
|
74
|
+
|
|
75
|
+
with open(self.index_file, "r") as file:
|
|
76
|
+
index_data = json.load(file)
|
|
77
|
+
|
|
78
|
+
index_items = []
|
|
79
|
+
for module_name, data in index_data.items():
|
|
80
|
+
index_item = IndexItem(
|
|
81
|
+
module_name=module_name,
|
|
82
|
+
symbols=data["symbols"],
|
|
83
|
+
last_modified=data["last_modified"]
|
|
84
|
+
)
|
|
85
|
+
index_items.append(index_item)
|
|
86
|
+
|
|
87
|
+
return index_items
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.5"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|