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.

Files changed (161) hide show
  1. {auto_coder-0.1.243 → auto_coder-0.1.244}/PKG-INFO +2 -2
  2. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/PKG-INFO +2 -2
  3. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/requires.txt +1 -1
  4. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder.py +17 -0
  5. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat_auto_coder.py +2 -2
  6. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat_auto_coder_lang.py +5 -0
  7. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/auto_coder_lang.py +11 -1
  8. auto_coder-0.1.244/src/autocoder/common/files.py +58 -0
  9. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/index.py +1 -0
  10. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/models.py +21 -21
  11. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/suffixproject/__init__.py +2 -3
  12. auto_coder-0.1.244/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +257 -0
  13. auto_coder-0.1.244/src/autocoder/utils/rest.py +142 -0
  14. auto_coder-0.1.244/src/autocoder/version.py +1 -0
  15. auto_coder-0.1.243/src/autocoder/common/files.py +0 -26
  16. auto_coder-0.1.243/src/autocoder/utils/auto_coder_utils/chat_stream_out.py +0 -381
  17. auto_coder-0.1.243/src/autocoder/utils/rest.py +0 -190
  18. auto_coder-0.1.243/src/autocoder/version.py +0 -1
  19. {auto_coder-0.1.243 → auto_coder-0.1.244}/LICENSE +0 -0
  20. {auto_coder-0.1.243 → auto_coder-0.1.244}/README.md +0 -0
  21. {auto_coder-0.1.243 → auto_coder-0.1.244}/setup.cfg +0 -0
  22. {auto_coder-0.1.243 → auto_coder-0.1.244}/setup.py +0 -0
  23. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/SOURCES.txt +0 -0
  24. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/dependency_links.txt +0 -0
  25. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/entry_points.txt +0 -0
  26. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/auto_coder.egg-info/top_level.txt +0 -0
  27. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/__init__.py +0 -0
  28. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/__init__.py +0 -0
  29. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_demand_organizer.py +0 -0
  30. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_filegroup.py +0 -0
  31. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_guess_query.py +0 -0
  32. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/auto_tool.py +0 -0
  33. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/coder.py +0 -0
  34. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/designer.py +0 -0
  35. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/planner.py +0 -0
  36. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/agent/project_reader.py +0 -0
  37. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag.py +0 -0
  38. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag_client_mcp.py +0 -0
  39. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_rag_mcp.py +0 -0
  40. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/auto_coder_server.py +0 -0
  41. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/benchmark.py +0 -0
  42. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/chat/__init__.py +0 -0
  43. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/command_args.py +0 -0
  44. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/JupyterClient.py +0 -0
  45. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/ShellClient.py +0 -0
  46. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/__init__.py +0 -0
  47. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/anything2images.py +0 -0
  48. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/anything2img.py +0 -0
  49. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/audio.py +0 -0
  50. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/buildin_tokenizer.py +0 -0
  51. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/chunk_validation.py +0 -0
  52. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/cleaner.py +0 -0
  53. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_execute.py +0 -0
  54. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate.py +0 -0
  55. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_diff.py +0 -0
  56. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
  57. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
  58. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge.py +0 -0
  59. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_diff.py +0 -0
  60. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
  61. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
  62. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/code_modification_ranker.py +0 -0
  63. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_completer.py +0 -0
  64. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_generator.py +0 -0
  65. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/command_templates.py +0 -0
  66. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/const.py +0 -0
  67. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/git_utils.py +0 -0
  68. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/image_to_page.py +0 -0
  69. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/interpreter.py +0 -0
  70. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/llm_rerank.py +0 -0
  71. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_hub.py +0 -0
  72. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_server.py +0 -0
  73. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_servers/__init__.py +0 -0
  74. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_servers/mcp_server_perplexity.py +0 -0
  75. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/mcp_tools.py +0 -0
  76. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/memory_manager.py +0 -0
  77. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/printer.py +0 -0
  78. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/recall_validation.py +0 -0
  79. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/screenshots.py +0 -0
  80. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/search.py +0 -0
  81. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/search_replace.py +0 -0
  82. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/sys_prompt.py +0 -0
  83. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/text.py +0 -0
  84. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/types.py +0 -0
  85. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/common/utils_code_auto_generate.py +0 -0
  86. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/data/tokenizer.json +0 -0
  87. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/db/__init__.py +0 -0
  88. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/db/store.py +0 -0
  89. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/__init__.py +0 -0
  90. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/__init__.py +0 -0
  91. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/action.py +0 -0
  92. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/copilot.py +0 -0
  93. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
  94. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
  95. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
  96. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/__init__.py +0 -0
  97. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/entry.py +0 -0
  98. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/__init__.py +0 -0
  99. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/normal_filter.py +0 -0
  100. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/filter/quick_filter.py +0 -0
  101. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/for_command.py +0 -0
  102. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/symbols_utils.py +0 -0
  103. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/index/types.py +0 -0
  104. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/lang.py +0 -0
  105. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/pyproject/__init__.py +0 -0
  106. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/__init__.py +0 -0
  107. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/api_server.py +0 -0
  108. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/__init__.py +0 -0
  109. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/base_cache.py +0 -0
  110. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/byzer_storage_cache.py +0 -0
  111. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/file_monitor_cache.py +0 -0
  112. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/cache/simple_cache.py +0 -0
  113. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/doc_filter.py +0 -0
  114. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/document_retriever.py +0 -0
  115. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/llm_wrapper.py +0 -0
  116. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/__init__.py +0 -0
  117. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/docx_loader.py +0 -0
  118. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/excel_loader.py +0 -0
  119. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
  120. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
  121. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/long_context_rag.py +0 -0
  122. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/rag_config.py +0 -0
  123. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/rag_entry.py +0 -0
  124. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/raw_rag.py +0 -0
  125. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/relevant_utils.py +0 -0
  126. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/simple_directory_reader.py +0 -0
  127. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/simple_rag.py +0 -0
  128. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/__init__.py +0 -0
  129. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/event_writer.py +0 -0
  130. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/stream_event/types.py +0 -0
  131. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_checker.py +0 -0
  132. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_counter.py +0 -0
  133. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/token_limiter.py +0 -0
  134. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/types.py +0 -0
  135. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/utils.py +0 -0
  136. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/rag/variable_holder.py +0 -0
  137. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/regexproject/__init__.py +0 -0
  138. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/tsproject/__init__.py +0 -0
  139. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/__init__.py +0 -0
  140. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/_markitdown.py +0 -0
  141. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/auto_coder_utils/__init__.py +0 -0
  142. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/chat_auto_coder_utils/__init__.py +0 -0
  143. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/conversation_store.py +0 -0
  144. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/llm_client_interceptors.py +0 -0
  145. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/llms.py +0 -0
  146. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/log_capture.py +0 -0
  147. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/multi_turn.py +0 -0
  148. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/operate_config_api.py +0 -0
  149. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/print_table.py +0 -0
  150. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/queue_communicate.py +0 -0
  151. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/request_event_queue.py +0 -0
  152. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/request_queue.py +0 -0
  153. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/tests.py +0 -0
  154. {auto_coder-0.1.243 → auto_coder-0.1.244}/src/autocoder/utils/types.py +0 -0
  155. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_action_regex_project.py +0 -0
  156. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_chat_auto_coder.py +0 -0
  157. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_code_auto_merge_editblock.py +0 -0
  158. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_command_completer.py +0 -0
  159. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_planner.py +0 -0
  160. {auto_coder-0.1.243 → auto_coder-0.1.244}/tests/test_queue_communicate.py +0 -0
  161. {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.243
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.159
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.243
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.159
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
@@ -16,7 +16,7 @@ tabulate
16
16
  jupyter_client
17
17
  prompt-toolkit
18
18
  tokenizers
19
- byzerllm[saas]>=0.1.159
19
+ byzerllm[saas]>=0.1.160
20
20
  patch
21
21
  diff_match_patch
22
22
  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
- llm = byzerllm.ByzerLLM.from_default_model(
1609
- args.inference_model or args.model)
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)))
@@ -130,6 +130,7 @@ class IndexManager:
130
130
  如果有符号,按如下格式返回:
131
131
 
132
132
  ```
133
+ 用途:主要用于提供自动实现函数模板的功能。
133
134
  {符号类型}: {符号名称}, {符号名称}, ...
134
135
  ```
135
136
 
@@ -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
- raise Exception(f"Model {name} not found")
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
- # base_url 中提取并处理 host
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
- f".{suffix.strip()}" if not suffix.startswith(".") else suffix.strip()
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