auto-coder 0.1.315__py3-none-any.whl → 0.1.317__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.
Potentially problematic release.
This version of auto-coder might be problematic. Click here for more details.
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/METADATA +1 -1
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/RECORD +42 -21
- autocoder/auto_coder_runner.py +1 -2
- autocoder/commands/tools.py +30 -19
- autocoder/common/__init__.py +3 -0
- autocoder/common/auto_coder_lang.py +24 -0
- autocoder/common/code_auto_merge_editblock.py +2 -42
- autocoder/common/git_utils.py +2 -2
- autocoder/common/token_cost_caculate.py +103 -42
- autocoder/common/v2/__init__.py +0 -0
- autocoder/common/v2/code_auto_generate.py +199 -0
- autocoder/common/v2/code_auto_generate_diff.py +361 -0
- autocoder/common/v2/code_auto_generate_editblock.py +380 -0
- autocoder/common/v2/code_auto_generate_strict_diff.py +269 -0
- autocoder/common/v2/code_auto_merge.py +211 -0
- autocoder/common/v2/code_auto_merge_diff.py +354 -0
- autocoder/common/v2/code_auto_merge_editblock.py +523 -0
- autocoder/common/v2/code_auto_merge_strict_diff.py +259 -0
- autocoder/common/v2/code_diff_manager.py +266 -0
- autocoder/common/v2/code_editblock_manager.py +275 -0
- autocoder/common/v2/code_manager.py +238 -0
- autocoder/common/v2/code_strict_diff_manager.py +241 -0
- autocoder/dispacher/actions/action.py +16 -0
- autocoder/dispacher/actions/plugins/action_regex_project.py +6 -0
- autocoder/events/event_manager_singleton.py +2 -2
- autocoder/helper/__init__.py +0 -0
- autocoder/helper/project_creator.py +570 -0
- autocoder/linters/linter_factory.py +44 -25
- autocoder/linters/models.py +220 -0
- autocoder/linters/python_linter.py +1 -7
- autocoder/linters/reactjs_linter.py +580 -0
- autocoder/linters/shadow_linter.py +390 -0
- autocoder/linters/vue_linter.py +576 -0
- autocoder/memory/active_context_manager.py +0 -4
- autocoder/memory/active_package.py +12 -12
- autocoder/shadows/__init__.py +0 -0
- autocoder/shadows/shadow_manager.py +235 -0
- autocoder/version.py +1 -1
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.315.dist-info → auto_coder-0.1.317.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ autocoder/auto_coder_lang.py,sha256=Rtupq6N3_HT7JRhDKdgCBcwRaiAnyCOR_Gsp4jUomrI,
|
|
|
4
4
|
autocoder/auto_coder_rag.py,sha256=vOqwBHdK_KwMNUUc8ji_tlZ5DoALAG1rDjWAic3rM-4,34561
|
|
5
5
|
autocoder/auto_coder_rag_client_mcp.py,sha256=QRxUbjc6A8UmDMQ8lXgZkjgqtq3lgKYeatJbDY6rSo0,6270
|
|
6
6
|
autocoder/auto_coder_rag_mcp.py,sha256=-RrjNwFaS2e5v8XDIrKR-zlUNUE8UBaeOtojffBrvJo,8521
|
|
7
|
-
autocoder/auto_coder_runner.py,sha256=
|
|
7
|
+
autocoder/auto_coder_runner.py,sha256=AVbSXL0uBmfY2E7-cw6GyGGz6xCozRlv0yl4laATRLU,107339
|
|
8
8
|
autocoder/auto_coder_server.py,sha256=E3Z829TPSooRSNhuh3_x9yaZi0f5G0Lm0ntoZhjGaoQ,20576
|
|
9
9
|
autocoder/benchmark.py,sha256=Ypomkdzd1T3GE6dRICY3Hj547dZ6_inqJbBJIp5QMco,4423
|
|
10
10
|
autocoder/chat_auto_coder.py,sha256=Cp5_m3pCxEDcRrVG1uojTfD8xecdl9FvYtD948TvLsg,25223
|
|
@@ -14,7 +14,7 @@ autocoder/command_parser.py,sha256=fx1g9E6GaM273lGTcJqaFQ-hoksS_Ik2glBMnVltPCE,1
|
|
|
14
14
|
autocoder/lang.py,sha256=U6AjVV8Rs1uLyjFCZ8sT6WWuNUxMBqkXXIOs4S120uk,14511
|
|
15
15
|
autocoder/models.py,sha256=AyoZ-Pzy0oyYUmWCxOIRiOImsqboSfRET7LO9-UOuxI,11172
|
|
16
16
|
autocoder/run_context.py,sha256=IUfSO6_gp2Wt1blFWAmOpN0b0nDrTTk4LmtCYUBIoro,1643
|
|
17
|
-
autocoder/version.py,sha256=
|
|
17
|
+
autocoder/version.py,sha256=shzvDfXpFrMexWnk8N3KNRFUSRGFCbb2hw1zUBzlVLw,23
|
|
18
18
|
autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
autocoder/agent/auto_demand_organizer.py,sha256=URAq0gSEiHeV_W4zwhOI_83kHz0Ryfj1gcfh5jwCv_w,6501
|
|
20
20
|
autocoder/agent/auto_filegroup.py,sha256=pBsAkBcpFTff-9L5OwI8xhf2xPKpl-aZwz-skF2B6dc,6296
|
|
@@ -30,15 +30,15 @@ autocoder/chat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
30
30
|
autocoder/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
autocoder/commands/auto_command.py,sha256=fZ4TNU4YA9qdoVHmZX0rb6sV_N-DEcgSLaC5s3PGSHA,64200
|
|
32
32
|
autocoder/commands/auto_web.py,sha256=Cc0eb6JN3SvFy3GD_lpSLvIqj7F1eFDTcwg1t-zDcKg,39024
|
|
33
|
-
autocoder/commands/tools.py,sha256=
|
|
33
|
+
autocoder/commands/tools.py,sha256=SlMhPICWjDsloi05CfDMawCtJmbffOCjUNj_-ve-w40,31836
|
|
34
34
|
autocoder/common/JupyterClient.py,sha256=O-wi6pXeAEYhAY24kDa0BINrLYvKS6rKyWe98pDClS0,2816
|
|
35
35
|
autocoder/common/ShellClient.py,sha256=fM1q8t_XMSbLBl2zkCNC2J9xuyKN3eXzGm6hHhqL2WY,2286
|
|
36
|
-
autocoder/common/__init__.py,sha256=
|
|
36
|
+
autocoder/common/__init__.py,sha256=uYI9fXA6ypxWopBeN82MjKiOvT9b-xx0U5wI3AztGQc,14170
|
|
37
37
|
autocoder/common/action_yml_file_manager.py,sha256=-bbTB8nyxgzf_GNa_TCL21TV87b_9ENmDmybZWVrwSA,17371
|
|
38
38
|
autocoder/common/anything2images.py,sha256=0ILBbWzY02M-CiWB-vzuomb_J1hVdxRcenAfIrAXq9M,25283
|
|
39
39
|
autocoder/common/anything2img.py,sha256=iZQmg8srXlD7N5uGl5b_ONKJMBjYoW8kPmokkG6ISF0,10118
|
|
40
40
|
autocoder/common/audio.py,sha256=Kn9nWKQddWnUrAz0a_ZUgjcu4VUU_IcZBigT7n3N3qc,7439
|
|
41
|
-
autocoder/common/auto_coder_lang.py,sha256=
|
|
41
|
+
autocoder/common/auto_coder_lang.py,sha256=4wH_lGZhoj0qA64J14OecsTa3PSRu35BCAlsRssgvYI,37888
|
|
42
42
|
autocoder/common/auto_configure.py,sha256=D4N-fl9v8bKM5-Ds-uhkC2uGDmHH_ZjLJ759F8KXMKs,13129
|
|
43
43
|
autocoder/common/buildin_tokenizer.py,sha256=L7d5t39ZFvUd6EoMPXUhYK1toD0FHlRH1jtjKRGokWU,1236
|
|
44
44
|
autocoder/common/chunk_validation.py,sha256=BrR_ZWavW8IANuueEE7hS8NFAwEvm8TX34WnPx_1hs8,3030
|
|
@@ -50,7 +50,7 @@ autocoder/common/code_auto_generate_editblock.py,sha256=YfXuSYogJ5YoHTsx6LN5pPsk
|
|
|
50
50
|
autocoder/common/code_auto_generate_strict_diff.py,sha256=cKCcDfVADSbkwPMWmHGhRjzKutieEw80NjFjwZbFudw,21990
|
|
51
51
|
autocoder/common/code_auto_merge.py,sha256=WaU-T-ZVn3QDaA_SrdkHciUPKDcTfVa-IbhHKBYEv5w,9961
|
|
52
52
|
autocoder/common/code_auto_merge_diff.py,sha256=DcljWrtlejq2cb9Gj-jBjvUQzRbCE2uMNGg8SBOhEnk,19271
|
|
53
|
-
autocoder/common/code_auto_merge_editblock.py,sha256=
|
|
53
|
+
autocoder/common/code_auto_merge_editblock.py,sha256=SnbWZvLY13A7TK9gERJ8EbkwWVotHwHzwQGJRHNQ0vI,20095
|
|
54
54
|
autocoder/common/code_auto_merge_strict_diff.py,sha256=C35pFxhkgypsm50VDAFOBAT6YXMtzKTvIpEUH1GjZZg,13209
|
|
55
55
|
autocoder/common/code_modification_ranker.py,sha256=Ld3wtjV10zW7lN_L3bKEsvi7RvAleB8r1DD9eLmVnx4,13462
|
|
56
56
|
autocoder/common/command_completer.py,sha256=jBFi8Y1xWmMcxwdDz6Gs7r8ADFPb7eRr9egWU0vLxLo,35787
|
|
@@ -63,7 +63,7 @@ autocoder/common/const.py,sha256=eTjhjh4Aj4CUzviJ81jaf3Y5cwqsLATySn2wJxaS6RQ,291
|
|
|
63
63
|
autocoder/common/context_pruner.py,sha256=HlU5BmxpCX7uVTJUsTFLlXvkwcOQuidI9uCKZaFxh6s,19874
|
|
64
64
|
autocoder/common/conversation_pruner.py,sha256=pzmrQEa7pFzA66eYSS_h7VqP6ZwUABeooDQzm0PGu0A,5770
|
|
65
65
|
autocoder/common/files.py,sha256=nPiKcnUcYZbSUn3TskKeTVnAxCJRtuehPuB_5d2imX8,4618
|
|
66
|
-
autocoder/common/git_utils.py,sha256=
|
|
66
|
+
autocoder/common/git_utils.py,sha256=SU66RwNTBanG4XdX_dVH9z7sFd2XzlOG7ETTOGLaTEo,27077
|
|
67
67
|
autocoder/common/global_cancel.py,sha256=TyjYQPESwo04D1BOTmC9hH7IbkKDDM-b2zPacEHGIQ8,3264
|
|
68
68
|
autocoder/common/image_to_page.py,sha256=yWiTJQ49Lm3j0FngiJhQ9u7qayqE_bOGb8Rk0TmSWx0,14123
|
|
69
69
|
autocoder/common/index_import_export.py,sha256=h758AYY1df6JMTKUXYmMkSgxItfymDt82XT7O-ygEuw,4565
|
|
@@ -86,29 +86,44 @@ autocoder/common/stats_panel.py,sha256=wGl9O45pjVVDxhNumLv4_NfLYSlUP_18Tw4hcJSjw
|
|
|
86
86
|
autocoder/common/stream_out_type.py,sha256=uNHRg-1my6CxcPzQM6pACrYpTZbxOenVT8aLxnruv2w,333
|
|
87
87
|
autocoder/common/sys_prompt.py,sha256=JlexfjZt554faqbgkCmzOJqYUzDHfbnxly5ugFfHfEE,26403
|
|
88
88
|
autocoder/common/text.py,sha256=KGRQq314GHBmY4MWG8ossRoQi1_DTotvhxchpn78c-k,1003
|
|
89
|
-
autocoder/common/token_cost_caculate.py,sha256=
|
|
89
|
+
autocoder/common/token_cost_caculate.py,sha256=MSWJtl7YpQSUt-gFQoqUcJMblyPqHXe2ZioiZOFkV80,10085
|
|
90
90
|
autocoder/common/types.py,sha256=PXTETrsTvhLE49jqAeUKGySvxBN9pjeyCgRHLDYdd9U,664
|
|
91
91
|
autocoder/common/utils_code_auto_generate.py,sha256=Tvb3Mqxedj0Jhi0faKyWvILuNCty9fZi341fyIs33tA,4550
|
|
92
92
|
autocoder/common/mcp_servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
93
93
|
autocoder/common/mcp_servers/mcp_server_gpt4o_mini_search.py,sha256=TApShxgoozLluobXHOK1-oAE1zm0-9jdRoPLQB1qwMI,5688
|
|
94
94
|
autocoder/common/mcp_servers/mcp_server_perplexity.py,sha256=CIC26UkfH1lYoVCjfyY5xGGYVx8h0oz0Uj1c7YJ3OPw,5560
|
|
95
|
+
autocoder/common/v2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
96
|
+
autocoder/common/v2/code_auto_generate.py,sha256=coCVfRHSgH8FM63s2-chj5plGRfJjCrijy4P4289hj4,9163
|
|
97
|
+
autocoder/common/v2/code_auto_generate_diff.py,sha256=TvvpqZQCZJEKqeVs8qqkjiXsRTPzAk9LaWObdmxcA_Y,14445
|
|
98
|
+
autocoder/common/v2/code_auto_generate_editblock.py,sha256=Qh69VnykQbSqapLi-Glwu3R5hznittLxsVnwayl8PoY,14732
|
|
99
|
+
autocoder/common/v2/code_auto_generate_strict_diff.py,sha256=mQgsPugawrP9GYfsVKOTRuSLr0GlmVUKWKABAFZ95JY,8788
|
|
100
|
+
autocoder/common/v2/code_auto_merge.py,sha256=FZHrIZyFUkFmv4EbproXfIIUfGx_L3EPfvjldsYlplI,9345
|
|
101
|
+
autocoder/common/v2/code_auto_merge_diff.py,sha256=xh93G9Gn8zSRhGq6L90tlodFM2u-g5KLlvZ4TPDSlDM,14945
|
|
102
|
+
autocoder/common/v2/code_auto_merge_editblock.py,sha256=FpXdHAuHhtOLXybrUd2e1rDrxqoge-CpUyWpX0yNEv8,22018
|
|
103
|
+
autocoder/common/v2/code_auto_merge_strict_diff.py,sha256=jIIedNZGW52dhSmNxb3vB7UdJZp8tg59Z2gg3sCpqoM,10117
|
|
104
|
+
autocoder/common/v2/code_diff_manager.py,sha256=DEYzR7IhCOHPayh8MnQwizUIyMzpMpE93DXzuewSGT4,10495
|
|
105
|
+
autocoder/common/v2/code_editblock_manager.py,sha256=17UOrdEkYvpER9g9zpgfbxNwBIr3magV8Jazra-Ksq4,10885
|
|
106
|
+
autocoder/common/v2/code_manager.py,sha256=-7wqkCOYXEjJfYcWQrs7i8gz7U4ntBycxzCGX41LnaY,9165
|
|
107
|
+
autocoder/common/v2/code_strict_diff_manager.py,sha256=6vpeAvJsnYDszYtmntPtHVrQQVGqsWwgFTrnboUP1es,9330
|
|
95
108
|
autocoder/data/byzerllm.md,sha256=SGCMpEaUQ0ysPxQsgzyyp5sgvEr8dZsxEGAfVcPBIq0,47741
|
|
96
109
|
autocoder/data/tokenizer.json,sha256=7Lb5_DaYlDRvBRH0B0ynXO5c1fOwbQLxujX805-OEh0,7847602
|
|
97
110
|
autocoder/db/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
98
111
|
autocoder/db/store.py,sha256=tFT66bP2ZKIqZip-uhLkHRSLaaOAUUDZfozJwcqix3c,1908
|
|
99
112
|
autocoder/dispacher/__init__.py,sha256=GTGpU9KbyAu3QMsbecnETYHMoIDBfKKP8iEVsU8gKcg,957
|
|
100
113
|
autocoder/dispacher/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
101
|
-
autocoder/dispacher/actions/action.py,sha256=
|
|
114
|
+
autocoder/dispacher/actions/action.py,sha256=3xBHErBX_RGuWQtMyc1FSWLp3u6ffMasdfjWp4JBcfI,23177
|
|
102
115
|
autocoder/dispacher/actions/copilot.py,sha256=2nQzKt8Sr40mIDOizZWyl4ekCwaHYklvgGlVfvhOlFM,13106
|
|
103
116
|
autocoder/dispacher/actions/plugins/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
104
|
-
autocoder/dispacher/actions/plugins/action_regex_project.py,sha256=
|
|
117
|
+
autocoder/dispacher/actions/plugins/action_regex_project.py,sha256=Vp07ANh0LlHoVPLM9ovTiIKv1gsUuCF57Gje4XiFVDA,8000
|
|
105
118
|
autocoder/dispacher/actions/plugins/action_translate.py,sha256=GEn7dZA22jy5WyzINomjmzzB795p2Olg-CJla97lRF8,7744
|
|
106
119
|
autocoder/events/__init__.py,sha256=1x_juwr9Ows2RADDa2LyI4QlmPxOVOXZeLO1cht-slM,1443
|
|
107
120
|
autocoder/events/event_content.py,sha256=0unVmskGrfvnsniLvNXobco9KG-r6cv_C-gXK3L5zXQ,11557
|
|
108
121
|
autocoder/events/event_manager.py,sha256=WsEog4diXPsidCcN-Ycm18iPbX21PBibkcmjee-aRcQ,11739
|
|
109
|
-
autocoder/events/event_manager_singleton.py,sha256=
|
|
122
|
+
autocoder/events/event_manager_singleton.py,sha256=8aBp97fgbas0KYrpHbljTg2n4RcWd85SOgQITu47ZWA,8809
|
|
110
123
|
autocoder/events/event_store.py,sha256=y6tT3P-o3yhDptrKi-UmqI_ZBNg7v21FriI3f7lo_ME,12709
|
|
111
124
|
autocoder/events/event_types.py,sha256=wONd3wC_BhGXTbXIlb4kFIr7gkhYSBjQE30JjTc8tnU,3558
|
|
125
|
+
autocoder/helper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
126
|
+
autocoder/helper/project_creator.py,sha256=RITjVfZ_Y5zytSHTNYiwxfn2Eqfvf2Ywe13e6g5tY18,17360
|
|
112
127
|
autocoder/index/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
113
128
|
autocoder/index/entry.py,sha256=a8KhkNd6tKuD6W9fh9ohdri2r4UYeZWswi14pVwpr-Q,15740
|
|
114
129
|
autocoder/index/for_command.py,sha256=BFvljE4t6VaMBGboZAuhUCzVK0EitCy_n5D_7FEnihw,3204
|
|
@@ -121,11 +136,15 @@ autocoder/index/filter/quick_filter.py,sha256=ozESEgy506FQ5ecjOumyo4D_KMrterB1QL
|
|
|
121
136
|
autocoder/linters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
122
137
|
autocoder/linters/base_linter.py,sha256=1_0DPESnSyF3ZcQhoFkBYJylT5w-B61Rx-3A9uhuPlg,3066
|
|
123
138
|
autocoder/linters/code_linter.py,sha256=JylTj-Mj4jl9-XSH3PVlbQ4l55Y6E1FG-glv860CGSs,22462
|
|
124
|
-
autocoder/linters/linter_factory.py,sha256=
|
|
125
|
-
autocoder/linters/
|
|
139
|
+
autocoder/linters/linter_factory.py,sha256=rsDzaY0jFnmEsbY8Co_xxpJe9lXgfs07Nnrht8_WWtY,10273
|
|
140
|
+
autocoder/linters/models.py,sha256=GBdayu_p50KBxoRms4X68zrDK-OsKDEKKjo926FevwE,9838
|
|
141
|
+
autocoder/linters/python_linter.py,sha256=eEszTQwYHYLfi6JLqHW7kBIdlJOdyA9-yErbBNyaMgU,22393
|
|
142
|
+
autocoder/linters/reactjs_linter.py,sha256=HUDm6oNwlJ7V8l22mj_2nfZUx23m5W7-v2tgWHN2-PM,21171
|
|
143
|
+
autocoder/linters/shadow_linter.py,sha256=LIbv21g9DJ_gK4fAV-zSaCQdVgSoASFGmWaydokNsEg,14810
|
|
144
|
+
autocoder/linters/vue_linter.py,sha256=ZyvoxT0kSizFh_UkR7UZYO5DV9edbvDQZaibEF9W95I,20905
|
|
126
145
|
autocoder/memory/__init__.py,sha256=5FeGvsesRViYL4BkFiHw9SdlyHeWlqALpTyqOpfnBRw,179
|
|
127
|
-
autocoder/memory/active_context_manager.py,sha256=
|
|
128
|
-
autocoder/memory/active_package.py,sha256=
|
|
146
|
+
autocoder/memory/active_context_manager.py,sha256=HFNdXoFaQn8XhgxzIEgTFbzFw_caKfbBQud9OruJQbU,33177
|
|
147
|
+
autocoder/memory/active_package.py,sha256=DKJgiL470iq_OsSZfi9C-_C7RbaCBOtdEIudIkkUsdQ,25456
|
|
129
148
|
autocoder/memory/async_processor.py,sha256=htHzLGupw9IHQAEdLe2AEaALZSItPi3AltDt8FMTRHk,4643
|
|
130
149
|
autocoder/memory/directory_mapper.py,sha256=BXHblOdRpeZb7URDECALp9uN5oi91KmkW9g_UaWFuZY,2513
|
|
131
150
|
autocoder/plugins/__init__.py,sha256=uc8UNSAVb9uQvr5zUSS-Xu_RhrdbO2i3w2NhkrVtODM,43023
|
|
@@ -179,6 +198,8 @@ autocoder/rag/stream_event/event_writer.py,sha256=l7kq_LnDDE8E5dZ-73C7J2MgzSL7Wr
|
|
|
179
198
|
autocoder/rag/stream_event/types.py,sha256=rtLwOE8rShmi1dJdxyBpAV5ZjLBGG9vptMiSzMxGuIA,318
|
|
180
199
|
autocoder/regex_project/__init__.py,sha256=EBZeCL5ORyD_9_5u_UuG4s7XtpXOu0y1sWDmxWFtufE,6781
|
|
181
200
|
autocoder/regexproject/__init__.py,sha256=OGlfVe2yulGIZstACbVePVbNXajvVLRFyubnIc-9Gw0,9758
|
|
201
|
+
autocoder/shadows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
202
|
+
autocoder/shadows/shadow_manager.py,sha256=AMZg4Cv8Ut0KJdAEw8CbIm7neiDFPnogYQXziLwXvcs,7548
|
|
182
203
|
autocoder/suffixproject/__init__.py,sha256=EOb8eUqfu3ka8mrggkXUfwX3SWnxqEoiYmDF7Zkf0F8,11143
|
|
183
204
|
autocoder/tsproject/__init__.py,sha256=LPehIUgzFbZ5DT_Pc0a_xCQQXEDxACPTMwXfFF7rcL0,11836
|
|
184
205
|
autocoder/utils/__init__.py,sha256=W47ac6IOZhNR1rdbho9fvhHnPI_N1i4oMcZOwxLelbU,1123
|
|
@@ -205,9 +226,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
205
226
|
autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
206
227
|
autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=xuBeWD0YOckqRo8JB1WkVIMOYH6c24m7JfV4svBfPDo,15113
|
|
207
228
|
autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
208
|
-
auto_coder-0.1.
|
|
209
|
-
auto_coder-0.1.
|
|
210
|
-
auto_coder-0.1.
|
|
211
|
-
auto_coder-0.1.
|
|
212
|
-
auto_coder-0.1.
|
|
213
|
-
auto_coder-0.1.
|
|
229
|
+
auto_coder-0.1.317.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
230
|
+
auto_coder-0.1.317.dist-info/METADATA,sha256=LlnaYkCNF6NYqqH8kZcX_DV9Az57hmOFn1JD_C1wRAo,2747
|
|
231
|
+
auto_coder-0.1.317.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
232
|
+
auto_coder-0.1.317.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
|
|
233
|
+
auto_coder-0.1.317.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
|
|
234
|
+
auto_coder-0.1.317.dist-info/RECORD,,
|
autocoder/auto_coder_runner.py
CHANGED
|
@@ -1438,8 +1438,7 @@ def commit(query: str):
|
|
|
1438
1438
|
|
|
1439
1439
|
action_yml_file_manager = ActionYmlFileManager(args.source_dir)
|
|
1440
1440
|
action_file_name = os.path.basename(args.file)
|
|
1441
|
-
add_updated_urls = []
|
|
1442
|
-
commit_result.changed_files
|
|
1441
|
+
add_updated_urls = []
|
|
1443
1442
|
for file in commit_result.changed_files:
|
|
1444
1443
|
add_updated_urls.append(os.path.join(args.source_dir, file))
|
|
1445
1444
|
|
autocoder/commands/tools.py
CHANGED
|
@@ -164,7 +164,7 @@ class AutoCommandTools:
|
|
|
164
164
|
# 如果是在web模式下,则使用event_manager事件来询问用户
|
|
165
165
|
if get_run_context().is_web():
|
|
166
166
|
try:
|
|
167
|
-
|
|
167
|
+
get_event_manager(
|
|
168
168
|
self.args.event_file).write_result(
|
|
169
169
|
EventContentCreator.create_result(
|
|
170
170
|
EventContentCreator.ResultSummaryContent(
|
|
@@ -178,15 +178,15 @@ class AutoCommandTools:
|
|
|
178
178
|
"response": response
|
|
179
179
|
}
|
|
180
180
|
})
|
|
181
|
-
except Exception as e:
|
|
182
|
-
error_message = f"Error: {str(e)}\n\n完整异常堆栈信息:\n{traceback.format_exc()}"
|
|
181
|
+
except Exception as e:
|
|
182
|
+
error_message = f"Error: {str(e)}\n\n完整异常堆栈信息:\n{traceback.format_exc()}"
|
|
183
183
|
self.result_manager.append(content=f"Error: {error_message}", meta={
|
|
184
184
|
"action": "response_user",
|
|
185
185
|
"input": {
|
|
186
186
|
"response": response
|
|
187
187
|
}
|
|
188
188
|
})
|
|
189
|
-
return
|
|
189
|
+
return response
|
|
190
190
|
|
|
191
191
|
console = Console()
|
|
192
192
|
answer_text = Text(response, style="italic")
|
|
@@ -331,9 +331,19 @@ class AutoCommandTools:
|
|
|
331
331
|
注意,这个工具无法返回所有文件的信息,因为有些文件可能没有被索引。
|
|
332
332
|
尽量避免使用该工具。
|
|
333
333
|
"""
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
334
|
+
try:
|
|
335
|
+
index_manager = self._get_index()
|
|
336
|
+
s = index_manager.read_index_as_str()
|
|
337
|
+
index_data = json.loads(s)
|
|
338
|
+
except Exception as e:
|
|
339
|
+
v = f"Error: {str(e)}\n\n完整异常堆栈信息:\n{traceback.format_exc()}"
|
|
340
|
+
self.result_manager.add_result(content=v, meta={
|
|
341
|
+
"action": "get_project_map",
|
|
342
|
+
"input": {
|
|
343
|
+
"file_paths": file_paths
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
return v
|
|
337
347
|
|
|
338
348
|
final_result = []
|
|
339
349
|
|
|
@@ -778,21 +788,21 @@ class AutoCommandTools:
|
|
|
778
788
|
def lint_code(self, path: str, language: Optional[str] = None, fix: bool = False, verbose: bool = False) -> str:
|
|
779
789
|
"""
|
|
780
790
|
对代码进行质量检查,支持多种编程语言。
|
|
781
|
-
|
|
791
|
+
|
|
782
792
|
参数说明:
|
|
783
793
|
path (str): 要检查的文件路径或项目目录
|
|
784
794
|
language (str, optional): 明确指定语言类型,如'python', 'javascript', 'typescript', 'react', 'vue'等
|
|
785
795
|
如果不指定,将尝试根据文件扩展名或项目结构自动检测
|
|
786
796
|
fix (bool): 是否自动修复可修复的问题,默认为False
|
|
787
797
|
verbose (bool): 是否显示详细输出,默认为False
|
|
788
|
-
|
|
798
|
+
|
|
789
799
|
返回值:
|
|
790
800
|
格式化后的lint结果,包含错误和警告信息
|
|
791
|
-
|
|
801
|
+
|
|
792
802
|
支持的语言:
|
|
793
803
|
- 前端: JavaScript, TypeScript, React, Vue (使用ESLint)
|
|
794
804
|
- Python: 使用pylint, flake8, black
|
|
795
|
-
|
|
805
|
+
|
|
796
806
|
说明:
|
|
797
807
|
- 对于前端代码,需要Node.js环境
|
|
798
808
|
- 对于Python代码,需要pylint/flake8/black
|
|
@@ -804,18 +814,19 @@ class AutoCommandTools:
|
|
|
804
814
|
try:
|
|
805
815
|
# 检查是否是目录或文件
|
|
806
816
|
is_directory = os.path.isdir(path)
|
|
807
|
-
|
|
817
|
+
|
|
808
818
|
# 根据路径类型执行相应的lint操作
|
|
809
819
|
if is_directory:
|
|
810
820
|
# 对整个项目进行lint
|
|
811
|
-
result = lint_project(
|
|
821
|
+
result = lint_project(
|
|
822
|
+
path, language=language, fix=fix, verbose=verbose)
|
|
812
823
|
else:
|
|
813
824
|
# 对单个文件进行lint
|
|
814
825
|
result = lint_file(path, fix=fix, verbose=verbose)
|
|
815
|
-
|
|
826
|
+
|
|
816
827
|
# 格式化结果
|
|
817
828
|
formatted_result = format_lint_result(result, language=language)
|
|
818
|
-
|
|
829
|
+
|
|
819
830
|
# 记录操作结果
|
|
820
831
|
self.result_manager.add_result(content=formatted_result, meta={
|
|
821
832
|
"action": "lint_code",
|
|
@@ -827,12 +838,12 @@ class AutoCommandTools:
|
|
|
827
838
|
},
|
|
828
839
|
"result": result
|
|
829
840
|
})
|
|
830
|
-
|
|
841
|
+
|
|
831
842
|
return formatted_result
|
|
832
|
-
|
|
843
|
+
|
|
833
844
|
except Exception as e:
|
|
834
845
|
error_message = f"Linting failed: {str(e)}\n\n完整异常堆栈信息:\n{traceback.format_exc()}"
|
|
835
|
-
|
|
846
|
+
|
|
836
847
|
self.result_manager.add_result(content=error_message, meta={
|
|
837
848
|
"action": "lint_code",
|
|
838
849
|
"input": {
|
|
@@ -843,5 +854,5 @@ class AutoCommandTools:
|
|
|
843
854
|
},
|
|
844
855
|
"error": error_message
|
|
845
856
|
})
|
|
846
|
-
|
|
857
|
+
|
|
847
858
|
return error_message
|
autocoder/common/__init__.py
CHANGED
|
@@ -733,6 +733,30 @@ MESSAGES = {
|
|
|
733
733
|
"code_generate_title": {
|
|
734
734
|
"en": "{{model_name}} is generating code",
|
|
735
735
|
"zh": "{{model_name}}正在生成代码"
|
|
736
|
+
},
|
|
737
|
+
"generating_initial_code": {
|
|
738
|
+
"en": "Generating initial code...",
|
|
739
|
+
"zh": "正在生成初始代码..."
|
|
740
|
+
},
|
|
741
|
+
"generation_failed": {
|
|
742
|
+
"en": "Code generation failed",
|
|
743
|
+
"zh": "代码生成失败"
|
|
744
|
+
},
|
|
745
|
+
"no_files_to_lint": {
|
|
746
|
+
"en": "No files to lint",
|
|
747
|
+
"zh": "没有需要检查的文件"
|
|
748
|
+
},
|
|
749
|
+
"no_lint_errors_found": {
|
|
750
|
+
"en": "No lint errors found",
|
|
751
|
+
"zh": "未发现代码质量问题"
|
|
752
|
+
},
|
|
753
|
+
"lint_attempt_status": {
|
|
754
|
+
"en": "Lint attempt {{attempt}}/{{max_correction_attempts}}: {{error_count}} errors found. {{ formatted_issues }}",
|
|
755
|
+
"zh": "代码质量检查尝试 {{attempt}}/{{max_correction_attempts}}: 发现 {{error_count}} 个错误. {{ formatted_issues }}"
|
|
756
|
+
},
|
|
757
|
+
"max_attempts_reached": {
|
|
758
|
+
"en": "Maximum correction attempts reached",
|
|
759
|
+
"zh": "已达到最大修复尝试次数"
|
|
736
760
|
}
|
|
737
761
|
}
|
|
738
762
|
|
|
@@ -43,38 +43,7 @@ class CodeAutoMergeEditBlock:
|
|
|
43
43
|
self.fence_0 = fence_0
|
|
44
44
|
self.fence_1 = fence_1
|
|
45
45
|
self.printer = Printer()
|
|
46
|
-
|
|
47
|
-
def run_pylint(self, code: str) -> tuple[bool, str]:
|
|
48
|
-
with tempfile.NamedTemporaryFile(
|
|
49
|
-
mode="w", suffix=".py", delete=False
|
|
50
|
-
) as temp_file:
|
|
51
|
-
temp_file.write(code)
|
|
52
|
-
temp_file_path = temp_file.name
|
|
53
|
-
|
|
54
|
-
try:
|
|
55
|
-
result = subprocess.run(
|
|
56
|
-
[
|
|
57
|
-
"pylint",
|
|
58
|
-
"--disable=all",
|
|
59
|
-
"--enable=E0001,W0311,W0312",
|
|
60
|
-
temp_file_path,
|
|
61
|
-
],
|
|
62
|
-
capture_output=True,
|
|
63
|
-
text=True,
|
|
64
|
-
check=False,
|
|
65
|
-
)
|
|
66
|
-
os.unlink(temp_file_path)
|
|
67
|
-
if result.returncode != 0:
|
|
68
|
-
error_message = result.stdout.strip() or result.stderr.strip()
|
|
69
|
-
self.printer.print_in_terminal("pylint_check_failed", error_message=error_message)
|
|
70
|
-
return False, error_message
|
|
71
|
-
return True, ""
|
|
72
|
-
except subprocess.CalledProcessError as e:
|
|
73
|
-
error_message = f"Error running pylint: {str(e)}"
|
|
74
|
-
self.printer.print_in_terminal("pylint_error", error_message=error_message)
|
|
75
|
-
os.unlink(temp_file_path)
|
|
76
|
-
return False, error_message
|
|
77
|
-
|
|
46
|
+
|
|
78
47
|
def parse_whole_text(self, text: str) -> List[PathAndCode]:
|
|
79
48
|
'''
|
|
80
49
|
从文本中抽取如下格式代码(two_line_mode):
|
|
@@ -373,16 +342,7 @@ class CodeAutoMergeEditBlock:
|
|
|
373
342
|
self.printer.print_in_terminal("unmerged_blocks_warning", num_blocks=len(unmerged_blocks))
|
|
374
343
|
self._print_unmerged_blocks(unmerged_blocks)
|
|
375
344
|
return
|
|
376
|
-
|
|
377
|
-
# lint check
|
|
378
|
-
for file_path, new_content in file_content_mapping.items():
|
|
379
|
-
if file_path.endswith(".py"):
|
|
380
|
-
pylint_passed, error_message = self.run_pylint(new_content)
|
|
381
|
-
if not pylint_passed:
|
|
382
|
-
self.printer.print_in_terminal("pylint_file_check_failed",
|
|
383
|
-
file_path=file_path,
|
|
384
|
-
error_message=error_message)
|
|
385
|
-
|
|
345
|
+
|
|
386
346
|
if changes_made and not force_skip_git and not self.args.skip_commit:
|
|
387
347
|
try:
|
|
388
348
|
git_utils.commit_changes(
|
autocoder/common/git_utils.py
CHANGED
|
@@ -26,8 +26,8 @@ class CommitResult(BaseModel):
|
|
|
26
26
|
success: bool
|
|
27
27
|
commit_message: Optional[str] = None
|
|
28
28
|
commit_hash: Optional[str] = None
|
|
29
|
-
changed_files: Optional[List[str]] =
|
|
30
|
-
diffs: Optional[dict] =
|
|
29
|
+
changed_files: Optional[List[str]] = []
|
|
30
|
+
diffs: Optional[dict] = {}
|
|
31
31
|
error_message: Optional[str] = None
|
|
32
32
|
|
|
33
33
|
|
|
@@ -3,10 +3,14 @@ import time
|
|
|
3
3
|
from loguru import logger
|
|
4
4
|
import byzerllm
|
|
5
5
|
from byzerllm import MetaHolder
|
|
6
|
+
from autocoder.common.types import CodeGenerateResult
|
|
7
|
+
from autocoder.events.event_types import EventMetadata
|
|
6
8
|
from autocoder.utils import llms
|
|
7
9
|
from autocoder.events.event_manager_singleton import get_event_manager
|
|
8
10
|
from autocoder.events import event_content as EventContentCreator
|
|
9
11
|
from pydantic import BaseModel, Field
|
|
12
|
+
from autocoder.common import AutoCoderArgs
|
|
13
|
+
from autocoder.common.printer import Printer
|
|
10
14
|
|
|
11
15
|
|
|
12
16
|
class TokenUsageStats(BaseModel):
|
|
@@ -15,12 +19,12 @@ class TokenUsageStats(BaseModel):
|
|
|
15
19
|
output_tokens: int = Field(default=0, description="输出的token数量")
|
|
16
20
|
input_cost: float = Field(default=0.0, description="输入token的成本")
|
|
17
21
|
output_cost: float = Field(default=0.0, description="输出token的成本")
|
|
18
|
-
|
|
22
|
+
|
|
19
23
|
@property
|
|
20
24
|
def total_tokens(self) -> int:
|
|
21
25
|
"""总token数"""
|
|
22
26
|
return self.input_tokens + self.output_tokens
|
|
23
|
-
|
|
27
|
+
|
|
24
28
|
@property
|
|
25
29
|
def total_cost(self) -> float:
|
|
26
30
|
"""总成本"""
|
|
@@ -32,7 +36,7 @@ class TokenCostCalculator:
|
|
|
32
36
|
Token计费计算器 - 提供获取模型信息、计算token成本和记录token统计信息的公共功能
|
|
33
37
|
"""
|
|
34
38
|
|
|
35
|
-
def __init__(self, logger_name: str = "TokenCostCalculator"):
|
|
39
|
+
def __init__(self, logger_name: str = "TokenCostCalculator",args:Optional[AutoCoderArgs]=None):
|
|
36
40
|
"""
|
|
37
41
|
初始化Token计费计算器
|
|
38
42
|
|
|
@@ -40,8 +44,10 @@ class TokenCostCalculator:
|
|
|
40
44
|
logger_name: logger名称,默认为TokenCostCalculator
|
|
41
45
|
"""
|
|
42
46
|
self.logger = logger.bind(name=logger_name)
|
|
47
|
+
self.args = args
|
|
48
|
+
self.printer = Printer()
|
|
43
49
|
|
|
44
|
-
def get_model_info(self, llm: byzerllm.ByzerLLM,product_mode:str="lite") -> Tuple[str, Dict[str, Dict[str, float]]]:
|
|
50
|
+
def get_model_info(self, llm: byzerllm.ByzerLLM, product_mode: str = "lite") -> Tuple[str, Dict[str, Dict[str, float]]]:
|
|
45
51
|
"""
|
|
46
52
|
获取模型名称和价格信息
|
|
47
53
|
|
|
@@ -67,6 +73,15 @@ class TokenCostCalculator:
|
|
|
67
73
|
|
|
68
74
|
return model_name, model_info_map
|
|
69
75
|
|
|
76
|
+
def calculate_token_costs_by_generate(self, generate: CodeGenerateResult) -> TokenUsageStats:
|
|
77
|
+
stats = TokenUsageStats()
|
|
78
|
+
stats.input_tokens = generate.metadata.get("input_tokens_count", 0)
|
|
79
|
+
stats.output_tokens = generate.metadata.get(
|
|
80
|
+
"generated_tokens_count", 0)
|
|
81
|
+
stats.input_cost = generate.metadata.get("input_tokens_cost", 0)
|
|
82
|
+
stats.output_cost = generate.metadata.get("generated_tokens_cost", 0)
|
|
83
|
+
return stats
|
|
84
|
+
|
|
70
85
|
def calculate_token_costs(self, meta_holder: MetaHolder,
|
|
71
86
|
model_info_map: Dict[str, Dict[str, float]]) -> TokenUsageStats:
|
|
72
87
|
"""
|
|
@@ -93,7 +108,7 @@ class TokenCostCalculator:
|
|
|
93
108
|
info.get("output_price", 0.0)) / 1000000
|
|
94
109
|
|
|
95
110
|
return stats
|
|
96
|
-
|
|
111
|
+
|
|
97
112
|
def log_event(self,
|
|
98
113
|
model_name: str,
|
|
99
114
|
operation_name: str,
|
|
@@ -101,6 +116,41 @@ class TokenCostCalculator:
|
|
|
101
116
|
end_time: float,
|
|
102
117
|
stats: TokenUsageStats,
|
|
103
118
|
event_file: Optional[str] = None):
|
|
119
|
+
elapsed_time = end_time - start_time
|
|
120
|
+
|
|
121
|
+
# 计算token生成速度(每秒生成的token数)
|
|
122
|
+
speed = stats.output_tokens / elapsed_time if elapsed_time > 0 else 0
|
|
123
|
+
|
|
124
|
+
# 记录日志
|
|
125
|
+
self.logger.info(f"{operation_name} Stats - Model: {model_name}, "
|
|
126
|
+
f"Input Tokens: {stats.input_tokens}, "
|
|
127
|
+
f"Output Tokens: {stats.output_tokens}, "
|
|
128
|
+
f"Total Tokens: {stats.total_tokens}, "
|
|
129
|
+
f"Time: {elapsed_time:.2f}s, "
|
|
130
|
+
f"Speed: {speed:.2f}tokens/s, "
|
|
131
|
+
f"Total Cost: ${stats.total_cost:.6f}")
|
|
132
|
+
|
|
133
|
+
get_event_manager(event_file).write_result(
|
|
134
|
+
EventContentCreator.create_result(content=EventContentCreator.ResultTokenStatContent(
|
|
135
|
+
model_name=model_name,
|
|
136
|
+
elapsed_time=elapsed_time,
|
|
137
|
+
first_token_time=0, # 不跟踪首个token时间
|
|
138
|
+
input_tokens=stats.input_tokens,
|
|
139
|
+
output_tokens=stats.output_tokens,
|
|
140
|
+
input_cost=stats.input_cost,
|
|
141
|
+
output_cost=stats.output_cost,
|
|
142
|
+
speed=speed
|
|
143
|
+
).to_dict()))
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def log_event_by_generate(self,
|
|
147
|
+
model_name: str,
|
|
148
|
+
operation_name: str,
|
|
149
|
+
start_time: float,
|
|
150
|
+
end_time: float,
|
|
151
|
+
stats: TokenUsageStats,
|
|
152
|
+
event_file: Optional[str] = None,
|
|
153
|
+
sampling_count: int = 1):
|
|
104
154
|
"""
|
|
105
155
|
记录token统计信息到日志和事件系统
|
|
106
156
|
|
|
@@ -117,43 +167,53 @@ class TokenCostCalculator:
|
|
|
117
167
|
# 计算token生成速度(每秒生成的token数)
|
|
118
168
|
speed = stats.output_tokens / elapsed_time if elapsed_time > 0 else 0
|
|
119
169
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
170
|
+
self.printer.print_in_terminal(
|
|
171
|
+
operation_name,
|
|
172
|
+
duration=elapsed_time,
|
|
173
|
+
input_tokens=stats.input_tokens,
|
|
174
|
+
output_tokens=stats.output_tokens,
|
|
175
|
+
input_cost=stats.input_cost,
|
|
176
|
+
output_cost=stats.output_cost,
|
|
177
|
+
speed=round(speed, 2),
|
|
178
|
+
model_names=model_name,
|
|
179
|
+
sampling_count=sampling_count
|
|
180
|
+
)
|
|
128
181
|
|
|
129
182
|
# 记录事件(如果提供了event_file)
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
183
|
+
get_event_manager(self.args.event_file).write_result(
|
|
184
|
+
EventContentCreator.create_result(content=EventContentCreator.ResultTokenStatContent(
|
|
185
|
+
model_name=model_name,
|
|
186
|
+
elapsed_time=elapsed_time,
|
|
187
|
+
input_tokens=stats.input_tokens,
|
|
188
|
+
output_tokens=stats.output_tokens,
|
|
189
|
+
input_cost=stats.input_cost,
|
|
190
|
+
output_cost=stats.output_cost,
|
|
191
|
+
speed=round(speed, 2)
|
|
192
|
+
)).to_dict(), metadata=EventMetadata(
|
|
193
|
+
action_file=self.args.file
|
|
194
|
+
).to_dict())
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def track_token_usage_by_generate(self,
|
|
198
|
+
llm: byzerllm.ByzerLLM,
|
|
199
|
+
generate: CodeGenerateResult,
|
|
200
|
+
operation_name: str,
|
|
201
|
+
start_time: float,
|
|
202
|
+
end_time: float,
|
|
203
|
+
product_mode: Optional[str] = None,
|
|
204
|
+
event_file: Optional[str] = None) -> TokenUsageStats:
|
|
205
|
+
model_name, model_info_map = self.get_model_info(llm, product_mode)
|
|
206
|
+
stats = self.calculate_token_costs_by_generate(generate)
|
|
207
|
+
|
|
208
|
+
self.log_event_by_generate(
|
|
209
|
+
model_name=model_name,
|
|
210
|
+
operation_name=operation_name,
|
|
211
|
+
start_time=start_time,
|
|
212
|
+
end_time=end_time,
|
|
213
|
+
stats=stats,
|
|
214
|
+
event_file=event_file,
|
|
215
|
+
sampling_count=len(generate.contents)
|
|
216
|
+
)
|
|
157
217
|
|
|
158
218
|
def track_token_usage(self,
|
|
159
219
|
llm: byzerllm.ByzerLLM,
|
|
@@ -180,9 +240,10 @@ class TokenCostCalculator:
|
|
|
180
240
|
"""
|
|
181
241
|
# 使用传入的product_mode或实例的product_mode
|
|
182
242
|
actual_product_mode = product_mode
|
|
183
|
-
|
|
243
|
+
|
|
184
244
|
# 获取模型信息
|
|
185
|
-
model_name, model_info_map = self.get_model_info(
|
|
245
|
+
model_name, model_info_map = self.get_model_info(
|
|
246
|
+
llm, actual_product_mode)
|
|
186
247
|
|
|
187
248
|
# 计算token统计和成本
|
|
188
249
|
stats = self.calculate_token_costs(meta_holder, model_info_map)
|
|
File without changes
|