auto-coder 0.1.243__tar.gz → 0.1.244__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.243 → auto_coder-0.1.244}/PKG-INFO +2 -2
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/PKG-INFO +2 -2
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/requires.txt +1 -1
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder.py +17 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat_auto_coder.py +2 -2
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat_auto_coder_lang.py +5 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/auto_coder_lang.py +11 -1
- auto_coder-0.1.244/src/autocoder/common/files.py +58 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/index.py +1 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/models.py +21 -21
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/suffixproject/__init__.py +2 -3
- auto_coder-0.1.244/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +257 -0
- auto_coder-0.1.244/src/autocoder/utils/rest.py +142 -0
- auto_coder-0.1.244/src/autocoder/version.py +1 -0
- auto_coder-0.1.243/src/autocoder/common/files.py +0 -26
- auto_coder-0.1.243/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +0 -381
- auto_coder-0.1.243/src/autocoder/utils/rest.py +0 -190
- auto_coder-0.1.243/src/autocoder/version.py +0 -1
- {auto_coder-0.1.243 → auto_coder-0.1.244}/LICENSE +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/README.md +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/setup.cfg +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/setup.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/SOURCES.txt +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_demand_organizer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_filegroup.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_guess_query.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_tool.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/coder.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/designer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/planner.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/project_reader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag_client_mcp.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag_mcp.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_server.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/benchmark.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/command_args.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/JupyterClient.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/ShellClient.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/anything2images.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/anything2img.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/audio.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/buildin_tokenizer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/chunk_validation.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/cleaner.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_execute.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_diff.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_diff.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_modification_ranker.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_completer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_generator.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_templates.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/const.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/git_utils.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/image_to_page.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/interpreter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/llm_rerank.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_hub.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_server.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_servers/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_servers/mcp_server_perplexity.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_tools.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/memory_manager.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/printer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/recall_validation.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/screenshots.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/search.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/search_replace.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/sys_prompt.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/text.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/types.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/utils_code_auto_generate.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/data/tokenizer.json +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/db/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/db/store.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/action.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/copilot.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/entry.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/normal_filter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/quick_filter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/for_command.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/symbols_utils.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/types.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/lang.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/pyproject/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/api_server.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/base_cache.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/byzer_storage_cache.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/file_monitor_cache.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/simple_cache.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/doc_filter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/document_retriever.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/llm_wrapper.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/docx_loader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/excel_loader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/long_context_rag.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/rag_config.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/rag_entry.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/raw_rag.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/relevant_utils.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/simple_directory_reader.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/simple_rag.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/event_writer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/types.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_checker.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_counter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_limiter.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/types.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/utils.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/variable_holder.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/regexproject/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/tsproject/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/_markitdown.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/auto_coder_utils/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/chat_auto_coder_utils/__init__.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/conversation_store.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/llm_client_interceptors.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/llms.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/log_capture.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/multi_turn.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/operate_config_api.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/print_table.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/queue_communicate.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/request_event_queue.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/request_queue.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/tests.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/types.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_action_regex_project.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_chat_auto_coder.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_command_completer.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_planner.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_queue_communicate.py +0 -0
- {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_symbols_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.244
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -26,7 +26,7 @@ Requires-Dist: tabulate
|
|
|
26
26
|
Requires-Dist: jupyter_client
|
|
27
27
|
Requires-Dist: prompt-toolkit
|
|
28
28
|
Requires-Dist: tokenizers
|
|
29
|
-
Requires-Dist: byzerllm[saas]>=0.1.
|
|
29
|
+
Requires-Dist: byzerllm[saas]>=0.1.160
|
|
30
30
|
Requires-Dist: patch
|
|
31
31
|
Requires-Dist: diff_match_patch
|
|
32
32
|
Requires-Dist: GitPython
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: auto-coder
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.244
|
|
4
4
|
Summary: AutoCoder: AutoCoder
|
|
5
5
|
Author: allwefantasy
|
|
6
6
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
@@ -26,7 +26,7 @@ Requires-Dist: tabulate
|
|
|
26
26
|
Requires-Dist: jupyter_client
|
|
27
27
|
Requires-Dist: prompt-toolkit
|
|
28
28
|
Requires-Dist: tokenizers
|
|
29
|
-
Requires-Dist: byzerllm[saas]>=0.1.
|
|
29
|
+
Requires-Dist: byzerllm[saas]>=0.1.160
|
|
30
30
|
Requires-Dist: patch
|
|
31
31
|
Requires-Dist: diff_match_patch
|
|
32
32
|
Requires-Dist: GitPython
|
|
@@ -692,6 +692,23 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
692
692
|
)
|
|
693
693
|
llm.setup_sub_client("vl_model", vl_model)
|
|
694
694
|
|
|
695
|
+
if args.index_model:
|
|
696
|
+
model_name = args.index_model.strip()
|
|
697
|
+
model_info = models_module.get_model_by_name(model_name)
|
|
698
|
+
index_model = byzerllm.SimpleByzerLLM(default_model_name=model_name)
|
|
699
|
+
index_model.deploy(
|
|
700
|
+
model_path="",
|
|
701
|
+
pretrained_model_type="saas/openai",
|
|
702
|
+
udf_name=model_name,
|
|
703
|
+
infer_params={
|
|
704
|
+
"saas.base_url": model_info["base_url"],
|
|
705
|
+
"saas.api_key": model_info["api_key"],
|
|
706
|
+
"saas.model": model_info["model_name"],
|
|
707
|
+
"saas.is_reasoning": model_info["is_reasoning"]
|
|
708
|
+
}
|
|
709
|
+
)
|
|
710
|
+
llm.setup_sub_client("index_model", index_model)
|
|
711
|
+
|
|
695
712
|
if args.sd_model:
|
|
696
713
|
model_name = args.sd_model.strip()
|
|
697
714
|
model_info = models_module.get_model_by_name(model_name)
|
|
@@ -1605,8 +1605,8 @@ def code_next(query: str):
|
|
|
1605
1605
|
if os.path.exists(temp_yaml):
|
|
1606
1606
|
os.remove(temp_yaml)
|
|
1607
1607
|
|
|
1608
|
-
|
|
1609
|
-
|
|
1608
|
+
product_mode = conf.get("product_mode", "lite")
|
|
1609
|
+
llm = get_single_llm(args.chat_model or args.model, product_mode=product_mode)
|
|
1610
1610
|
|
|
1611
1611
|
auto_guesser = AutoGuessQuery(
|
|
1612
1612
|
llm=llm, project_dir=os.getcwd(), skip_diff=True)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import locale
|
|
2
|
+
from byzerllm.utils import format_str_jinja2
|
|
2
3
|
|
|
3
4
|
MESSAGES = {
|
|
4
5
|
"en": {
|
|
@@ -236,3 +237,7 @@ def get_system_language():
|
|
|
236
237
|
def get_message(key):
|
|
237
238
|
lang = get_system_language()
|
|
238
239
|
return MESSAGES.get(lang, MESSAGES['en']).get(key, MESSAGES['en'][key])
|
|
240
|
+
|
|
241
|
+
|
|
242
|
+
def get_message_with_format(msg_key: str, **kwargs):
|
|
243
|
+
return format_str_jinja2(get_message(msg_key), **kwargs)
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import locale
|
|
2
|
+
from byzerllm.utils import format_str_jinja2
|
|
2
3
|
|
|
3
4
|
MESSAGES = {
|
|
4
|
-
"en": {
|
|
5
|
+
"en": {
|
|
6
|
+
"model_not_found": "Model {{model_name}} not found",
|
|
5
7
|
"new_session_started": "New session started. Previous chat history has been archived.",
|
|
6
8
|
"memory_save_success": "✅ Saved to your memory",
|
|
9
|
+
"file_decode_error": "Failed to decode file: {{file_path}}. Tried encodings: {{encodings}}",
|
|
10
|
+
"file_write_error": "Failed to write file: {{file_path}}. Error: {{error}}",
|
|
7
11
|
"index_file_too_large": "⚠️ File {{ file_path }} is too large ({{ file_size }} > {{ max_length }}), splitting into chunks...",
|
|
8
12
|
"index_update_success": "✅ Successfully updated index for {{ file_path }} (md5: {{ md5 }}) in {{ duration }}s",
|
|
9
13
|
"index_build_error": "❌ Error building index for {{ file_path }}: {{ error }}",
|
|
@@ -73,8 +77,11 @@ MESSAGES = {
|
|
|
73
77
|
"git_init_required": "⚠️ auto_merge only applies to git repositories.\n\nPlease try using git init in the source directory:\n\n```shell\ncd {{ source_dir }}\ngit init.\n```\n\nThen run auto - coder again.\nError: {{ error }}"
|
|
74
78
|
},
|
|
75
79
|
"zh": {
|
|
80
|
+
"model_not_found": "未找到模型: {{model_name}}",
|
|
76
81
|
"new_session_started": "新会话已开始。之前的聊天历史已存档。",
|
|
77
82
|
"memory_save_success": "✅ 已保存到您的记忆中",
|
|
83
|
+
"file_decode_error": "无法解码文件: {{file_path}}。尝试的编码: {{encodings}}",
|
|
84
|
+
"file_write_error": "无法写入文件: {{file_path}}. 错误: {{error}}",
|
|
78
85
|
"index_file_too_large": "⚠️ 文件 {{ file_path }} 过大 ({{ file_size }} > {{ max_length }}), 正在分块处理...",
|
|
79
86
|
"index_update_success": "✅ 成功更新 {{ file_path }} 的索引 (md5: {{ md5 }}), 耗时 {{ duration }} 秒",
|
|
80
87
|
"index_build_error": "❌ 构建 {{ file_path }} 索引时出错: {{ error }}",
|
|
@@ -156,3 +163,6 @@ def get_system_language():
|
|
|
156
163
|
def get_message(key):
|
|
157
164
|
lang = get_system_language()
|
|
158
165
|
return MESSAGES.get(lang, MESSAGES['en']).get(key, MESSAGES['en'][key])
|
|
166
|
+
|
|
167
|
+
def get_message_with_format(msg_key: str, **kwargs):
|
|
168
|
+
return format_str_jinja2(get_message(msg_key), **kwargs)
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from autocoder.common.auto_coder_lang import get_message_with_format
|
|
2
|
+
from typing import List, Dict, Union
|
|
3
|
+
|
|
4
|
+
def read_file(file_path):
|
|
5
|
+
"""Read a file with automatic encoding detection.
|
|
6
|
+
|
|
7
|
+
Tries common encodings in sequence (UTF-8 > GBK > UTF-16 > Latin-1) to handle
|
|
8
|
+
cross-platform encoding issues between Windows and Linux systems.
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
file_path (str): Path to the file to read
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
str: The file contents as a string
|
|
15
|
+
|
|
16
|
+
Raises:
|
|
17
|
+
ValueError: If the file cannot be decoded with any of the tried encodings
|
|
18
|
+
"""
|
|
19
|
+
encodings = ['utf-8', 'gbk', 'utf-16', 'latin-1']
|
|
20
|
+
|
|
21
|
+
for encoding in encodings:
|
|
22
|
+
try:
|
|
23
|
+
with open(file_path, 'r', encoding=encoding) as f:
|
|
24
|
+
content = f.read()
|
|
25
|
+
return content
|
|
26
|
+
except UnicodeDecodeError:
|
|
27
|
+
continue
|
|
28
|
+
|
|
29
|
+
raise ValueError(get_message_with_format("file_decode_error",
|
|
30
|
+
file_path=file_path,
|
|
31
|
+
encodings=", ".join(encodings)))
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def save_file(file_path: str, content: Union[str, List[str]]) -> None:
|
|
36
|
+
"""Save content to a file using UTF-8 encoding.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
file_path (str): Path to the file to write
|
|
40
|
+
content (Union[str, List[str]]): Content to write to the file.
|
|
41
|
+
Can be a string or list of strings (will be joined with newlines)
|
|
42
|
+
|
|
43
|
+
Raises:
|
|
44
|
+
IOError: If the file cannot be written
|
|
45
|
+
TypeError: If content is neither str nor List[str]
|
|
46
|
+
"""
|
|
47
|
+
try:
|
|
48
|
+
with open(file_path, 'w', encoding='utf-8') as f:
|
|
49
|
+
if isinstance(content, str):
|
|
50
|
+
f.write(content)
|
|
51
|
+
elif isinstance(content, list):
|
|
52
|
+
f.write('\n'.join(content))
|
|
53
|
+
else:
|
|
54
|
+
raise TypeError("Content must be either str or List[str]")
|
|
55
|
+
except IOError as e:
|
|
56
|
+
raise IOError(get_message_with_format("file_write_error",
|
|
57
|
+
file_path=file_path,
|
|
58
|
+
error=str(e)))
|
|
@@ -36,6 +36,22 @@ default_models_list = [
|
|
|
36
36
|
}
|
|
37
37
|
]
|
|
38
38
|
|
|
39
|
+
def process_api_key_path(base_url: str) -> str:
|
|
40
|
+
"""
|
|
41
|
+
从 base_url 中提取 host 部分并处理特殊字符
|
|
42
|
+
例如: https://api.example.com:8080/v1 -> api.example.com_8080
|
|
43
|
+
"""
|
|
44
|
+
if not base_url:
|
|
45
|
+
return ""
|
|
46
|
+
|
|
47
|
+
parsed = urlparse(base_url)
|
|
48
|
+
host = parsed.netloc
|
|
49
|
+
|
|
50
|
+
# 将冒号替换为下划线
|
|
51
|
+
host = host.replace(":", "_")
|
|
52
|
+
|
|
53
|
+
return host
|
|
54
|
+
|
|
39
55
|
def load_models() -> List[Dict]:
|
|
40
56
|
"""
|
|
41
57
|
Load models from ~/.auto-coder/keys/models.json and merge with default_models_list.
|
|
@@ -73,7 +89,7 @@ def load_models() -> List[Dict]:
|
|
|
73
89
|
api_key_file = os.path.join(api_key_dir, model["api_key_path"])
|
|
74
90
|
if os.path.exists(api_key_file):
|
|
75
91
|
with open(api_key_file, "r") as f:
|
|
76
|
-
model["api_key"] = f.read()
|
|
92
|
+
model["api_key"] = f.read()
|
|
77
93
|
return target_models
|
|
78
94
|
|
|
79
95
|
def save_models(models: List[Dict]) -> None:
|
|
@@ -85,22 +101,6 @@ def save_models(models: List[Dict]) -> None:
|
|
|
85
101
|
json.dump(models, f, indent=2, ensure_ascii=False)
|
|
86
102
|
|
|
87
103
|
|
|
88
|
-
def process_api_key_path(base_url: str) -> str:
|
|
89
|
-
"""
|
|
90
|
-
从 base_url 中提取 host 部分并处理特殊字符
|
|
91
|
-
例如: https://api.example.com:8080/v1 -> api.example.com_8080
|
|
92
|
-
"""
|
|
93
|
-
if not base_url:
|
|
94
|
-
return ""
|
|
95
|
-
|
|
96
|
-
parsed = urlparse(base_url)
|
|
97
|
-
host = parsed.netloc
|
|
98
|
-
|
|
99
|
-
# 将冒号替换为下划线
|
|
100
|
-
host = host.replace(":", "_")
|
|
101
|
-
|
|
102
|
-
return host
|
|
103
|
-
|
|
104
104
|
def get_model_by_name(name: str) -> Dict:
|
|
105
105
|
"""
|
|
106
106
|
根据模型名称查找模型
|
|
@@ -109,7 +109,8 @@ def get_model_by_name(name: str) -> Dict:
|
|
|
109
109
|
v = [m for m in models if m["name"] == name.strip()]
|
|
110
110
|
|
|
111
111
|
if len(v) == 0:
|
|
112
|
-
|
|
112
|
+
from autocoder.common.auto_coder_lang import get_message_with_format
|
|
113
|
+
raise Exception(get_message_with_format("model_not_found", model_name=name))
|
|
113
114
|
return v[0]
|
|
114
115
|
|
|
115
116
|
def update_model_with_api_key(name: str, api_key: str) -> Dict:
|
|
@@ -135,9 +136,8 @@ def update_model_with_api_key(name: str, api_key: str) -> Dict:
|
|
|
135
136
|
|
|
136
137
|
if not found_model:
|
|
137
138
|
return None
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
api_key_path = process_api_key_path(found_model["base_url"])
|
|
139
|
+
|
|
140
|
+
api_key_path = name
|
|
141
141
|
if api_key_path:
|
|
142
142
|
found_model["api_key_path"] = api_key_path
|
|
143
143
|
|
|
@@ -36,9 +36,8 @@ class SuffixProject:
|
|
|
36
36
|
self.target_file = args.target_file
|
|
37
37
|
self.project_type = args.project_type
|
|
38
38
|
self.suffixs = [
|
|
39
|
-
|
|
40
|
-
for suffix in self.project_type.split(",")
|
|
41
|
-
if suffix.strip() != ""
|
|
39
|
+
suffix.strip() if suffix.startswith(".") else f".{suffix.strip()}"
|
|
40
|
+
for suffix in self.project_type.split(",") if suffix.strip()
|
|
42
41
|
]
|
|
43
42
|
self.file_filter = file_filter
|
|
44
43
|
self.sources = []
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
from rich.console import Console
|
|
2
|
+
from rich.live import Live
|
|
3
|
+
from rich.panel import Panel
|
|
4
|
+
from rich.markdown import Markdown
|
|
5
|
+
from rich.layout import Layout
|
|
6
|
+
from threading import Thread, Lock
|
|
7
|
+
from queue import Queue, Empty
|
|
8
|
+
from typing import Generator, List, Dict, Any, Optional, Tuple, Literal
|
|
9
|
+
from autocoder.utils.request_queue import RequestValue, RequestOption, StreamValue
|
|
10
|
+
from autocoder.utils.request_queue import request_queue
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
MAX_HISTORY_LINES = 40 # 最大保留历史行数
|
|
14
|
+
|
|
15
|
+
class StreamRenderer:
|
|
16
|
+
def __init__(self, title: str):
|
|
17
|
+
self.title = title
|
|
18
|
+
self.content = ""
|
|
19
|
+
self.lock = Lock()
|
|
20
|
+
self.is_complete = False
|
|
21
|
+
|
|
22
|
+
def update(self, content: str):
|
|
23
|
+
with self.lock:
|
|
24
|
+
self.content += content
|
|
25
|
+
|
|
26
|
+
def get_content(self) -> str:
|
|
27
|
+
with self.lock:
|
|
28
|
+
return self.content
|
|
29
|
+
|
|
30
|
+
def complete(self):
|
|
31
|
+
with self.lock:
|
|
32
|
+
self.is_complete = True
|
|
33
|
+
|
|
34
|
+
class MultiStreamRenderer:
|
|
35
|
+
def __init__(self, stream_titles: List[str], layout: str = "horizontal", console: Optional[Console] = None):
|
|
36
|
+
"""
|
|
37
|
+
Initialize multi-stream renderer
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
stream_titles: List of titles for each stream
|
|
41
|
+
layout: "horizontal" or "vertical"
|
|
42
|
+
console: Rich console instance
|
|
43
|
+
"""
|
|
44
|
+
if console is None:
|
|
45
|
+
console = Console(force_terminal=True, color_system="auto")
|
|
46
|
+
|
|
47
|
+
self.console = console
|
|
48
|
+
self.layout_type = layout
|
|
49
|
+
self.streams = [StreamRenderer(title) for title in stream_titles]
|
|
50
|
+
self.layout = Layout()
|
|
51
|
+
|
|
52
|
+
# Create named layouts for each stream
|
|
53
|
+
self.stream_layouts = [Layout(name=f"stream{i}") for i in range(len(stream_titles))]
|
|
54
|
+
|
|
55
|
+
# Configure layout
|
|
56
|
+
if layout == "horizontal":
|
|
57
|
+
self.layout.split_row(*self.stream_layouts)
|
|
58
|
+
else:
|
|
59
|
+
self.layout.split_column(*self.stream_layouts)
|
|
60
|
+
|
|
61
|
+
def _process_stream(self,
|
|
62
|
+
stream_idx: int,
|
|
63
|
+
stream_generator: Generator[Tuple[str, Dict[str, Any]], None, None]):
|
|
64
|
+
"""Process a single stream in a separate thread"""
|
|
65
|
+
stream = self.streams[stream_idx]
|
|
66
|
+
try:
|
|
67
|
+
for content, meta in stream_generator:
|
|
68
|
+
if content:
|
|
69
|
+
stream.update(content)
|
|
70
|
+
finally:
|
|
71
|
+
stream.complete()
|
|
72
|
+
|
|
73
|
+
def render_streams(self,
|
|
74
|
+
stream_generators: List[Generator[Tuple[str, Dict[str, Any]], None, None]]) -> List[str]:
|
|
75
|
+
"""
|
|
76
|
+
Render multiple streams simultaneously
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
stream_generators: List of stream generators to render
|
|
80
|
+
|
|
81
|
+
Returns:
|
|
82
|
+
List of final content from each stream
|
|
83
|
+
"""
|
|
84
|
+
assert len(stream_generators) == len(self.streams), "Number of generators must match number of streams"
|
|
85
|
+
|
|
86
|
+
# Start processing threads
|
|
87
|
+
threads = []
|
|
88
|
+
for i, generator in enumerate(stream_generators):
|
|
89
|
+
thread = Thread(target=self._process_stream, args=(i, generator))
|
|
90
|
+
thread.daemon = True
|
|
91
|
+
thread.start()
|
|
92
|
+
threads.append(thread)
|
|
93
|
+
|
|
94
|
+
try:
|
|
95
|
+
with Live(self.layout, console=self.console, refresh_per_second=10) as live:
|
|
96
|
+
while any(not stream.is_complete for stream in self.streams):
|
|
97
|
+
# Update all panels
|
|
98
|
+
for i, stream in enumerate(self.streams):
|
|
99
|
+
panel = Panel(
|
|
100
|
+
Markdown(stream.get_content() or "Waiting..."),
|
|
101
|
+
title=stream.title,
|
|
102
|
+
border_style="green" if not stream.is_complete else "blue"
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
# Update appropriate layout section
|
|
106
|
+
self.stream_layouts[i].update(panel)
|
|
107
|
+
|
|
108
|
+
time.sleep(0.1) # Prevent excessive CPU usage
|
|
109
|
+
|
|
110
|
+
except KeyboardInterrupt:
|
|
111
|
+
print("\nStopping streams...")
|
|
112
|
+
|
|
113
|
+
# Wait for all threads to complete
|
|
114
|
+
for thread in threads:
|
|
115
|
+
thread.join()
|
|
116
|
+
|
|
117
|
+
return [stream.get_content() for stream in self.streams]
|
|
118
|
+
|
|
119
|
+
def multi_stream_out(
|
|
120
|
+
stream_generators: List[Generator[Tuple[str, Dict[str, Any]], None, None]],
|
|
121
|
+
titles: List[str],
|
|
122
|
+
layout: str = "horizontal",
|
|
123
|
+
console: Optional[Console] = None
|
|
124
|
+
) -> List[str]:
|
|
125
|
+
"""
|
|
126
|
+
Render multiple streams with Rich
|
|
127
|
+
|
|
128
|
+
Args:
|
|
129
|
+
stream_generators: List of stream generators
|
|
130
|
+
titles: List of titles for each stream
|
|
131
|
+
layout: "horizontal" or "vertical"
|
|
132
|
+
console: Optional Rich console instance
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
List of final content from each stream
|
|
136
|
+
"""
|
|
137
|
+
renderer = MultiStreamRenderer(titles, layout, console)
|
|
138
|
+
return renderer.render_streams(stream_generators)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def stream_out(
|
|
142
|
+
stream_generator: Generator[Tuple[str, Dict[str, Any]], None, None],
|
|
143
|
+
request_id: Optional[str] = None,
|
|
144
|
+
console: Optional[Console] = None
|
|
145
|
+
) -> Tuple[str, Optional[Dict[str, Any]]]:
|
|
146
|
+
"""
|
|
147
|
+
处理流式输出事件并在终端中展示
|
|
148
|
+
|
|
149
|
+
Args:
|
|
150
|
+
stream_generator: 生成流式输出的生成器
|
|
151
|
+
request_id: 请求ID,用于更新请求队列
|
|
152
|
+
console: Rich Console对象
|
|
153
|
+
|
|
154
|
+
Returns:
|
|
155
|
+
Tuple[str, Dict[str, Any]]: 返回完整的响应内容和最后的元数据
|
|
156
|
+
"""
|
|
157
|
+
if console is None:
|
|
158
|
+
console = Console(force_terminal=True, color_system="auto", height=None)
|
|
159
|
+
|
|
160
|
+
lines_buffer = [] # 存储历史行
|
|
161
|
+
current_line = "" # 当前行
|
|
162
|
+
assistant_response = ""
|
|
163
|
+
last_meta = None
|
|
164
|
+
|
|
165
|
+
try:
|
|
166
|
+
with Live(
|
|
167
|
+
Panel("", title="Response", border_style="green"),
|
|
168
|
+
refresh_per_second=4,
|
|
169
|
+
console=console
|
|
170
|
+
) as live:
|
|
171
|
+
for res in stream_generator:
|
|
172
|
+
last_meta = res[1]
|
|
173
|
+
content = res[0]
|
|
174
|
+
reasoning_content = last_meta.reasoning_content
|
|
175
|
+
|
|
176
|
+
if reasoning_content == "" and content == "":
|
|
177
|
+
continue
|
|
178
|
+
|
|
179
|
+
assistant_response += content
|
|
180
|
+
|
|
181
|
+
display_delta = reasoning_content if reasoning_content else content
|
|
182
|
+
|
|
183
|
+
# 处理所有行
|
|
184
|
+
parts = (current_line + display_delta).split("\n")
|
|
185
|
+
|
|
186
|
+
# 最后一部分是未完成的新行
|
|
187
|
+
if len(parts) > 1:
|
|
188
|
+
# 将完整行加入缓冲区
|
|
189
|
+
lines_buffer.extend(parts[:-1])
|
|
190
|
+
# 保留最大行数限制
|
|
191
|
+
if len(lines_buffer) > MAX_HISTORY_LINES:
|
|
192
|
+
del lines_buffer[0:len(lines_buffer) - MAX_HISTORY_LINES]
|
|
193
|
+
|
|
194
|
+
# 更新当前行
|
|
195
|
+
current_line = parts[-1]
|
|
196
|
+
|
|
197
|
+
# 构建显示内容 = 历史行 + 当前行
|
|
198
|
+
display_content = "\n".join(lines_buffer[-MAX_HISTORY_LINES:] + [current_line])
|
|
199
|
+
|
|
200
|
+
if request_id and request_queue:
|
|
201
|
+
request_queue.add_request(
|
|
202
|
+
request_id,
|
|
203
|
+
RequestValue(
|
|
204
|
+
value=StreamValue(value=[content]),
|
|
205
|
+
status=RequestOption.RUNNING,
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
live.update(
|
|
210
|
+
Panel(
|
|
211
|
+
Markdown(display_content),
|
|
212
|
+
title="Response",
|
|
213
|
+
border_style="green",
|
|
214
|
+
height=min(50, live.console.height - 4)
|
|
215
|
+
)
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
# 处理最后一行的内容
|
|
219
|
+
if current_line:
|
|
220
|
+
lines_buffer.append(current_line)
|
|
221
|
+
|
|
222
|
+
# 最终显示结果
|
|
223
|
+
live.update(
|
|
224
|
+
Panel(
|
|
225
|
+
Markdown(assistant_response),
|
|
226
|
+
title="Final Response",
|
|
227
|
+
border_style="blue"
|
|
228
|
+
)
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
except Exception as e:
|
|
232
|
+
console.print(Panel(
|
|
233
|
+
f"Error: {str(e)}",
|
|
234
|
+
title="Error",
|
|
235
|
+
border_style="red"
|
|
236
|
+
))
|
|
237
|
+
|
|
238
|
+
if request_id and request_queue:
|
|
239
|
+
request_queue.add_request(
|
|
240
|
+
request_id,
|
|
241
|
+
RequestValue(
|
|
242
|
+
value=StreamValue(value=[str(e)]),
|
|
243
|
+
status=RequestOption.FAILED
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
finally:
|
|
248
|
+
if request_id and request_queue:
|
|
249
|
+
request_queue.add_request(
|
|
250
|
+
request_id,
|
|
251
|
+
RequestValue(
|
|
252
|
+
value=StreamValue(value=[""]),
|
|
253
|
+
status=RequestOption.COMPLETED
|
|
254
|
+
),
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
return assistant_response, last_meta
|