auto-coder 0.1.232__tar.gz → 0.1.233__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.
Potentially problematic release.
This version of auto-coder might be problematic. Click here for more details.
- {auto_coder-0.1.232 → auto_coder-0.1.233}/PKG-INFO +1 -1
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/PKG-INFO +1 -1
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/SOURCES.txt +4 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder.py +28 -5
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/chat_auto_coder.py +12 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/__init__.py +1 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/action.py +1 -1
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/copilot.py +1 -1
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +1 -1
- auto_coder-0.1.233/src/autocoder/index/entry.py +286 -0
- auto_coder-0.1.233/src/autocoder/index/filter/normal_filter.py +168 -0
- auto_coder-0.1.233/src/autocoder/index/filter/quick_filter.py +98 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/index/index.py +6 -393
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/index/types.py +4 -1
- auto_coder-0.1.233/src/autocoder/utils/chat_auto_coder_utils/__init__.py +0 -0
- auto_coder-0.1.233/src/autocoder/version.py +1 -0
- auto_coder-0.1.232/src/autocoder/version.py +0 -1
- {auto_coder-0.1.232 → auto_coder-0.1.233}/LICENSE +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/README.md +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/setup.cfg +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/setup.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/requires.txt +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/auto_demand_organizer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/auto_filegroup.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/auto_guess_query.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/auto_tool.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/coder.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/designer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/planner.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/agent/project_reader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder_lang.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder_rag.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder_rag_client_mcp.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder_rag_mcp.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/auto_coder_server.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/benchmark.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/chat/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/chat_auto_coder_lang.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/command_args.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/JupyterClient.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/ShellClient.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/anything2images.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/anything2img.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/audio.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/buildin_tokenizer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/chunk_validation.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/cleaner.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_execute.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_generate.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_generate_diff.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_merge.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_merge_diff.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/code_modification_ranker.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/command_completer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/command_generator.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/command_templates.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/const.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/files.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/git_utils.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/image_to_page.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/interpreter.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/llm_rerank.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/mcp_hub.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/mcp_server.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/mcp_servers/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/mcp_servers/mcp_server_perplexity.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/mcp_tools.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/memory_manager.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/recall_validation.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/screenshots.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/search.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/search_replace.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/sys_prompt.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/text.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/types.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/common/utils_code_auto_generate.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/data/tokenizer.json +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/db/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/db/store.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/index/__init__.py +0 -0
- {auto_coder-0.1.232/src/autocoder/rag → auto_coder-0.1.233/src/autocoder/index/filter}/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/index/for_command.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/index/symbols_utils.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/lang.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/models.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/pyproject/__init__.py +0 -0
- {auto_coder-0.1.232/src/autocoder/rag/cache → auto_coder-0.1.233/src/autocoder/rag}/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/api_server.py +0 -0
- {auto_coder-0.1.232/src/autocoder/rag/stream_event → auto_coder-0.1.233/src/autocoder/rag/cache}/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/cache/base_cache.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/cache/byzer_storage_cache.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/cache/file_monitor_cache.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/cache/simple_cache.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/doc_filter.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/document_retriever.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/llm_wrapper.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/loaders/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/loaders/docx_loader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/loaders/excel_loader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/long_context_rag.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/rag_config.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/rag_entry.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/raw_rag.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/relevant_utils.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/simple_directory_reader.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/simple_rag.py +0 -0
- {auto_coder-0.1.232/src/autocoder/utils/auto_coder_utils → auto_coder-0.1.233/src/autocoder/rag/stream_event}/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/stream_event/event_writer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/stream_event/types.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/token_checker.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/token_counter.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/token_limiter.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/types.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/utils.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/rag/variable_holder.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/regexproject/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/suffixproject/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/tsproject/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/_markitdown.py +0 -0
- {auto_coder-0.1.232/src/autocoder/utils/chat_auto_coder_utils → auto_coder-0.1.233/src/autocoder/utils/auto_coder_utils}/__init__.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/conversation_store.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/llm_client_interceptors.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/llms.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/log_capture.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/multi_turn.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/operate_config_api.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/print_table.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/queue_communicate.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/request_event_queue.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/request_queue.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/rest.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/src/autocoder/utils/tests.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_action_regex_project.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_chat_auto_coder.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_command_completer.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_planner.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_queue_communicate.py +0 -0
- {auto_coder-0.1.232 → auto_coder-0.1.233}/tests/test_symbols_utils.py +0 -0
|
@@ -84,10 +84,14 @@ src/autocoder/dispacher/actions/plugins/__init__.py
|
|
|
84
84
|
src/autocoder/dispacher/actions/plugins/action_regex_project.py
|
|
85
85
|
src/autocoder/dispacher/actions/plugins/action_translate.py
|
|
86
86
|
src/autocoder/index/__init__.py
|
|
87
|
+
src/autocoder/index/entry.py
|
|
87
88
|
src/autocoder/index/for_command.py
|
|
88
89
|
src/autocoder/index/index.py
|
|
89
90
|
src/autocoder/index/symbols_utils.py
|
|
90
91
|
src/autocoder/index/types.py
|
|
92
|
+
src/autocoder/index/filter/__init__.py
|
|
93
|
+
src/autocoder/index/filter/normal_filter.py
|
|
94
|
+
src/autocoder/index/filter/quick_filter.py
|
|
91
95
|
src/autocoder/pyproject/__init__.py
|
|
92
96
|
src/autocoder/rag/__init__.py
|
|
93
97
|
src/autocoder/rag/api_server.py
|
|
@@ -42,6 +42,7 @@ from rich.live import Live
|
|
|
42
42
|
from autocoder.auto_coder_lang import get_message
|
|
43
43
|
from autocoder.common.memory_manager import save_to_memory_file
|
|
44
44
|
from autocoder import models as models_module
|
|
45
|
+
from autocoder.common.utils_code_auto_generate import stream_chat_with_continue
|
|
45
46
|
from autocoder.utils.auto_coder_utils.chat_stream_out import stream_out
|
|
46
47
|
|
|
47
48
|
console = Console()
|
|
@@ -443,7 +444,24 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
443
444
|
"saas.is_reasoning": model_info["is_reasoning"]
|
|
444
445
|
}
|
|
445
446
|
)
|
|
446
|
-
llm.setup_sub_client("inference_model", inference_model)
|
|
447
|
+
llm.setup_sub_client("inference_model", inference_model)
|
|
448
|
+
|
|
449
|
+
if args.index_filter_model:
|
|
450
|
+
model_info = models_module.get_model_by_name(args.index_filter_model)
|
|
451
|
+
model_name = args.index_filter_model
|
|
452
|
+
index_filter_model = byzerllm.SimpleByzerLLM(default_model_name=model_name)
|
|
453
|
+
index_filter_model.deploy(
|
|
454
|
+
model_path="",
|
|
455
|
+
pretrained_model_type=model_info["model_type"],
|
|
456
|
+
udf_name=model_name,
|
|
457
|
+
infer_params={
|
|
458
|
+
"saas.base_url": model_info["base_url"],
|
|
459
|
+
"saas.api_key": model_info["api_key"],
|
|
460
|
+
"saas.model": model_info["model_name"],
|
|
461
|
+
"saas.is_reasoning": model_info["is_reasoning"]
|
|
462
|
+
}
|
|
463
|
+
)
|
|
464
|
+
llm.setup_sub_client("index_filter_model", index_filter_model)
|
|
447
465
|
|
|
448
466
|
|
|
449
467
|
if args.product_mode == "pro":
|
|
@@ -482,7 +500,12 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
482
500
|
if args.inference_model:
|
|
483
501
|
inference_model = byzerllm.ByzerLLM()
|
|
484
502
|
inference_model.setup_default_model_name(args.inference_model)
|
|
485
|
-
llm.setup_sub_client("inference_model", inference_model)
|
|
503
|
+
llm.setup_sub_client("inference_model", inference_model)
|
|
504
|
+
|
|
505
|
+
if args.index_filter_model:
|
|
506
|
+
index_filter_model = byzerllm.ByzerLLM()
|
|
507
|
+
index_filter_model.setup_default_model_name(args.index_filter_model)
|
|
508
|
+
llm.setup_sub_client("index_filter_model", index_filter_model)
|
|
486
509
|
|
|
487
510
|
|
|
488
511
|
if args.human_as_model:
|
|
@@ -1106,7 +1129,8 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
1106
1129
|
{"role": "assistant", "content": "read"})
|
|
1107
1130
|
source_count += 1
|
|
1108
1131
|
|
|
1109
|
-
from autocoder.index.index import IndexManager
|
|
1132
|
+
from autocoder.index.index import IndexManager
|
|
1133
|
+
from autocoder.index.entry import build_index_and_filter_files
|
|
1110
1134
|
from autocoder.pyproject import PyProject
|
|
1111
1135
|
from autocoder.tsproject import TSProject
|
|
1112
1136
|
from autocoder.suffixproject import SuffixProject
|
|
@@ -1272,8 +1296,7 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
1272
1296
|
)
|
|
1273
1297
|
)
|
|
1274
1298
|
v = [[response.result,None]]
|
|
1275
|
-
else:
|
|
1276
|
-
from autocoder.common.utils_code_auto_generate import stream_chat_with_continue
|
|
1299
|
+
else:
|
|
1277
1300
|
v = stream_chat_with_continue(
|
|
1278
1301
|
llm=chat_llm,
|
|
1279
1302
|
conversations=loaded_conversations,
|
|
@@ -52,6 +52,7 @@ from autocoder.common.memory_manager import get_global_memory_file_paths
|
|
|
52
52
|
from autocoder import models
|
|
53
53
|
import shlex
|
|
54
54
|
from autocoder.utils.llms import get_single_llm
|
|
55
|
+
import pkg_resources
|
|
55
56
|
|
|
56
57
|
class SymbolItem(BaseModel):
|
|
57
58
|
symbol_name: str
|
|
@@ -2478,6 +2479,17 @@ def lib_command(args: List[str]):
|
|
|
2478
2479
|
|
|
2479
2480
|
|
|
2480
2481
|
def main():
|
|
2482
|
+
from autocoder.rag.variable_holder import VariableHolder
|
|
2483
|
+
from tokenizers import Tokenizer
|
|
2484
|
+
try:
|
|
2485
|
+
tokenizer_path = pkg_resources.resource_filename(
|
|
2486
|
+
"autocoder", "data/tokenizer.json"
|
|
2487
|
+
)
|
|
2488
|
+
VariableHolder.TOKENIZER_PATH = tokenizer_path
|
|
2489
|
+
VariableHolder.TOKENIZER_MODEL = Tokenizer.from_file(tokenizer_path)
|
|
2490
|
+
except FileNotFoundError:
|
|
2491
|
+
tokenizer_path = None
|
|
2492
|
+
|
|
2481
2493
|
ARGS = parse_arguments()
|
|
2482
2494
|
|
|
2483
2495
|
if ARGS.lite:
|
|
@@ -259,6 +259,7 @@ class AutoCoderArgs(pydantic.BaseModel):
|
|
|
259
259
|
skip_filter_index: Optional[bool] = False
|
|
260
260
|
|
|
261
261
|
index_model: Optional[str] = ""
|
|
262
|
+
index_filter_model: Optional[str] = ""
|
|
262
263
|
index_model_max_length: Optional[int] = 0
|
|
263
264
|
index_model_max_input_length: Optional[int] = 0
|
|
264
265
|
index_model_anti_quota_limit: Optional[int] = 0
|
|
@@ -9,7 +9,7 @@ from autocoder.common.buildin_tokenizer import BuildinTokenizer
|
|
|
9
9
|
from autocoder.pyproject import PyProject, Level1PyProject
|
|
10
10
|
from autocoder.tsproject import TSProject
|
|
11
11
|
from autocoder.suffixproject import SuffixProject
|
|
12
|
-
from autocoder.index.
|
|
12
|
+
from autocoder.index.entry import build_index_and_filter_files
|
|
13
13
|
from autocoder.common.code_auto_merge import CodeAutoMerge
|
|
14
14
|
from autocoder.common.code_auto_merge_diff import CodeAutoMergeDiff
|
|
15
15
|
from autocoder.common.code_auto_merge_strict_diff import CodeAutoMergeStrictDiff
|
|
@@ -9,7 +9,7 @@ from autocoder.common.JupyterClient import JupyterNotebook
|
|
|
9
9
|
from autocoder.common.ShellClient import ShellClient
|
|
10
10
|
from autocoder.suffixproject import SuffixProject
|
|
11
11
|
from autocoder.common.search import Search, SearchEngine
|
|
12
|
-
from autocoder.index.
|
|
12
|
+
from autocoder.index.entry import build_index_and_filter_files
|
|
13
13
|
from autocoder.common.image_to_page import ImageToPage, ImageToPageDirectly
|
|
14
14
|
from typing import Optional, Dict, Any, List
|
|
15
15
|
import byzerllm
|
|
@@ -9,7 +9,7 @@ from autocoder.common.code_auto_generate import CodeAutoGenerate
|
|
|
9
9
|
from autocoder.common.code_auto_generate_diff import CodeAutoGenerateDiff
|
|
10
10
|
from autocoder.common.code_auto_generate_strict_diff import CodeAutoGenerateStrictDiff
|
|
11
11
|
from autocoder.common.code_auto_generate_editblock import CodeAutoGenerateEditBlock
|
|
12
|
-
from autocoder.index.
|
|
12
|
+
from autocoder.index.entry import build_index_and_filter_files
|
|
13
13
|
from autocoder.regexproject import RegexProject
|
|
14
14
|
from autocoder.utils.conversation_store import store_code_model_conversation
|
|
15
15
|
from loguru import logger
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import json
|
|
3
|
+
import time
|
|
4
|
+
from typing import List, Dict, Any, Optional
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from autocoder.common import SourceCode, AutoCoderArgs
|
|
7
|
+
|
|
8
|
+
from rich.console import Console
|
|
9
|
+
from rich.table import Table
|
|
10
|
+
from rich.panel import Panel
|
|
11
|
+
|
|
12
|
+
from loguru import logger
|
|
13
|
+
from autocoder.utils.queue_communicate import (
|
|
14
|
+
queue_communicate,
|
|
15
|
+
CommunicateEvent,
|
|
16
|
+
CommunicateEventType,
|
|
17
|
+
)
|
|
18
|
+
from autocoder.index.types import (
|
|
19
|
+
TargetFile
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
from autocoder.index.filter.quick_filter import QuickFilter
|
|
23
|
+
from autocoder.index.filter.normal_filter import NormalFilter
|
|
24
|
+
from autocoder.index.index import IndexManager
|
|
25
|
+
|
|
26
|
+
def build_index_and_filter_files(
|
|
27
|
+
llm, args: AutoCoderArgs, sources: List[SourceCode]
|
|
28
|
+
) -> str:
|
|
29
|
+
# Initialize timing and statistics
|
|
30
|
+
total_start_time = time.monotonic()
|
|
31
|
+
stats = {
|
|
32
|
+
"total_files": len(sources),
|
|
33
|
+
"indexed_files": 0,
|
|
34
|
+
"level1_filtered": 0,
|
|
35
|
+
"level2_filtered": 0,
|
|
36
|
+
"verified_files": 0,
|
|
37
|
+
"final_files": 0,
|
|
38
|
+
"timings": {
|
|
39
|
+
"process_tagged_sources": 0.0,
|
|
40
|
+
"build_index": 0.0,
|
|
41
|
+
"quick_filter": 0.0,
|
|
42
|
+
"normal_filter": {
|
|
43
|
+
"level1_filter": 0.0,
|
|
44
|
+
"level2_filter": 0.0,
|
|
45
|
+
"relevance_verification": 0.0,
|
|
46
|
+
},
|
|
47
|
+
"file_selection": 0.0,
|
|
48
|
+
"prepare_output": 0.0,
|
|
49
|
+
"total": 0.0
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
def get_file_path(file_path):
|
|
54
|
+
if file_path.startswith("##"):
|
|
55
|
+
return file_path.strip()[2:]
|
|
56
|
+
return file_path
|
|
57
|
+
|
|
58
|
+
final_files: Dict[str, TargetFile] = {}
|
|
59
|
+
|
|
60
|
+
# Phase 1: Process REST/RAG/Search sources
|
|
61
|
+
logger.info("Phase 1: Processing REST/RAG/Search sources...")
|
|
62
|
+
phase_start = time.monotonic()
|
|
63
|
+
for source in sources:
|
|
64
|
+
if source.tag in ["REST", "RAG", "SEARCH"]:
|
|
65
|
+
final_files[get_file_path(source.module_name)] = TargetFile(
|
|
66
|
+
file_path=source.module_name, reason="Rest/Rag/Search"
|
|
67
|
+
)
|
|
68
|
+
phase_end = time.monotonic()
|
|
69
|
+
stats["timings"]["process_tagged_sources"] = phase_end - phase_start
|
|
70
|
+
|
|
71
|
+
if not args.skip_build_index and llm:
|
|
72
|
+
# Phase 2: Build index
|
|
73
|
+
if args.request_id and not args.skip_events:
|
|
74
|
+
queue_communicate.send_event(
|
|
75
|
+
request_id=args.request_id,
|
|
76
|
+
event=CommunicateEvent(
|
|
77
|
+
event_type=CommunicateEventType.CODE_INDEX_BUILD_START.value,
|
|
78
|
+
data=json.dumps({"total_files": len(sources)})
|
|
79
|
+
)
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
logger.info("Phase 2: Building index for all files...")
|
|
83
|
+
phase_start = time.monotonic()
|
|
84
|
+
index_manager = IndexManager(llm=llm, sources=sources, args=args)
|
|
85
|
+
index_data = index_manager.build_index()
|
|
86
|
+
stats["indexed_files"] = len(index_data) if index_data else 0
|
|
87
|
+
phase_end = time.monotonic()
|
|
88
|
+
stats["timings"]["build_index"] = phase_end - phase_start
|
|
89
|
+
|
|
90
|
+
if args.request_id and not args.skip_events:
|
|
91
|
+
queue_communicate.send_event(
|
|
92
|
+
request_id=args.request_id,
|
|
93
|
+
event=CommunicateEvent(
|
|
94
|
+
event_type=CommunicateEventType.CODE_INDEX_BUILD_END.value,
|
|
95
|
+
data=json.dumps({
|
|
96
|
+
"indexed_files": stats["indexed_files"],
|
|
97
|
+
"build_index_time": stats["timings"]["build_index"],
|
|
98
|
+
})
|
|
99
|
+
)
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
quick_filter = QuickFilter(index_manager,stats,sources)
|
|
103
|
+
final_files = quick_filter.filter(index_manager.read_index(),args.query)
|
|
104
|
+
|
|
105
|
+
if not final_files:
|
|
106
|
+
normal_filter = NormalFilter(index_manager,stats,sources)
|
|
107
|
+
final_files = normal_filter.filter(index_manager.read_index(),args.query)
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def display_table_and_get_selections(data):
|
|
111
|
+
from prompt_toolkit.shortcuts import checkboxlist_dialog
|
|
112
|
+
from prompt_toolkit.styles import Style
|
|
113
|
+
|
|
114
|
+
choices = [(file, f"{file} - {reason}") for file, reason in data]
|
|
115
|
+
selected_files = [file for file, _ in choices]
|
|
116
|
+
|
|
117
|
+
style = Style.from_dict(
|
|
118
|
+
{
|
|
119
|
+
"dialog": "bg:#88ff88",
|
|
120
|
+
"dialog frame.label": "bg:#ffffff #000000",
|
|
121
|
+
"dialog.body": "bg:#88ff88 #000000",
|
|
122
|
+
"dialog shadow": "bg:#00aa00",
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
result = checkboxlist_dialog(
|
|
127
|
+
title="Target Files",
|
|
128
|
+
text="Tab to switch between buttons, and Space/Enter to select/deselect.",
|
|
129
|
+
values=choices,
|
|
130
|
+
style=style,
|
|
131
|
+
default_values=selected_files,
|
|
132
|
+
).run()
|
|
133
|
+
|
|
134
|
+
return [file for file in result] if result else []
|
|
135
|
+
|
|
136
|
+
def print_selected(data):
|
|
137
|
+
console = Console()
|
|
138
|
+
|
|
139
|
+
table = Table(
|
|
140
|
+
title="Files Used as Context",
|
|
141
|
+
show_header=True,
|
|
142
|
+
header_style="bold magenta",
|
|
143
|
+
)
|
|
144
|
+
table.add_column("File Path", style="cyan", no_wrap=True)
|
|
145
|
+
table.add_column("Reason", style="green")
|
|
146
|
+
|
|
147
|
+
for file, reason in data:
|
|
148
|
+
table.add_row(file, reason)
|
|
149
|
+
|
|
150
|
+
panel = Panel(
|
|
151
|
+
table,
|
|
152
|
+
expand=False,
|
|
153
|
+
border_style="bold blue",
|
|
154
|
+
padding=(1, 1),
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
console.print(panel)
|
|
158
|
+
|
|
159
|
+
# Phase 6: File selection and limitation
|
|
160
|
+
logger.info("Phase 6: Processing file selection and limits...")
|
|
161
|
+
phase_start = time.monotonic()
|
|
162
|
+
|
|
163
|
+
if args.index_filter_file_num > 0:
|
|
164
|
+
logger.info(
|
|
165
|
+
f"Limiting files from {len(final_files)} to {args.index_filter_file_num}")
|
|
166
|
+
|
|
167
|
+
if args.skip_confirm:
|
|
168
|
+
final_filenames = [file.file_path for file in final_files.values()]
|
|
169
|
+
if args.index_filter_file_num > 0:
|
|
170
|
+
final_filenames = final_filenames[: args.index_filter_file_num]
|
|
171
|
+
else:
|
|
172
|
+
target_files_data = [
|
|
173
|
+
(file.file_path, file.reason) for file in final_files.values()
|
|
174
|
+
]
|
|
175
|
+
if not target_files_data:
|
|
176
|
+
logger.warning(
|
|
177
|
+
"No target files found, you may need to rewrite the query and try again."
|
|
178
|
+
)
|
|
179
|
+
final_filenames = []
|
|
180
|
+
else:
|
|
181
|
+
final_filenames = display_table_and_get_selections(
|
|
182
|
+
target_files_data)
|
|
183
|
+
|
|
184
|
+
if args.index_filter_file_num > 0:
|
|
185
|
+
final_filenames = final_filenames[: args.index_filter_file_num]
|
|
186
|
+
|
|
187
|
+
phase_end = time.monotonic()
|
|
188
|
+
stats["timings"]["file_selection"] = phase_end - phase_start
|
|
189
|
+
|
|
190
|
+
# Phase 7: Display results and prepare output
|
|
191
|
+
logger.info("Phase 7: Preparing final output...")
|
|
192
|
+
phase_start = time.monotonic()
|
|
193
|
+
try:
|
|
194
|
+
print_selected(
|
|
195
|
+
[
|
|
196
|
+
(file.file_path, file.reason)
|
|
197
|
+
for file in final_files.values()
|
|
198
|
+
if file.file_path in final_filenames
|
|
199
|
+
]
|
|
200
|
+
)
|
|
201
|
+
except Exception as e:
|
|
202
|
+
logger.warning(
|
|
203
|
+
"Failed to display selected files in terminal mode. Falling back to simple print."
|
|
204
|
+
)
|
|
205
|
+
print("Target Files Selected:")
|
|
206
|
+
for file in final_filenames:
|
|
207
|
+
print(f"{file} - {final_files[file].reason}")
|
|
208
|
+
|
|
209
|
+
source_code = ""
|
|
210
|
+
depulicated_sources = set()
|
|
211
|
+
|
|
212
|
+
for file in sources:
|
|
213
|
+
if file.module_name in final_filenames:
|
|
214
|
+
if file.module_name in depulicated_sources:
|
|
215
|
+
continue
|
|
216
|
+
depulicated_sources.add(file.module_name)
|
|
217
|
+
source_code += f"##File: {file.module_name}\n"
|
|
218
|
+
source_code += f"{file.source_code}\n\n"
|
|
219
|
+
|
|
220
|
+
if args.request_id and not args.skip_events:
|
|
221
|
+
queue_communicate.send_event(
|
|
222
|
+
request_id=args.request_id,
|
|
223
|
+
event=CommunicateEvent(
|
|
224
|
+
event_type=CommunicateEventType.CODE_INDEX_FILTER_FILE_SELECTED.value,
|
|
225
|
+
data=json.dumps([
|
|
226
|
+
(file.file_path, file.reason)
|
|
227
|
+
for file in final_files.values()
|
|
228
|
+
if file.file_path in depulicated_sources
|
|
229
|
+
])
|
|
230
|
+
)
|
|
231
|
+
)
|
|
232
|
+
|
|
233
|
+
stats["final_files"] = len(depulicated_sources)
|
|
234
|
+
phase_end = time.monotonic()
|
|
235
|
+
stats["timings"]["prepare_output"] = phase_end - phase_start
|
|
236
|
+
|
|
237
|
+
# Calculate total time and print summary
|
|
238
|
+
total_end_time = time.monotonic()
|
|
239
|
+
total_time = total_end_time - total_start_time
|
|
240
|
+
stats["timings"]["total"] = total_time
|
|
241
|
+
|
|
242
|
+
# Calculate total filter time
|
|
243
|
+
total_filter_time = (
|
|
244
|
+
stats["timings"]["quick_filter"] +
|
|
245
|
+
stats["timings"]["normal_filter"]["level1_filter"] +
|
|
246
|
+
stats["timings"]["normal_filter"]["level2_filter"] +
|
|
247
|
+
stats["timings"]["normal_filter"]["relevance_verification"]
|
|
248
|
+
)
|
|
249
|
+
|
|
250
|
+
# Print final statistics in a more structured way
|
|
251
|
+
summary = f"""
|
|
252
|
+
=== Indexing and Filtering Summary ===
|
|
253
|
+
• Total files scanned: {stats['total_files']}
|
|
254
|
+
• Files indexed: {stats['indexed_files']}
|
|
255
|
+
• Files filtered:
|
|
256
|
+
- Level 1 (query-based): {stats['level1_filtered']}
|
|
257
|
+
- Level 2 (related files): {stats['level2_filtered']}
|
|
258
|
+
- Relevance verified: {stats.get('verified_files', 0)}
|
|
259
|
+
• Final files selected: {stats['final_files']}
|
|
260
|
+
|
|
261
|
+
=== Time Breakdown ===
|
|
262
|
+
• Index build: {stats['timings'].get('build_index', 0):.2f}s
|
|
263
|
+
• Quick filter: {stats['timings'].get('quick_filter', 0):.2f}s
|
|
264
|
+
• Normal filter:
|
|
265
|
+
- Level 1 filter: {stats['timings']["normal_filter"].get('level1_filter', 0):.2f}s
|
|
266
|
+
- Level 2 filter: {stats['timings']["normal_filter"].get('level2_filter', 0):.2f}s
|
|
267
|
+
- Relevance check: {stats['timings']["normal_filter"].get('relevance_verification', 0):.2f}s
|
|
268
|
+
• File selection: {stats['timings'].get('file_selection', 0):.2f}s
|
|
269
|
+
• Total time: {total_time:.2f}s
|
|
270
|
+
====================================
|
|
271
|
+
"""
|
|
272
|
+
logger.info(summary)
|
|
273
|
+
|
|
274
|
+
if args.request_id and not args.skip_events:
|
|
275
|
+
queue_communicate.send_event(
|
|
276
|
+
request_id=args.request_id,
|
|
277
|
+
event=CommunicateEvent(
|
|
278
|
+
event_type=CommunicateEventType.CODE_INDEX_FILTER_END.value,
|
|
279
|
+
data=json.dumps({
|
|
280
|
+
"filtered_files": stats["final_files"],
|
|
281
|
+
"filter_time": total_filter_time
|
|
282
|
+
})
|
|
283
|
+
)
|
|
284
|
+
)
|
|
285
|
+
|
|
286
|
+
return source_code
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
from typing import List, Union,Dict,Any
|
|
2
|
+
from autocoder.index.types import IndexItem
|
|
3
|
+
from autocoder.common import SourceCode, AutoCoderArgs
|
|
4
|
+
import byzerllm
|
|
5
|
+
import time
|
|
6
|
+
from autocoder.index.index import IndexManager
|
|
7
|
+
from autocoder.index.types import (
|
|
8
|
+
IndexItem,
|
|
9
|
+
TargetFile,
|
|
10
|
+
VerifyFileRelevance,
|
|
11
|
+
FileList,
|
|
12
|
+
FileNumberList
|
|
13
|
+
)
|
|
14
|
+
from loguru import logger
|
|
15
|
+
from autocoder.utils.queue_communicate import (
|
|
16
|
+
queue_communicate,
|
|
17
|
+
CommunicateEvent,
|
|
18
|
+
CommunicateEventType,
|
|
19
|
+
)
|
|
20
|
+
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
21
|
+
import json
|
|
22
|
+
|
|
23
|
+
def get_file_path(file_path):
|
|
24
|
+
if file_path.startswith("##"):
|
|
25
|
+
return file_path.strip()[2:]
|
|
26
|
+
return file_path
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class NormalFilter():
|
|
30
|
+
def __init__(self, index_manager: IndexManager,stats:Dict[str,Any],sources:List[SourceCode]):
|
|
31
|
+
self.index_manager = index_manager
|
|
32
|
+
self.args = index_manager.args
|
|
33
|
+
self.stats = stats
|
|
34
|
+
self.sources = sources
|
|
35
|
+
|
|
36
|
+
def filter(self, index_items: List[IndexItem], query: str) -> Dict[str, TargetFile]:
|
|
37
|
+
final_files: Dict[str, TargetFile] = {}
|
|
38
|
+
if not self.args.skip_filter_index:
|
|
39
|
+
if self.args.request_id and not self.args.skip_events:
|
|
40
|
+
queue_communicate.send_event(
|
|
41
|
+
request_id=self.args.request_id,
|
|
42
|
+
event=CommunicateEvent(
|
|
43
|
+
event_type=CommunicateEventType.CODE_INDEX_FILTER_START.value,
|
|
44
|
+
data=json.dumps({})
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
# Phase 3: Level 1 filtering - Query-based
|
|
48
|
+
logger.info(
|
|
49
|
+
"Phase 3: Performing Level 1 filtering (query-based)...")
|
|
50
|
+
|
|
51
|
+
phase_start = time.monotonic()
|
|
52
|
+
target_files = self.index_manager.get_target_files_by_query(self.args.query)
|
|
53
|
+
|
|
54
|
+
if target_files:
|
|
55
|
+
for file in target_files.file_list:
|
|
56
|
+
file_path = file.file_path.strip()
|
|
57
|
+
final_files[get_file_path(file_path)] = file
|
|
58
|
+
self.stats["level1_filtered"] = len(target_files.file_list)
|
|
59
|
+
phase_end = time.monotonic()
|
|
60
|
+
self.stats["timings"]["normal_filter"]["level1_filter"] = phase_end - phase_start
|
|
61
|
+
|
|
62
|
+
# Phase 4: Level 2 filtering - Related files
|
|
63
|
+
if target_files is not None and self.args.index_filter_level >= 2:
|
|
64
|
+
logger.info(
|
|
65
|
+
"Phase 4: Performing Level 2 filtering (related files)...")
|
|
66
|
+
if self.args.request_id and not self.args.skip_events:
|
|
67
|
+
queue_communicate.send_event(
|
|
68
|
+
request_id=self.args.request_id,
|
|
69
|
+
event=CommunicateEvent(
|
|
70
|
+
event_type=CommunicateEventType.CODE_INDEX_FILTER_START.value,
|
|
71
|
+
data=json.dumps({})
|
|
72
|
+
)
|
|
73
|
+
)
|
|
74
|
+
phase_start = time.monotonic()
|
|
75
|
+
related_files = self.index_manager.get_related_files(
|
|
76
|
+
[file.file_path for file in target_files.file_list]
|
|
77
|
+
)
|
|
78
|
+
if related_files is not None:
|
|
79
|
+
for file in related_files.file_list:
|
|
80
|
+
file_path = file.file_path.strip()
|
|
81
|
+
final_files[get_file_path(file_path)] = file
|
|
82
|
+
self.stats["level2_filtered"] = len(related_files.file_list)
|
|
83
|
+
phase_end = time.monotonic()
|
|
84
|
+
self.stats["timings"]["normal_filter"]["level2_filter"] = phase_end - phase_start
|
|
85
|
+
|
|
86
|
+
if not final_files:
|
|
87
|
+
logger.warning("No related files found, using all files")
|
|
88
|
+
for source in self.sources:
|
|
89
|
+
final_files[get_file_path(source.module_name)] = TargetFile(
|
|
90
|
+
file_path=source.module_name,
|
|
91
|
+
reason="No related files found, use all files",
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
# Phase 5: Relevance verification
|
|
95
|
+
logger.info("Phase 5: Performing relevance verification...")
|
|
96
|
+
if self.args.index_filter_enable_relevance_verification:
|
|
97
|
+
phase_start = time.monotonic()
|
|
98
|
+
verified_files = {}
|
|
99
|
+
temp_files = list(final_files.values())
|
|
100
|
+
verification_results = []
|
|
101
|
+
|
|
102
|
+
def print_verification_results(results):
|
|
103
|
+
from rich.table import Table
|
|
104
|
+
from rich.console import Console
|
|
105
|
+
|
|
106
|
+
console = Console()
|
|
107
|
+
table = Table(title="File Relevance Verification Results", show_header=True, header_style="bold magenta")
|
|
108
|
+
table.add_column("File Path", style="cyan", no_wrap=True)
|
|
109
|
+
table.add_column("Score", justify="right", style="green")
|
|
110
|
+
table.add_column("Status", style="yellow")
|
|
111
|
+
table.add_column("Reason/Error")
|
|
112
|
+
|
|
113
|
+
for file_path, score, status, reason in results:
|
|
114
|
+
table.add_row(
|
|
115
|
+
file_path,
|
|
116
|
+
str(score) if score is not None else "N/A",
|
|
117
|
+
status,
|
|
118
|
+
reason
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
console.print(table)
|
|
122
|
+
|
|
123
|
+
def verify_single_file(file: TargetFile):
|
|
124
|
+
for source in self.sources:
|
|
125
|
+
if source.module_name == file.file_path:
|
|
126
|
+
file_content = source.source_code
|
|
127
|
+
try:
|
|
128
|
+
result = self.index_manager.verify_file_relevance.with_llm(llm).with_return_type(VerifyFileRelevance).run(
|
|
129
|
+
file_content=file_content,
|
|
130
|
+
query=self.args.query
|
|
131
|
+
)
|
|
132
|
+
if result.relevant_score >= self.args.verify_file_relevance_score:
|
|
133
|
+
verified_files[file.file_path] = TargetFile(
|
|
134
|
+
file_path=file.file_path,
|
|
135
|
+
reason=f"Score:{result.relevant_score}, {result.reason}"
|
|
136
|
+
)
|
|
137
|
+
return file.file_path, result.relevant_score, "PASS", result.reason
|
|
138
|
+
else:
|
|
139
|
+
return file.file_path, result.relevant_score, "FAIL", result.reason
|
|
140
|
+
except Exception as e:
|
|
141
|
+
error_msg = str(e)
|
|
142
|
+
verified_files[file.file_path] = TargetFile(
|
|
143
|
+
file_path=file.file_path,
|
|
144
|
+
reason=f"Verification failed: {error_msg}"
|
|
145
|
+
)
|
|
146
|
+
return file.file_path, None, "ERROR", error_msg
|
|
147
|
+
return None
|
|
148
|
+
|
|
149
|
+
with ThreadPoolExecutor(max_workers=self.args.index_filter_workers) as executor:
|
|
150
|
+
futures = [executor.submit(verify_single_file, file)
|
|
151
|
+
for file in temp_files]
|
|
152
|
+
for future in as_completed(futures):
|
|
153
|
+
result = future.result()
|
|
154
|
+
if result:
|
|
155
|
+
verification_results.append(result)
|
|
156
|
+
time.sleep(self.args.anti_quota_limit)
|
|
157
|
+
|
|
158
|
+
# Print verification results in a table
|
|
159
|
+
print_verification_results(verification_results)
|
|
160
|
+
|
|
161
|
+
self.stats["verified_files"] = len(verified_files)
|
|
162
|
+
phase_end = time.monotonic()
|
|
163
|
+
self.stats["timings"]["normal_filter"]["relevance_verification"] = phase_end - phase_start
|
|
164
|
+
|
|
165
|
+
# Keep all files, not just verified ones
|
|
166
|
+
final_files = verified_files
|
|
167
|
+
|
|
168
|
+
return final_files
|