auto-coder 0.1.353__py3-none-any.whl → 0.1.355__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.353.dist-info → auto_coder-0.1.355.dist-info}/METADATA +1 -1
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/RECORD +60 -45
- autocoder/agent/agentic_filter.py +1 -1
- autocoder/auto_coder.py +8 -0
- autocoder/auto_coder_rag.py +37 -1
- autocoder/auto_coder_runner.py +58 -77
- autocoder/chat/conf_command.py +270 -0
- autocoder/chat/models_command.py +485 -0
- autocoder/chat_auto_coder.py +29 -24
- autocoder/chat_auto_coder_lang.py +26 -2
- autocoder/commands/auto_command.py +60 -132
- autocoder/commands/auto_web.py +1 -1
- autocoder/commands/tools.py +1 -1
- autocoder/common/__init__.py +3 -1
- autocoder/common/command_completer.py +58 -12
- autocoder/common/command_completer_v2.py +576 -0
- autocoder/common/conversations/__init__.py +52 -0
- autocoder/common/conversations/compatibility.py +303 -0
- autocoder/common/conversations/conversation_manager.py +502 -0
- autocoder/common/conversations/example.py +152 -0
- autocoder/common/file_monitor/__init__.py +5 -0
- autocoder/common/file_monitor/monitor.py +383 -0
- autocoder/common/global_cancel.py +53 -16
- autocoder/common/ignorefiles/__init__.py +4 -0
- autocoder/common/ignorefiles/ignore_file_utils.py +103 -0
- autocoder/common/ignorefiles/test_ignore_file_utils.py +91 -0
- autocoder/common/rulefiles/__init__.py +15 -0
- autocoder/common/rulefiles/autocoderrules_utils.py +173 -0
- autocoder/common/save_formatted_log.py +54 -0
- autocoder/common/v2/agent/agentic_edit.py +10 -39
- autocoder/common/v2/agent/agentic_edit_tools/list_files_tool_resolver.py +1 -1
- autocoder/common/v2/agent/agentic_edit_tools/search_files_tool_resolver.py +73 -43
- autocoder/common/v2/code_agentic_editblock_manager.py +9 -9
- autocoder/common/v2/code_diff_manager.py +2 -2
- autocoder/common/v2/code_editblock_manager.py +31 -18
- autocoder/common/v2/code_strict_diff_manager.py +3 -2
- autocoder/dispacher/actions/action.py +6 -6
- autocoder/dispacher/actions/plugins/action_regex_project.py +2 -2
- autocoder/events/event_manager_singleton.py +1 -1
- autocoder/index/index.py +3 -3
- autocoder/models.py +22 -9
- autocoder/rag/api_server.py +14 -2
- autocoder/rag/cache/local_byzer_storage_cache.py +1 -1
- autocoder/rag/cache/local_duckdb_storage_cache.py +8 -0
- autocoder/rag/cache/simple_cache.py +63 -33
- autocoder/rag/loaders/docx_loader.py +1 -1
- autocoder/rag/loaders/filter_utils.py +133 -76
- autocoder/rag/loaders/image_loader.py +15 -3
- autocoder/rag/loaders/pdf_loader.py +2 -2
- autocoder/rag/long_context_rag.py +11 -0
- autocoder/rag/qa_conversation_strategy.py +5 -31
- autocoder/rag/utils.py +21 -2
- autocoder/utils/_markitdown.py +66 -25
- autocoder/utils/auto_coder_utils/chat_stream_out.py +4 -4
- autocoder/utils/thread_utils.py +9 -27
- autocoder/version.py +1 -1
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.353.dist-info → auto_coder-0.1.355.dist-info}/top_level.txt +0 -0
|
@@ -347,7 +347,7 @@ class CodeEditBlockManager:
|
|
|
347
347
|
|
|
348
348
|
# 计算这次修复缺失上下文花费的token情况
|
|
349
349
|
token_cost_calculator.track_token_usage_by_generate(
|
|
350
|
-
llm=self.
|
|
350
|
+
llm=self.code_generator.llms[0],
|
|
351
351
|
generate=generation_result,
|
|
352
352
|
operation_name="code_generation_complete",
|
|
353
353
|
start_time=start_time,
|
|
@@ -433,7 +433,7 @@ class CodeEditBlockManager:
|
|
|
433
433
|
return (unmerged_formatted_text, merged_formatted_text)
|
|
434
434
|
|
|
435
435
|
for attempt in range(self.args.auto_fix_merge_max_attempts):
|
|
436
|
-
global_cancel.check_and_raise()
|
|
436
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
437
437
|
unmerged_formatted_text, merged_formatted_text = _format_blocks(
|
|
438
438
|
merge)
|
|
439
439
|
fix_prompt = self.fix_unmerged_blocks.prompt(
|
|
@@ -470,7 +470,7 @@ class CodeEditBlockManager:
|
|
|
470
470
|
|
|
471
471
|
# 计算这次修复未合并块花费的token情况
|
|
472
472
|
token_cost_calculator.track_token_usage_by_generate(
|
|
473
|
-
llm=self.
|
|
473
|
+
llm=self.code_generator.llms[0],
|
|
474
474
|
generate=generation_result,
|
|
475
475
|
operation_name="code_generation_complete",
|
|
476
476
|
start_time=start_time,
|
|
@@ -544,7 +544,7 @@ class CodeEditBlockManager:
|
|
|
544
544
|
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
545
545
|
|
|
546
546
|
for attempt in range(self.auto_fix_lint_max_attempts):
|
|
547
|
-
global_cancel.check_and_raise()
|
|
547
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
548
548
|
# 代码生成结果更新到影子文件里去
|
|
549
549
|
self.shadow_manager.clean_shadows()
|
|
550
550
|
shadow_files = self._create_shadow_files_from_edits(
|
|
@@ -611,7 +611,7 @@ class CodeEditBlockManager:
|
|
|
611
611
|
|
|
612
612
|
# 计算这次修复lint问题花费的token情况
|
|
613
613
|
token_cost_calculator.track_token_usage_by_generate(
|
|
614
|
-
llm=self.
|
|
614
|
+
llm=self.code_generator.llms[0],
|
|
615
615
|
generate=generation_result,
|
|
616
616
|
operation_name="code_generation_complete",
|
|
617
617
|
start_time=start_time,
|
|
@@ -657,7 +657,7 @@ class CodeEditBlockManager:
|
|
|
657
657
|
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
658
658
|
|
|
659
659
|
for attempt in range(self.auto_fix_compile_max_attempts):
|
|
660
|
-
global_cancel.check_and_raise()
|
|
660
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
661
661
|
# 先更新增量影子系统的文件
|
|
662
662
|
self.shadow_manager.clean_shadows()
|
|
663
663
|
shadow_files = self._create_shadow_files_from_edits(
|
|
@@ -710,7 +710,7 @@ class CodeEditBlockManager:
|
|
|
710
710
|
|
|
711
711
|
# 计算这次修复compile问题花费的token情况
|
|
712
712
|
token_cost_calculator.track_token_usage_by_generate(
|
|
713
|
-
llm=self.
|
|
713
|
+
llm=self.code_generator.llms[0],
|
|
714
714
|
generate=generation_result,
|
|
715
715
|
operation_name="code_generation_complete",
|
|
716
716
|
start_time=start_time,
|
|
@@ -749,7 +749,7 @@ class CodeEditBlockManager:
|
|
|
749
749
|
|
|
750
750
|
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
751
751
|
token_cost_calculator.track_token_usage_by_generate(
|
|
752
|
-
llm=self.
|
|
752
|
+
llm=self.code_generator.llms[0],
|
|
753
753
|
generate=generation_result,
|
|
754
754
|
operation_name="code_generation_complete",
|
|
755
755
|
start_time=start_time,
|
|
@@ -804,7 +804,7 @@ class CodeEditBlockManager:
|
|
|
804
804
|
# 生成代码并自动修复lint错误
|
|
805
805
|
|
|
806
806
|
generation_result = self.generate_and_fix(query, source_code_list)
|
|
807
|
-
global_cancel.check_and_raise()
|
|
807
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
808
808
|
|
|
809
809
|
# 合并代码
|
|
810
810
|
self.code_merger.merge_code(generation_result)
|
|
@@ -251,7 +251,7 @@ class CodeDiffManager:
|
|
|
251
251
|
|
|
252
252
|
# 最多尝试修复5次
|
|
253
253
|
for attempt in range(self.max_correction_attempts):
|
|
254
|
-
global_cancel.check_and_raise()
|
|
254
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
255
255
|
# 代码生成结果更新到影子文件里去
|
|
256
256
|
shadow_files = self._create_shadow_files_from_edits(generation_result)
|
|
257
257
|
|
|
@@ -326,7 +326,7 @@ class CodeDiffManager:
|
|
|
326
326
|
"""
|
|
327
327
|
# 生成代码并自动修复lint错误
|
|
328
328
|
generation_result = self.generate_and_fix(query, source_code_list)
|
|
329
|
-
global_cancel.check_and_raise()
|
|
329
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
330
330
|
# 合并代码
|
|
331
331
|
self.code_merger.merge_code(generation_result)
|
|
332
332
|
|
|
@@ -24,6 +24,7 @@ from autocoder.shadows.shadow_manager import ShadowManager
|
|
|
24
24
|
from autocoder.linters.shadow_linter import ShadowLinter
|
|
25
25
|
from autocoder.linters.models import IssueSeverity
|
|
26
26
|
from loguru import logger
|
|
27
|
+
from autocoder.utils.llms import get_llm_names
|
|
27
28
|
from autocoder.common.global_cancel import global_cancel
|
|
28
29
|
from autocoder.linters.models import ProjectLintResult
|
|
29
30
|
from autocoder.common.token_cost_caculate import TokenCostCalculator
|
|
@@ -347,7 +348,7 @@ class CodeEditBlockManager:
|
|
|
347
348
|
|
|
348
349
|
# 计算这次修复缺失上下文花费的token情况
|
|
349
350
|
token_cost_calculator.track_token_usage_by_generate(
|
|
350
|
-
llm=self.
|
|
351
|
+
llm=self.code_generator.llms[0],
|
|
351
352
|
generate=generation_result,
|
|
352
353
|
operation_name="code_generation_complete",
|
|
353
354
|
start_time=start_time,
|
|
@@ -396,24 +397,36 @@ class CodeEditBlockManager:
|
|
|
396
397
|
def _format_blocks(merge: MergeCodeWithoutEffect) -> Tuple[str, str]:
|
|
397
398
|
unmerged_formatted_text = ""
|
|
398
399
|
for file_path, head, update in merge.failed_blocks:
|
|
399
|
-
unmerged_formatted_text += "```lang
|
|
400
|
-
unmerged_formatted_text +=
|
|
401
|
-
unmerged_formatted_text += "
|
|
400
|
+
unmerged_formatted_text += "```lang"
|
|
401
|
+
unmerged_formatted_text += "\n"
|
|
402
|
+
unmerged_formatted_text += f"##File: {file_path}"
|
|
403
|
+
unmerged_formatted_text += "\n"
|
|
404
|
+
unmerged_formatted_text += "<<<<<<< SEARCH"
|
|
405
|
+
unmerged_formatted_text += "\n"
|
|
402
406
|
unmerged_formatted_text += head
|
|
403
|
-
unmerged_formatted_text += "
|
|
407
|
+
unmerged_formatted_text += "\n"
|
|
408
|
+
unmerged_formatted_text += "======="
|
|
409
|
+
unmerged_formatted_text += "\n"
|
|
404
410
|
unmerged_formatted_text += update
|
|
405
|
-
unmerged_formatted_text += "
|
|
411
|
+
unmerged_formatted_text += "\n"
|
|
412
|
+
unmerged_formatted_text += ">>>>>>> REPLACE"
|
|
413
|
+
unmerged_formatted_text += "\n"
|
|
406
414
|
unmerged_formatted_text += "```"
|
|
407
415
|
unmerged_formatted_text += "\n"
|
|
408
416
|
|
|
409
417
|
merged_formatted_text = ""
|
|
410
418
|
if merge.merged_blocks:
|
|
411
419
|
for file_path, head, update in merge.merged_blocks:
|
|
412
|
-
merged_formatted_text += "```lang
|
|
413
|
-
merged_formatted_text +=
|
|
420
|
+
merged_formatted_text += "```lang"
|
|
421
|
+
merged_formatted_text += "\n"
|
|
422
|
+
merged_formatted_text += f"##File: {file_path}"
|
|
423
|
+
merged_formatted_text += "\n"
|
|
414
424
|
merged_formatted_text += head
|
|
415
|
-
merged_formatted_text += "
|
|
425
|
+
merged_formatted_text += "\n"
|
|
426
|
+
merged_formatted_text += "======="
|
|
427
|
+
merged_formatted_text += "\n"
|
|
416
428
|
merged_formatted_text += update
|
|
429
|
+
merged_formatted_text += "\n"
|
|
417
430
|
merged_formatted_text += "```"
|
|
418
431
|
merged_formatted_text += "\n"
|
|
419
432
|
|
|
@@ -433,7 +446,7 @@ class CodeEditBlockManager:
|
|
|
433
446
|
return (unmerged_formatted_text, merged_formatted_text)
|
|
434
447
|
|
|
435
448
|
for attempt in range(self.args.auto_fix_merge_max_attempts):
|
|
436
|
-
global_cancel.check_and_raise()
|
|
449
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
437
450
|
unmerged_formatted_text, merged_formatted_text = _format_blocks(
|
|
438
451
|
merge)
|
|
439
452
|
fix_prompt = self.fix_unmerged_blocks.prompt(
|
|
@@ -470,7 +483,7 @@ class CodeEditBlockManager:
|
|
|
470
483
|
|
|
471
484
|
# 计算这次修复未合并块花费的token情况
|
|
472
485
|
token_cost_calculator.track_token_usage_by_generate(
|
|
473
|
-
llm=self.
|
|
486
|
+
llm=self.code_generator.llms[0],
|
|
474
487
|
generate=generation_result,
|
|
475
488
|
operation_name="code_generation_complete",
|
|
476
489
|
start_time=start_time,
|
|
@@ -544,7 +557,7 @@ class CodeEditBlockManager:
|
|
|
544
557
|
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
545
558
|
|
|
546
559
|
for attempt in range(self.auto_fix_lint_max_attempts):
|
|
547
|
-
global_cancel.check_and_raise()
|
|
560
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
548
561
|
# 代码生成结果更新到影子文件里去
|
|
549
562
|
self.shadow_manager.clean_shadows()
|
|
550
563
|
shadow_files = self._create_shadow_files_from_edits(
|
|
@@ -611,7 +624,7 @@ class CodeEditBlockManager:
|
|
|
611
624
|
|
|
612
625
|
# 计算这次修复lint问题花费的token情况
|
|
613
626
|
token_cost_calculator.track_token_usage_by_generate(
|
|
614
|
-
llm=self.
|
|
627
|
+
llm=self.code_generator.llms[0],
|
|
615
628
|
generate=generation_result,
|
|
616
629
|
operation_name="code_generation_complete",
|
|
617
630
|
start_time=start_time,
|
|
@@ -657,7 +670,7 @@ class CodeEditBlockManager:
|
|
|
657
670
|
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
658
671
|
|
|
659
672
|
for attempt in range(self.auto_fix_compile_max_attempts):
|
|
660
|
-
global_cancel.check_and_raise()
|
|
673
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
661
674
|
# 先更新增量影子系统的文件
|
|
662
675
|
self.shadow_manager.clean_shadows()
|
|
663
676
|
shadow_files = self._create_shadow_files_from_edits(
|
|
@@ -710,7 +723,7 @@ class CodeEditBlockManager:
|
|
|
710
723
|
|
|
711
724
|
# 计算这次修复compile问题花费的token情况
|
|
712
725
|
token_cost_calculator.track_token_usage_by_generate(
|
|
713
|
-
llm=self.
|
|
726
|
+
llm=self.code_generator.llms[0],
|
|
714
727
|
generate=generation_result,
|
|
715
728
|
operation_name="code_generation_complete",
|
|
716
729
|
start_time=start_time,
|
|
@@ -747,9 +760,9 @@ class CodeEditBlockManager:
|
|
|
747
760
|
generation_result = self.code_generator.single_round_run(
|
|
748
761
|
query, source_code_list)
|
|
749
762
|
|
|
750
|
-
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
763
|
+
token_cost_calculator = TokenCostCalculator(args=self.args)
|
|
751
764
|
token_cost_calculator.track_token_usage_by_generate(
|
|
752
|
-
llm=self.
|
|
765
|
+
llm=self.code_generator.llms[0],
|
|
753
766
|
generate=generation_result,
|
|
754
767
|
operation_name="code_generation_complete",
|
|
755
768
|
start_time=start_time,
|
|
@@ -804,7 +817,7 @@ class CodeEditBlockManager:
|
|
|
804
817
|
# 生成代码并自动修复lint错误
|
|
805
818
|
|
|
806
819
|
generation_result = self.generate_and_fix(query, source_code_list)
|
|
807
|
-
global_cancel.check_and_raise()
|
|
820
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
808
821
|
|
|
809
822
|
# 合并代码
|
|
810
823
|
self.code_merger.merge_code(generation_result)
|
|
@@ -32,6 +32,7 @@ class CodeStrictDiffManager:
|
|
|
32
32
|
self.code_merger = CodeAutoMergeStrictDiff(llm, args)
|
|
33
33
|
self.shadow_manager = ShadowManager(args.source_dir, args.event_file)
|
|
34
34
|
self.shadow_linter = ShadowLinter(self.shadow_manager, verbose=False)
|
|
35
|
+
self.args = args
|
|
35
36
|
|
|
36
37
|
@byzerllm.prompt()
|
|
37
38
|
def fix_linter_errors(self, query: str, lint_issues: str) -> str:
|
|
@@ -159,7 +160,7 @@ class CodeStrictDiffManager:
|
|
|
159
160
|
|
|
160
161
|
# 最多尝试修复5次
|
|
161
162
|
for attempt in range(self.max_correction_attempts):
|
|
162
|
-
global_cancel.check_and_raise()
|
|
163
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
163
164
|
# 代码生成结果更新到影子文件里去
|
|
164
165
|
shadow_files = self._create_shadow_files_from_edits(generation_result)
|
|
165
166
|
|
|
@@ -234,7 +235,7 @@ class CodeStrictDiffManager:
|
|
|
234
235
|
"""
|
|
235
236
|
# 生成代码并自动修复lint错误
|
|
236
237
|
generation_result = self.generate_and_fix(query, source_code_list)
|
|
237
|
-
global_cancel.check_and_raise()
|
|
238
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
238
239
|
# 合并代码
|
|
239
240
|
self.code_merger.merge_code(generation_result)
|
|
240
241
|
|
|
@@ -113,7 +113,7 @@ class ActionTSProject(BaseAction):
|
|
|
113
113
|
f"Content(send to model) is {content_length} tokens, which is larger than the maximum input length {self.args.model_max_input_length}"
|
|
114
114
|
)
|
|
115
115
|
|
|
116
|
-
global_cancel.check_and_raise()
|
|
116
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
117
117
|
|
|
118
118
|
if (args.enable_auto_fix_merge or args.enable_auto_fix_lint) and args.execute and args.auto_merge=="editblock":
|
|
119
119
|
code_merge_manager = CodeEditBlockManager(llm=self.llm, args=self.args,action=self)
|
|
@@ -179,7 +179,7 @@ class ActionTSProject(BaseAction):
|
|
|
179
179
|
action_file=self.args.file
|
|
180
180
|
).to_dict())
|
|
181
181
|
|
|
182
|
-
global_cancel.check_and_raise()
|
|
182
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
183
183
|
|
|
184
184
|
merge_result = None
|
|
185
185
|
if args.execute and args.auto_merge:
|
|
@@ -267,7 +267,7 @@ class ActionPyProject(BaseAction):
|
|
|
267
267
|
max_length=self.args.model_max_input_length
|
|
268
268
|
)
|
|
269
269
|
|
|
270
|
-
global_cancel.check_and_raise()
|
|
270
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
271
271
|
|
|
272
272
|
if (args.enable_auto_fix_merge or args.enable_auto_fix_lint) and args.execute and args.auto_merge=="editblock":
|
|
273
273
|
code_merge_manager = CodeEditBlockManager(llm=self.llm, args=self.args,action=self)
|
|
@@ -334,7 +334,7 @@ class ActionPyProject(BaseAction):
|
|
|
334
334
|
action_file=self.args.file
|
|
335
335
|
).to_dict())
|
|
336
336
|
|
|
337
|
-
global_cancel.check_and_raise()
|
|
337
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
338
338
|
|
|
339
339
|
merge_result = None
|
|
340
340
|
if args.execute and args.auto_merge:
|
|
@@ -415,7 +415,7 @@ class ActionSuffixProject(BaseAction):
|
|
|
415
415
|
f"Content(send to model) is {content_length} tokens, which is larger than the maximum input length {self.args.model_max_input_length}"
|
|
416
416
|
)
|
|
417
417
|
|
|
418
|
-
global_cancel.check_and_raise()
|
|
418
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
419
419
|
|
|
420
420
|
if (args.enable_auto_fix_merge or args.enable_auto_fix_lint) and args.execute and args.auto_merge=="editblock":
|
|
421
421
|
code_merge_manager = CodeEditBlockManager(llm=self.llm, args=self.args,action=self)
|
|
@@ -481,7 +481,7 @@ class ActionSuffixProject(BaseAction):
|
|
|
481
481
|
action_file=self.args.file
|
|
482
482
|
).to_dict())
|
|
483
483
|
|
|
484
|
-
global_cancel.check_and_raise()
|
|
484
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
485
485
|
|
|
486
486
|
merge_result = None
|
|
487
487
|
if args.execute and args.auto_merge:
|
|
@@ -67,7 +67,7 @@ class ActionRegexProject:
|
|
|
67
67
|
|
|
68
68
|
start_time = time.time()
|
|
69
69
|
|
|
70
|
-
global_cancel.check_and_raise()
|
|
70
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
71
71
|
|
|
72
72
|
if (args.enable_auto_fix_merge or args.enable_auto_fix_lint) and args.execute and args.auto_merge=="editblock":
|
|
73
73
|
code_merge_manager = CodeEditBlockManager(llm=self.llm, args=self.args,action=self)
|
|
@@ -128,7 +128,7 @@ class ActionRegexProject:
|
|
|
128
128
|
action_file=self.args.file
|
|
129
129
|
).to_dict())
|
|
130
130
|
|
|
131
|
-
global_cancel.check_and_raise()
|
|
131
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
132
132
|
|
|
133
133
|
merge_result = None
|
|
134
134
|
if args.execute and args.auto_merge:
|
|
@@ -71,7 +71,7 @@ class EventManagerSingleton:
|
|
|
71
71
|
|
|
72
72
|
def get_event_file_path(file_id:str,project_path: Optional[str] = None) -> str:
|
|
73
73
|
if project_path is None:
|
|
74
|
-
return os.path.join(".auto-coder", "events", f"{file_id}.jsonl")
|
|
74
|
+
return os.path.join(os.getcwd(),".auto-coder", "events", f"{file_id}.jsonl")
|
|
75
75
|
else:
|
|
76
76
|
return os.path.join(project_path, ".auto-coder", "events", f"{file_id}.jsonl")
|
|
77
77
|
|
autocoder/index/index.py
CHANGED
|
@@ -298,7 +298,7 @@ class IndexManager:
|
|
|
298
298
|
return False
|
|
299
299
|
|
|
300
300
|
def build_index_for_single_source(self, source: SourceCode):
|
|
301
|
-
global_cancel.check_and_raise()
|
|
301
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
302
302
|
|
|
303
303
|
file_path = source.module_name
|
|
304
304
|
if not os.path.exists(file_path):
|
|
@@ -462,7 +462,7 @@ class IndexManager:
|
|
|
462
462
|
def filter_exclude_files(self, file_path, exclude_patterns):
|
|
463
463
|
# 增加 ignore_file_utils 的过滤
|
|
464
464
|
try:
|
|
465
|
-
from
|
|
465
|
+
from autocoder.common.ignorefiles import ignore_file_utils
|
|
466
466
|
if ignore_file_utils.should_ignore(file_path):
|
|
467
467
|
return True
|
|
468
468
|
except Exception:
|
|
@@ -575,7 +575,7 @@ class IndexManager:
|
|
|
575
575
|
for source in wait_to_build_files
|
|
576
576
|
]
|
|
577
577
|
for future in as_completed(futures):
|
|
578
|
-
global_cancel.check_and_raise()
|
|
578
|
+
global_cancel.check_and_raise(token=self.args.event_file)
|
|
579
579
|
result = future.result()
|
|
580
580
|
if result is not None:
|
|
581
581
|
counter += 1
|
autocoder/models.py
CHANGED
|
@@ -60,22 +60,35 @@ default_models_list = [
|
|
|
60
60
|
"max_output_tokens": 8096
|
|
61
61
|
},
|
|
62
62
|
{
|
|
63
|
-
"name": "
|
|
63
|
+
"name": "openai/gpt-4.1-mini",
|
|
64
64
|
"description": "",
|
|
65
|
-
"model_name": "
|
|
65
|
+
"model_name": "openai/gpt-4.1-mini",
|
|
66
66
|
"model_type": "saas/openai",
|
|
67
67
|
"base_url": "https://openrouter.ai/api/v1",
|
|
68
68
|
"api_key_path": "",
|
|
69
69
|
"is_reasoning": False,
|
|
70
|
-
"input_price":
|
|
71
|
-
"output_price":
|
|
70
|
+
"input_price": 2.8,
|
|
71
|
+
"output_price": 11.2,
|
|
72
72
|
"average_speed": 0.0,
|
|
73
|
-
"max_output_tokens": 8096*
|
|
73
|
+
"max_output_tokens": 8096*3
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
"name": "
|
|
76
|
+
"name": "openai/gpt-4.1",
|
|
77
77
|
"description": "",
|
|
78
|
-
"model_name": "
|
|
78
|
+
"model_name": "openai/gpt-4.1",
|
|
79
|
+
"model_type": "saas/openai",
|
|
80
|
+
"base_url": "https://openrouter.ai/api/v1",
|
|
81
|
+
"api_key_path": "",
|
|
82
|
+
"is_reasoning": False,
|
|
83
|
+
"input_price": 14.0,
|
|
84
|
+
"output_price": 42.0,
|
|
85
|
+
"average_speed": 0.0,
|
|
86
|
+
"max_output_tokens": 8096*3
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"name": "openai/gpt-4.1-nano",
|
|
90
|
+
"description": "",
|
|
91
|
+
"model_name": "openai/gpt-4.1-nano",
|
|
79
92
|
"model_type": "saas/openai",
|
|
80
93
|
"base_url": "https://openrouter.ai/api/v1",
|
|
81
94
|
"api_key_path": "",
|
|
@@ -83,8 +96,8 @@ default_models_list = [
|
|
|
83
96
|
"input_price": 0.0,
|
|
84
97
|
"output_price": 0.0,
|
|
85
98
|
"average_speed": 0.0,
|
|
86
|
-
"max_output_tokens": 8096*
|
|
87
|
-
},
|
|
99
|
+
"max_output_tokens": 8096*3
|
|
100
|
+
},
|
|
88
101
|
{
|
|
89
102
|
"name": "openrouter/google/gemini-2.5-pro-preview-03-25",
|
|
90
103
|
"description": "",
|
autocoder/rag/api_server.py
CHANGED
|
@@ -187,9 +187,16 @@ async def serve_static_file(full_path: str, request: Request):
|
|
|
187
187
|
# 直接使用规范化的路径
|
|
188
188
|
file_path = os.path.join("/", os.path.normpath(unquote(full_path)))
|
|
189
189
|
|
|
190
|
+
# 获取允许的静态文件目录
|
|
191
|
+
allowed_static_abs = request.app.state.allowed_static_abs
|
|
192
|
+
logger.info(f"==allowed_static_abs==: {allowed_static_abs}")
|
|
193
|
+
|
|
194
|
+
if file_path.startswith(("/_images","_images")):
|
|
195
|
+
file_path = os.path.join(allowed_static_abs, file_path)
|
|
196
|
+
|
|
190
197
|
# 检查文件是否存在
|
|
191
198
|
if not os.path.exists(file_path):
|
|
192
|
-
raise FileNotFoundError(f"File not found: {file_path}")
|
|
199
|
+
raise FileNotFoundError(f"File not found: {file_path}")
|
|
193
200
|
|
|
194
201
|
# 如果启用了Nginx X-Accel-Redirect,使用X-Accel特性
|
|
195
202
|
if hasattr(request.app.state, "enable_nginx_x_accel") and request.app.state.enable_nginx_x_accel:
|
|
@@ -273,6 +280,9 @@ def serve(llm:ByzerLLM, args: ServerArgs):
|
|
|
273
280
|
allowed_static_abs = os.path.abspath(allowed_static_dir)
|
|
274
281
|
logger.info(f"Static files root directory: {allowed_static_abs}")
|
|
275
282
|
|
|
283
|
+
# 将允许的静态文件目录存储到应用状态中
|
|
284
|
+
router_app.state.allowed_static_abs = allowed_static_abs
|
|
285
|
+
|
|
276
286
|
router_app.add_middleware(
|
|
277
287
|
CORSMiddleware,
|
|
278
288
|
allow_origins=args.allowed_origins,
|
|
@@ -309,9 +319,11 @@ def serve(llm:ByzerLLM, args: ServerArgs):
|
|
|
309
319
|
|
|
310
320
|
# Check if path is in allowed directory
|
|
311
321
|
abs_path = os.path.abspath(os.path.join("/", normalized_path))
|
|
322
|
+
if abs_path.startswith("/_images"):
|
|
323
|
+
return await call_next(request)
|
|
312
324
|
|
|
313
325
|
# 使用预先计算好的allowed_static_abs
|
|
314
|
-
is_allowed = abs_path.startswith(allowed_static_abs)
|
|
326
|
+
is_allowed = abs_path.startswith(request.app.state.allowed_static_abs)
|
|
315
327
|
|
|
316
328
|
if not is_allowed:
|
|
317
329
|
logger.warning(f"Unauthorized path access: {abs_path}")
|
|
@@ -269,7 +269,7 @@ class LocalByzerStorageCache(BaseCacheManager):
|
|
|
269
269
|
"file_path": file_info.file_path,
|
|
270
270
|
"content": chunk[0:self.chunk_size*2],
|
|
271
271
|
"raw_content": chunk[0:self.chunk_size*2],
|
|
272
|
-
"vector": chunk[0:self.
|
|
272
|
+
"vector": chunk[0:self.args.rag_emb_text_size],
|
|
273
273
|
"mtime": file_info.modify_time,
|
|
274
274
|
}
|
|
275
275
|
items.append(chunk_item)
|
|
@@ -88,6 +88,7 @@ class LocalDuckdbStorage:
|
|
|
88
88
|
table_name: str = "documents",
|
|
89
89
|
embed_dim: Optional[int] = None,
|
|
90
90
|
persist_dir: str = "./storage",
|
|
91
|
+
args: Optional[AutoCoderArgs] = None,
|
|
91
92
|
) -> None:
|
|
92
93
|
self.llm = llm
|
|
93
94
|
self.database_name = database_name
|
|
@@ -95,6 +96,7 @@ class LocalDuckdbStorage:
|
|
|
95
96
|
self.embed_dim = embed_dim
|
|
96
97
|
self.persist_dir = persist_dir
|
|
97
98
|
self.cache_dir = os.path.join(self.persist_dir, ".cache")
|
|
99
|
+
self.args = args
|
|
98
100
|
logger.info(f"正在启动 DuckDBVectorStore.")
|
|
99
101
|
|
|
100
102
|
if self.database_name != ":memory:":
|
|
@@ -239,6 +241,11 @@ class LocalDuckdbStorage:
|
|
|
239
241
|
def _node_to_table_row(
|
|
240
242
|
self, context_chunk: Dict[str, str | float], dim: int | None = None
|
|
241
243
|
) -> Any:
|
|
244
|
+
|
|
245
|
+
if not context_chunk["raw_content"]:
|
|
246
|
+
context_chunk["raw_content"] = "empty"
|
|
247
|
+
context_chunk["raw_content"] = context_chunk["raw_content"][: self.args.rag_emb_text_size]
|
|
248
|
+
|
|
242
249
|
return (
|
|
243
250
|
context_chunk["_id"],
|
|
244
251
|
context_chunk["file_path"],
|
|
@@ -332,6 +339,7 @@ class LocalDuckDBStorageCache(BaseCacheManager):
|
|
|
332
339
|
database_name="byzerai_store_duckdb.db",
|
|
333
340
|
table_name="rag_duckdb",
|
|
334
341
|
persist_dir=self.path,
|
|
342
|
+
args=args,
|
|
335
343
|
)
|
|
336
344
|
self.queue = []
|
|
337
345
|
self.chunk_size = 1000
|