autocoder-nano 0.1.30__py3-none-any.whl → 0.1.33__py3-none-any.whl
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.
- autocoder_nano/agent/agent_base.py +4 -4
- autocoder_nano/agent/agentic_edit.py +1584 -0
- autocoder_nano/agent/agentic_edit_tools/__init__.py +28 -0
- autocoder_nano/agent/agentic_edit_tools/ask_followup_question_tool.py +51 -0
- autocoder_nano/agent/agentic_edit_tools/attempt_completion_tool.py +36 -0
- autocoder_nano/agent/agentic_edit_tools/base_tool_resolver.py +31 -0
- autocoder_nano/agent/agentic_edit_tools/execute_command_tool.py +65 -0
- autocoder_nano/agent/agentic_edit_tools/list_code_definition_names_tool.py +78 -0
- autocoder_nano/agent/agentic_edit_tools/list_files_tool.py +123 -0
- autocoder_nano/agent/agentic_edit_tools/list_package_info_tool.py +42 -0
- autocoder_nano/agent/agentic_edit_tools/plan_mode_respond_tool.py +35 -0
- autocoder_nano/agent/agentic_edit_tools/read_file_tool.py +73 -0
- autocoder_nano/agent/agentic_edit_tools/replace_in_file_tool.py +148 -0
- autocoder_nano/agent/agentic_edit_tools/search_files_tool.py +135 -0
- autocoder_nano/agent/agentic_edit_tools/write_to_file_tool.py +57 -0
- autocoder_nano/agent/agentic_edit_types.py +151 -0
- autocoder_nano/auto_coder_nano.py +145 -91
- autocoder_nano/git_utils.py +63 -1
- autocoder_nano/llm_client.py +170 -3
- autocoder_nano/llm_types.py +53 -14
- autocoder_nano/rules/rules_learn.py +221 -0
- autocoder_nano/templates.py +1 -1
- autocoder_nano/utils/formatted_log_utils.py +128 -0
- autocoder_nano/utils/printer_utils.py +5 -4
- autocoder_nano/utils/shell_utils.py +85 -0
- autocoder_nano/version.py +1 -1
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/METADATA +3 -2
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/RECORD +33 -16
- autocoder_nano/agent/new/auto_new_project.py +0 -278
- /autocoder_nano/{agent/new → rules}/__init__.py +0 -0
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/LICENSE +0 -0
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/WHEEL +0 -0
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/entry_points.txt +0 -0
- {autocoder_nano-0.1.30.dist-info → autocoder_nano-0.1.33.dist-info}/top_level.txt +0 -0
@@ -1,20 +1,33 @@
|
|
1
1
|
autocoder_nano/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
-
autocoder_nano/auto_coder_nano.py,sha256
|
2
|
+
autocoder_nano/auto_coder_nano.py,sha256=Oxm9hJRrFaBexeeNgDXPfoov5BdAu9xmPktjGzZ5ZHo,104662
|
3
3
|
autocoder_nano/auto_coder_nano_rag.py,sha256=9BtNZ6nC5D5SPTIuziXZOfouCBLOMNzvJMTdDPQEgO8,10436
|
4
4
|
autocoder_nano/auto_coder_nano_ui.py,sha256=ZBskcIJMeTJY7_JipGJaee58G9fUJaOv3LV4hptLc6c,12669
|
5
5
|
autocoder_nano/file_utils.py,sha256=iGbkbQ191nKL4aNufdexYYYQSDM1XrDC9Uxp_PIbawY,661
|
6
|
-
autocoder_nano/git_utils.py,sha256=
|
6
|
+
autocoder_nano/git_utils.py,sha256=zAhXi5WFHklpkoPH04kkXpQjQJv1CEHbXE-O3tqyNlA,23194
|
7
7
|
autocoder_nano/helper.py,sha256=LbieDBKp408x9g4GHCvcujUgMgxDTV9owGHIBYpT1ww,6643
|
8
|
-
autocoder_nano/llm_client.py,sha256=
|
8
|
+
autocoder_nano/llm_client.py,sha256=aB6ZCZnMF28RvoPuqORZAneMpvIy16mPrB7-1vVKTao,11207
|
9
9
|
autocoder_nano/llm_prompt.py,sha256=ViWUfCZp0gDESAAPHBhZc2WhHiFUHIxK6a2xbFu0sjU,10864
|
10
|
-
autocoder_nano/llm_types.py,sha256=
|
10
|
+
autocoder_nano/llm_types.py,sha256=B7iJjaKsAuw984BCxCoGQHTLRWDiiW5eGmVEzgftOuk,11038
|
11
11
|
autocoder_nano/sys_utils.py,sha256=Sn6kr5diaEkVWbYDBrtenr9zw32jVIWvsAReY7_uEd0,1638
|
12
|
-
autocoder_nano/templates.py,sha256=
|
13
|
-
autocoder_nano/version.py,sha256=
|
12
|
+
autocoder_nano/templates.py,sha256=fqlRtnx6HvPE4CbdnPcnLBB-flPwufwcGRpsFD3aW2c,4271
|
13
|
+
autocoder_nano/version.py,sha256=Fe_iRBdCULDeTWWRIy1JuodlT2lPcNeViHhLCGYHuZU,79
|
14
14
|
autocoder_nano/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
15
|
-
autocoder_nano/agent/agent_base.py,sha256=
|
16
|
-
autocoder_nano/agent/
|
17
|
-
autocoder_nano/agent/
|
15
|
+
autocoder_nano/agent/agent_base.py,sha256=O5Hq6VnoqrXnBE_oXZHXlbmSRdOEe28H65bJ1WhAQjg,16377
|
16
|
+
autocoder_nano/agent/agentic_edit.py,sha256=I1HjRhMabDmtfxcCOKawUJV0wU1GNzKtof19_GNgAjU,88749
|
17
|
+
autocoder_nano/agent/agentic_edit_types.py,sha256=RAEN2cBoPVZjx6aD6uYo2FPyyARwdBUpDG7qsSAY9kE,3620
|
18
|
+
autocoder_nano/agent/agentic_edit_tools/__init__.py,sha256=E0zSUcPnYyAkEfkknNcb7oDBpuYY_UAKnCOaEyltYg0,1157
|
19
|
+
autocoder_nano/agent/agentic_edit_tools/ask_followup_question_tool.py,sha256=dIWjZQ3N5Y_yXs_SwGjx7nqBRfysEoQylQivGW4wRzY,2006
|
20
|
+
autocoder_nano/agent/agentic_edit_tools/attempt_completion_tool.py,sha256=msiYZoZnDhVTHEua_RnM2R3Ss-cpF3MSPwhb_Hl5mo4,1406
|
21
|
+
autocoder_nano/agent/agentic_edit_tools/base_tool_resolver.py,sha256=LPfMRGpTsXLDYHyzKFcNLrXvvSNNKF3bes6q-tB2ho0,943
|
22
|
+
autocoder_nano/agent/agentic_edit_tools/execute_command_tool.py,sha256=aRfbaDWajaFaxodYJjq59dqYAPolC0fiA2jnjIxD_yY,3007
|
23
|
+
autocoder_nano/agent/agentic_edit_tools/list_code_definition_names_tool.py,sha256=6FiUL4Z8mQr5LKRDhIDv0KmGL1coo3zaI9RVr30oj88,3714
|
24
|
+
autocoder_nano/agent/agentic_edit_tools/list_files_tool.py,sha256=LheSa7sjMlGy7n1AdjsHDn6yey-BYEeMfjE73zNtjL0,5880
|
25
|
+
autocoder_nano/agent/agentic_edit_tools/list_package_info_tool.py,sha256=8FDBt0CDQXGxqCEp1zl92zAX4hqjADz0wyvC5GlVi9I,1885
|
26
|
+
autocoder_nano/agent/agentic_edit_tools/plan_mode_respond_tool.py,sha256=gipMpb3bYMDR5U2axOpSwCeAZFYVyGerkUUpwBFDu9g,1447
|
27
|
+
autocoder_nano/agent/agentic_edit_tools/read_file_tool.py,sha256=TAMJbO06Ij1Cuxh3JAa4U5sxbeAv6UGdYU4xs25Uh7Q,3102
|
28
|
+
autocoder_nano/agent/agentic_edit_tools/replace_in_file_tool.py,sha256=d0PZGB9U5snXpXs7S2n39NCO0mKyMLb7z1v6HTKj6rI,6742
|
29
|
+
autocoder_nano/agent/agentic_edit_tools/search_files_tool.py,sha256=lPa0tCx25scmZ5RlZ9Laplm6WzrKFTS-lYgfe_L6viw,6078
|
30
|
+
autocoder_nano/agent/agentic_edit_tools/write_to_file_tool.py,sha256=IQksmLOuuaFxiOkIFzMs9dDTT3ZXunJZdY75coDFmWg,2479
|
18
31
|
autocoder_nano/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
19
32
|
autocoder_nano/app/static/css/ai.css,sha256=_o_dSPnrp9lmvtvE8tm7thu6iOy8tsJKR-X30ZhE_h4,10115
|
20
33
|
autocoder_nano/app/static/css/editormd.preview.min.css,sha256=c2LS2plIKcSyN9op6NLqkxRpYAPCcyl4o9gJa5_xlXM,44903
|
@@ -65,15 +78,19 @@ autocoder_nano/rag/doc_storage.py,sha256=sEfX-2PsRTOk7MiwqtY3u0lzqMBwTsPXeIknkAY
|
|
65
78
|
autocoder_nano/rag/long_context_rag.py,sha256=jpTfJg38pfVgL0FGFwe6nmBgQAMEAYtBw9ZLQQcFfpM,21862
|
66
79
|
autocoder_nano/rag/token_counter.py,sha256=tHuht9huViEnpqiUVN_xUcgBOHJ0T-6dmk4IWzc_Cd0,1979
|
67
80
|
autocoder_nano/research/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
81
|
+
autocoder_nano/rules/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
82
|
+
autocoder_nano/rules/rules_learn.py,sha256=P65_wwZ1sBxcQPTwdb7roqmkW_bj1SJQaZMLpUkglL4,7297
|
68
83
|
autocoder_nano/ss/__init__.py,sha256=jp9Az7c0uafZcC6qfxjyZnSnVLtgA_4UdakSOcp8osE,34
|
69
84
|
autocoder_nano/ss/search_engine.py,sha256=4_RcxF1almJX5XlLWB7d9UXM92YDK2bOqoCrkuGg5Mc,3720
|
70
85
|
autocoder_nano/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
71
86
|
autocoder_nano/tools/http_tools.py,sha256=04Tmg8BTwfsw7_-fKBDHv787XU4yQ5UtQSDj0zJBIUc,3189
|
72
87
|
autocoder_nano/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
73
|
-
autocoder_nano/utils/
|
74
|
-
autocoder_nano
|
75
|
-
autocoder_nano
|
76
|
-
autocoder_nano-0.1.
|
77
|
-
autocoder_nano-0.1.
|
78
|
-
autocoder_nano-0.1.
|
79
|
-
autocoder_nano-0.1.
|
88
|
+
autocoder_nano/utils/formatted_log_utils.py,sha256=1d3xvZ1Bo3-I1wQOMdXpwsMX5cl2FWkmpgHGHvTPEvI,5457
|
89
|
+
autocoder_nano/utils/printer_utils.py,sha256=6rGHihCh8DDESWs6qWqwsf3B6qaeM_CNx6crzkl9UCk,15303
|
90
|
+
autocoder_nano/utils/shell_utils.py,sha256=llVTrOrmS1RH2ws7W69tofVtf53Kq04uh-sURphejrU,2477
|
91
|
+
autocoder_nano-0.1.33.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
92
|
+
autocoder_nano-0.1.33.dist-info/METADATA,sha256=kpKkHjPw3_07Hf_TRNSSaaWXSkMQ3zKYQuDYsB__WEY,13591
|
93
|
+
autocoder_nano-0.1.33.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
94
|
+
autocoder_nano-0.1.33.dist-info/entry_points.txt,sha256=Dj8gGZ_AgLy8ANqr2do_DJjpsR3JMh-ztsrUXo4Vn5Q,194
|
95
|
+
autocoder_nano-0.1.33.dist-info/top_level.txt,sha256=D7s34cwIs1F4EAjRRDvO_zTHtUz1Z7UVccFUNlJn7HI,15
|
96
|
+
autocoder_nano-0.1.33.dist-info/RECORD,,
|
@@ -1,278 +0,0 @@
|
|
1
|
-
from typing import List
|
2
|
-
|
3
|
-
from pydantic import BaseModel
|
4
|
-
from loguru import logger
|
5
|
-
|
6
|
-
from autocoder_nano.llm_client import AutoLLM
|
7
|
-
from autocoder_nano.llm_prompt import prompt, extract_code
|
8
|
-
from autocoder_nano.llm_types import AutoCoderArgs
|
9
|
-
from autocoder_nano.sys_utils import detect_env
|
10
|
-
|
11
|
-
|
12
|
-
class IndexFilePath(BaseModel):
|
13
|
-
file_path: str
|
14
|
-
purpose: str
|
15
|
-
symbols: str
|
16
|
-
|
17
|
-
|
18
|
-
class ProjectFileList(BaseModel):
|
19
|
-
file_list: List[IndexFilePath]
|
20
|
-
|
21
|
-
|
22
|
-
class BuildNewProject:
|
23
|
-
"""
|
24
|
-
步骤一:完善需求,用户可能提出的需求是一个较为简短的需求,需要完善需求
|
25
|
-
步骤二:设计架构,
|
26
|
-
步骤三:构建索引,
|
27
|
-
步骤四:完成代码,
|
28
|
-
"""
|
29
|
-
|
30
|
-
def __init__(self, args: AutoCoderArgs, llm: AutoLLM, chat_model: str, code_model: str):
|
31
|
-
self.args = args
|
32
|
-
self.llm = llm
|
33
|
-
self.chat_model = chat_model
|
34
|
-
self.code_model = code_model
|
35
|
-
|
36
|
-
@prompt()
|
37
|
-
def _build_project_information(self, query, env_info, language):
|
38
|
-
"""
|
39
|
-
请根据以下简短需求,逐步进行完善工作:
|
40
|
-
这是我的原始需求: {{ query }}
|
41
|
-
|
42
|
-
环境信息如下:
|
43
|
-
操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
|
44
|
-
编程语言: {{ language }}
|
45
|
-
|
46
|
-
需要你自动执行以下步骤:
|
47
|
-
1. 需求补全 - 对简短需求进行描述扩充,诸如程序描述,目标用户,特色功能等。
|
48
|
-
2. 核心模块 - 生成5-8个核心功能模块(自动推测缺失环节)。
|
49
|
-
3. 技术映射 - 根据所使用的编程语言,以及功能,推荐使用的库并说明选择理由。
|
50
|
-
4. 风险预判 - 列出3项最高优先级的实施风险及应对方案。
|
51
|
-
5. 交互原型 - 输出关键功能的流程图/状态图(可使用简单易懂的方式诸如 A -> B 表达)。
|
52
|
-
|
53
|
-
说明:
|
54
|
-
1. 整体需求补充字数不要超过500,每条补充项不要超过100
|
55
|
-
|
56
|
-
下面是一段示例:
|
57
|
-
## 输入
|
58
|
-
这是我的原始需求: 完成一个坦克大战
|
59
|
-
|
60
|
-
环境信息如下:
|
61
|
-
操作系统: Linux
|
62
|
-
编程语言: Python 3.10
|
63
|
-
|
64
|
-
## 输出
|
65
|
-
1.需求补全:
|
66
|
-
开发经典坦克大战复刻版,支持双人本地协作。玩家通过摧毁敌方坦克保护基地,包含随机生成战场、可破坏地形、敌方AI军团、装备强化系统。
|
67
|
-
具备关卡难度递增、实时计分板、战场特效,要求保留原版核心操作手感和战术策略要素。
|
68
|
-
2. 核心模块:
|
69
|
-
- 随机生成地图系统(可破坏障碍/固定墙体)
|
70
|
-
- 双人本地操作模式(WASD+方向键控制)
|
71
|
-
- 敌方AI自动寻路与攻击模块
|
72
|
-
- 碰撞检测系统(子弹/地形/坦克交互)
|
73
|
-
- 计分系统与关卡推进机制
|
74
|
-
- 坦克能力升级系统(速度/护甲/弹药)
|
75
|
-
- 基地保护核心机制
|
76
|
-
- 战场音效与爆炸特效
|
77
|
-
3. 技术映射
|
78
|
-
- Pygame(2D渲染/事件处理/跨平台)
|
79
|
-
- Tiled(地图编辑器集成)
|
80
|
-
- pathfinding(A*算法实现AI移动)
|
81
|
-
- Pygame.mixer(音效管理)
|
82
|
-
- json(关卡配置存储)
|
83
|
-
- numpy(碰撞矩阵运算加速)
|
84
|
-
4. 风险预判
|
85
|
-
- 多物体碰撞性能瓶颈 → 采用空间分割优化检测范围
|
86
|
-
- 双人输入事件冲突 → 使用独立事件队列处理
|
87
|
-
- AI路径finding卡死 → 设置随机方向重置机制
|
88
|
-
5. 交互原型
|
89
|
-
- 主循环流程:初始化 → 玩家控制 → AI行动 → 碰撞检测 → 渲染更新 → 胜利/失败判断 → 关卡切换
|
90
|
-
- 子弹碰撞逻辑:子弹发射 → 碰撞检测 → (墙体: 消失 | 坦克: 扣血 | 基地: 游戏结束)
|
91
|
-
"""
|
92
|
-
|
93
|
-
def build_project_information(self, query, env_info, language):
|
94
|
-
self.llm.setup_default_model_name(self.chat_model)
|
95
|
-
try:
|
96
|
-
result = self._build_project_information.with_llm(self.llm).run(query, env_info, language)
|
97
|
-
information = result.output
|
98
|
-
return information
|
99
|
-
except Exception as err:
|
100
|
-
logger.error(f"完善项目需求错误: {str(err)}")
|
101
|
-
return None
|
102
|
-
|
103
|
-
@prompt()
|
104
|
-
def _build_project_architecture(self, query, env_info, language, information):
|
105
|
-
"""
|
106
|
-
这是我的原始需求: {{ query }}
|
107
|
-
|
108
|
-
环境信息如下:
|
109
|
-
操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
|
110
|
-
编程语言: {{ language }}
|
111
|
-
|
112
|
-
补充后的需求:
|
113
|
-
{{ information }}
|
114
|
-
|
115
|
-
1. 根据编程语言及需求,首先判断项目项目类型(可能是 Web应用,命令行工具或数据处理管道)
|
116
|
-
2. 首先构建一个的基础目录结构(可参考如下结构)
|
117
|
-
- src 目录:源代码目录
|
118
|
-
- tests 目录: 用于存放测试文件
|
119
|
-
- docs 目录:用于存放文档
|
120
|
-
- scripts 目录:用于存放实用脚本
|
121
|
-
3. 接下来需要考虑 分层架构,比如将核心逻辑,接口,数据层,工具类等分开
|
122
|
-
4. 同时还需要考虑各个模块的划分。比如,
|
123
|
-
- 核心业务逻辑放在core模块
|
124
|
-
- API路由在 api 目录
|
125
|
-
- 数据模型在 models 目录
|
126
|
-
- 数据库交互在 database 目录
|
127
|
-
- 工具函数在 utils 目录
|
128
|
-
- 中间件在 middleware 目录(如果是Web应用)
|
129
|
-
- 配置加载在 config 目录
|
130
|
-
- 错误处理在 errors 目录
|
131
|
-
- 日志配置在 logs 等
|
132
|
-
5. 还需要考虑依赖管理,比如py项目使用requirements管理依赖(分为开发和生产环境),或者使用Pipenv/Poetry
|
133
|
-
6. 测试部分应有单元测试、集成测试,可能使用pytest,并在CI/CD中配置
|
134
|
-
|
135
|
-
根据以上思路,我需要构建一个清晰,分层,模块化的目录结构,每个部分职责明确,方便扩展和维护,同时给出简要说明,让用户了解如何填充和扩展各个模块。
|
136
|
-
返回结果按如下格式:
|
137
|
-
|
138
|
-
- path/to/file1.py, 脚本功能描述
|
139
|
-
- path/to/file2.py, 脚本功能描述
|
140
|
-
- path/to/file3.py, 脚本功能描述
|
141
|
-
|
142
|
-
请严格遵循以下规则:
|
143
|
-
1. 脚本路径请使用相对路径(诸如 src/,core/,api/,utils/)
|
144
|
-
2. 脚本功能描述说明该脚本的详细用途(控制在50字以内,且使用中文)
|
145
|
-
3. 控制代码文件的数量,根据需求的复杂程度,简单需求代码文件控制在 5 个以内,中等需求文件数量控制在 5-10个,复杂项目文件数量控制在 10-20 个
|
146
|
-
4. 请严格按格式要求返回结果,无需额外的说明
|
147
|
-
"""
|
148
|
-
|
149
|
-
def build_project_architecture(self, query, env_info, language, information):
|
150
|
-
self.llm.setup_default_model_name(self.chat_model)
|
151
|
-
try:
|
152
|
-
result = self._build_project_architecture.with_llm(self.llm).run(query, env_info, language, information)
|
153
|
-
architecture = result.output
|
154
|
-
return architecture
|
155
|
-
except Exception as err:
|
156
|
-
logger.error(f"完善项目架构错误: {str(err)}")
|
157
|
-
return None
|
158
|
-
|
159
|
-
@prompt()
|
160
|
-
def _build_project_index(self, query, env_info, language, information, architecture):
|
161
|
-
"""
|
162
|
-
这是我的原始需求: {{ query }}
|
163
|
-
|
164
|
-
环境信息如下:
|
165
|
-
操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
|
166
|
-
编程语言: {{ language }}
|
167
|
-
|
168
|
-
补充后的需求:
|
169
|
-
{{ information }}
|
170
|
-
|
171
|
-
项目结构如下:
|
172
|
-
{{ architecture }}
|
173
|
-
|
174
|
-
我提供了以上诸如 '需求信息','目录结构' 信息。
|
175
|
-
根据用户需求,对目录结构中的文件,依次进行扩充,即我需要完成这个用途的脚本,
|
176
|
-
需要导入哪些库,创建哪些类,函数,变量,这些信息在后续可以直接用于生成代码
|
177
|
-
|
178
|
-
扩充信息包括
|
179
|
-
1. 函数
|
180
|
-
2. 类
|
181
|
-
3. 变量
|
182
|
-
4. 所有导入语句
|
183
|
-
|
184
|
-
下面是一段示例:
|
185
|
-
|
186
|
-
## 输入
|
187
|
-
- src/core/game_loop.py, 游戏主循环控制器,负责帧率同步和模块调度
|
188
|
-
- src/core/shape_generator.py, 七种基础形状生成及预览队列管理
|
189
|
-
|
190
|
-
## 输出
|
191
|
-
```json
|
192
|
-
{
|
193
|
-
"file_list": [
|
194
|
-
{
|
195
|
-
"file_path": "src/core/game_loop.py",
|
196
|
-
"purpose": "游戏主循环控制器,负责帧率同步和模块调度",
|
197
|
-
"symbols": "\n函数:build_metadata+函数用途,main+函数用途\n变量:loop_time+变量用途\n类:\n导入语句:import csv^^import netaddr"
|
198
|
-
},
|
199
|
-
{
|
200
|
-
"file_path": "src/core/shape_generator.py",
|
201
|
-
"purpose": "七种基础形状生成及预览队列管理",
|
202
|
-
"symbols": "\n函数:build_metadata+函数用途,main+函数用途\n变量:loop_time+变量用途\n类:\n导入语句:import csv^^import netaddr"
|
203
|
-
}
|
204
|
-
]
|
205
|
-
}
|
206
|
-
```
|
207
|
-
|
208
|
-
符号信息格式如下:
|
209
|
-
```
|
210
|
-
{符号类型}: {符号名称}+{符号用途}, {符号名称}+{符号用途}, ...
|
211
|
-
```
|
212
|
-
|
213
|
-
注意:
|
214
|
-
1. 直接输出结果,不要尝试使用任何代码
|
215
|
-
2. file_path 字段使用相对路径
|
216
|
-
3. purpose 字段的长度不能超过50字
|
217
|
-
4. symbols 字段的分隔符为^^
|
218
|
-
5. 请严格按格式要求返回结果
|
219
|
-
"""
|
220
|
-
|
221
|
-
def build_project_index(self, query, env_info, language, information, architecture) -> ProjectFileList:
|
222
|
-
self.llm.setup_default_model_name(self.chat_model)
|
223
|
-
result = self._build_project_index.with_llm(self.llm).with_return_type(ProjectFileList).run(
|
224
|
-
query, env_info, language, information, architecture
|
225
|
-
)
|
226
|
-
return result
|
227
|
-
|
228
|
-
@prompt()
|
229
|
-
def _build_single_code(self, query, env_info, language, information, architecture, fileindex):
|
230
|
-
"""
|
231
|
-
这是我的原始需求: {{ query }}
|
232
|
-
|
233
|
-
环境信息如下:
|
234
|
-
操作系统: {{ env_info.os_name }} {{ env_info.os_version }}
|
235
|
-
编程语言: {{ language }}
|
236
|
-
|
237
|
-
补充后的需求:
|
238
|
-
{{ information }}
|
239
|
-
|
240
|
-
项目结构如下:
|
241
|
-
{{ architecture }}
|
242
|
-
|
243
|
-
我提供了以上诸如 '需求信息','项目结构' 信息。
|
244
|
-
现在需要你基于如下信息生成对应的代码
|
245
|
-
|
246
|
-
路径: {{ fileindex.file_path }}
|
247
|
-
用途: {{ fileindex.purpose }}
|
248
|
-
符号信息: {{ fileindex.symbols }}
|
249
|
-
|
250
|
-
注意:
|
251
|
-
1. 请严格按照语言规范,直接输出代码
|
252
|
-
|
253
|
-
## 输出
|
254
|
-
```
|
255
|
-
import os
|
256
|
-
import time
|
257
|
-
from loguru import logger
|
258
|
-
import byzerllm
|
259
|
-
|
260
|
-
a = ""
|
261
|
-
|
262
|
-
@byzerllm.prompt(render="jinja")
|
263
|
-
def auto_implement_function_template(instruction:str, content:str)->str:
|
264
|
-
pass
|
265
|
-
```
|
266
|
-
"""
|
267
|
-
|
268
|
-
def build_single_code(self, query, env_info, language, information, architecture, fileindex: IndexFilePath):
|
269
|
-
self.llm.setup_default_model_name(self.code_model)
|
270
|
-
try:
|
271
|
-
result = self._build_single_code.with_llm(self.llm).run(
|
272
|
-
query, env_info, language, information, architecture, fileindex
|
273
|
-
)
|
274
|
-
code = extract_code(result.output)[0][1]
|
275
|
-
return code
|
276
|
-
except Exception as err:
|
277
|
-
logger.error(f"编写代码 {fileindex.file_path} 错误: {str(err)}")
|
278
|
-
return None
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|