auto-coder 0.1.183__tar.gz → 0.1.185__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 (121) hide show
  1. {auto_coder-0.1.183 → auto_coder-0.1.185}/PKG-INFO +2 -2
  2. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/PKG-INFO +2 -2
  3. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/SOURCES.txt +6 -0
  4. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/requires.txt +1 -1
  5. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/auto_coder.py +138 -17
  6. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/auto_coder_lang.py +14 -2
  7. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/auto_coder_rag.py +92 -1
  8. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/chat_auto_coder.py +25 -32
  9. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/__init__.py +2 -0
  10. auto_coder-0.1.185/src/autocoder/rag/cache/base_cache.py +14 -0
  11. auto_coder-0.1.185/src/autocoder/rag/cache/byzer_storage_cache.py +394 -0
  12. auto_coder-0.1.185/src/autocoder/rag/cache/file_monitor_cache.py +146 -0
  13. auto_coder-0.1.185/src/autocoder/rag/cache/simple_cache.py +204 -0
  14. auto_coder-0.1.185/src/autocoder/rag/document_retriever.py +238 -0
  15. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/long_context_rag.py +16 -6
  16. auto_coder-0.1.185/src/autocoder/rag/types.py +0 -0
  17. auto_coder-0.1.185/src/autocoder/rag/utils.py +133 -0
  18. auto_coder-0.1.185/src/autocoder/version.py +1 -0
  19. auto_coder-0.1.183/src/autocoder/rag/document_retriever.py +0 -657
  20. auto_coder-0.1.183/src/autocoder/version.py +0 -1
  21. {auto_coder-0.1.183 → auto_coder-0.1.185}/LICENSE +0 -0
  22. {auto_coder-0.1.183 → auto_coder-0.1.185}/README.md +0 -0
  23. {auto_coder-0.1.183 → auto_coder-0.1.185}/setup.cfg +0 -0
  24. {auto_coder-0.1.183 → auto_coder-0.1.185}/setup.py +0 -0
  25. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/dependency_links.txt +0 -0
  26. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/entry_points.txt +0 -0
  27. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/auto_coder.egg-info/top_level.txt +0 -0
  28. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/__init__.py +0 -0
  29. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/__init__.py +0 -0
  30. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/auto_tool.py +0 -0
  31. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/coder.py +0 -0
  32. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/designer.py +0 -0
  33. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/planner.py +0 -0
  34. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/agent/project_reader.py +0 -0
  35. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/auto_coder_server.py +0 -0
  36. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/chat/__init__.py +0 -0
  37. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/chat_auto_coder_lang.py +0 -0
  38. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/command_args.py +0 -0
  39. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/JupyterClient.py +0 -0
  40. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/ShellClient.py +0 -0
  41. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/anything2images.py +0 -0
  42. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/audio.py +0 -0
  43. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/cleaner.py +0 -0
  44. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_execute.py +0 -0
  45. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_generate.py +0 -0
  46. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_generate_diff.py +0 -0
  47. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
  48. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
  49. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_merge.py +0 -0
  50. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_merge_diff.py +0 -0
  51. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
  52. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
  53. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/command_completer.py +0 -0
  54. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/command_generator.py +0 -0
  55. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/command_templates.py +0 -0
  56. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/const.py +0 -0
  57. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/git_utils.py +0 -0
  58. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/image_to_page.py +0 -0
  59. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/interpreter.py +0 -0
  60. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/llm_rerank.py +0 -0
  61. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/screenshots.py +0 -0
  62. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/search.py +0 -0
  63. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/search_replace.py +0 -0
  64. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/text.py +0 -0
  65. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/common/types.py +0 -0
  66. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/db/__init__.py +0 -0
  67. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/db/store.py +0 -0
  68. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/__init__.py +0 -0
  69. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/__init__.py +0 -0
  70. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/action.py +0 -0
  71. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/copilot.py +0 -0
  72. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
  73. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
  74. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
  75. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/index/__init__.py +0 -0
  76. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/index/for_command.py +0 -0
  77. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/index/index.py +0 -0
  78. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/index/symbols_utils.py +0 -0
  79. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/lang.py +0 -0
  80. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/pyproject/__init__.py +0 -0
  81. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/__init__.py +0 -0
  82. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/api_server.py +0 -0
  83. /auto_coder-0.1.183/src/autocoder/rag/types.py → /auto_coder-0.1.185/src/autocoder/rag/cache/__init__.py +0 -0
  84. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/doc_filter.py +0 -0
  85. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/llm_wrapper.py +0 -0
  86. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/loaders/__init__.py +0 -0
  87. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/loaders/docx_loader.py +0 -0
  88. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/loaders/excel_loader.py +0 -0
  89. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
  90. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
  91. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/rag_config.py +0 -0
  92. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/rag_entry.py +0 -0
  93. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/raw_rag.py +0 -0
  94. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/relevant_utils.py +0 -0
  95. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/simple_directory_reader.py +0 -0
  96. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/simple_rag.py +0 -0
  97. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/token_checker.py +0 -0
  98. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/token_counter.py +0 -0
  99. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/token_limiter.py +0 -0
  100. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/rag/variable_holder.py +0 -0
  101. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/regexproject/__init__.py +0 -0
  102. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/suffixproject/__init__.py +0 -0
  103. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/tsproject/__init__.py +0 -0
  104. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/__init__.py +0 -0
  105. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/conversation_store.py +0 -0
  106. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/llm_client_interceptors.py +0 -0
  107. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/log_capture.py +0 -0
  108. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/multi_turn.py +0 -0
  109. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/print_table.py +0 -0
  110. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/queue_communicate.py +0 -0
  111. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/request_event_queue.py +0 -0
  112. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/request_queue.py +0 -0
  113. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/rest.py +0 -0
  114. {auto_coder-0.1.183 → auto_coder-0.1.185}/src/autocoder/utils/tests.py +0 -0
  115. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_action_regex_project.py +0 -0
  116. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_chat_auto_coder.py +0 -0
  117. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_code_auto_merge_editblock.py +0 -0
  118. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_command_completer.py +0 -0
  119. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_planner.py +0 -0
  120. {auto_coder-0.1.183 → auto_coder-0.1.185}/tests/test_queue_communicate.py +0 -0
  121. {auto_coder-0.1.183 → auto_coder-0.1.185}/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.183
3
+ Version: 0.1.185
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.136
29
+ Requires-Dist: byzerllm[saas]>=0.1.137
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.183
3
+ Version: 0.1.185
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.136
29
+ Requires-Dist: byzerllm[saas]>=0.1.137
30
30
  Requires-Dist: patch
31
31
  Requires-Dist: diff_match_patch
32
32
  Requires-Dist: GitPython
@@ -82,7 +82,13 @@ src/autocoder/rag/token_checker.py
82
82
  src/autocoder/rag/token_counter.py
83
83
  src/autocoder/rag/token_limiter.py
84
84
  src/autocoder/rag/types.py
85
+ src/autocoder/rag/utils.py
85
86
  src/autocoder/rag/variable_holder.py
87
+ src/autocoder/rag/cache/__init__.py
88
+ src/autocoder/rag/cache/base_cache.py
89
+ src/autocoder/rag/cache/byzer_storage_cache.py
90
+ src/autocoder/rag/cache/file_monitor_cache.py
91
+ src/autocoder/rag/cache/simple_cache.py
86
92
  src/autocoder/rag/loaders/__init__.py
87
93
  src/autocoder/rag/loaders/docx_loader.py
88
94
  src/autocoder/rag/loaders/excel_loader.py
@@ -16,7 +16,7 @@ tabulate
16
16
  jupyter_client
17
17
  prompt-toolkit
18
18
  tokenizers
19
- byzerllm[saas]>=0.1.136
19
+ byzerllm[saas]>=0.1.137
20
20
  patch
21
21
  diff_match_patch
22
22
  GitPython
@@ -385,7 +385,7 @@ def main(input_args: Optional[List[str]] = None):
385
385
 
386
386
  llm.setup_template(model=args.model, template="auto")
387
387
  llm.setup_default_model_name(args.model)
388
-
388
+
389
389
  llm.setup_max_output_length(args.model, args.model_max_length)
390
390
  llm.setup_max_input_length(args.model, args.model_max_input_length)
391
391
  llm.setup_extra_generation_params(
@@ -395,7 +395,7 @@ def main(input_args: Optional[List[str]] = None):
395
395
  if args.chat_model:
396
396
  chat_model = byzerllm.ByzerLLM()
397
397
  chat_model.setup_default_model_name(args.chat_model)
398
- llm.setup_sub_client("chat_model", chat_model)
398
+ llm.setup_sub_client("chat_model", chat_model)
399
399
 
400
400
  if args.vl_model:
401
401
  vl_model = byzerllm.ByzerLLM()
@@ -642,22 +642,24 @@ def main(input_args: Optional[List[str]] = None):
642
642
  )
643
643
  )
644
644
  return
645
-
645
+
646
646
  elif raw_args.agent_command == "designer":
647
- from autocoder.agent.designer import SVGDesigner, SDDesigner
647
+ from autocoder.agent.designer import SVGDesigner, SDDesigner
648
+
648
649
  if args.agent_designer_mode == "svg":
649
650
  designer = SVGDesigner(args, llm)
650
- designer.run(args.query)
651
+ designer.run(args.query)
651
652
  print("Successfully generated image in output.png")
652
653
  elif args.agent_designer_mode == "sd":
653
654
  designer = SDDesigner(args, llm)
654
- designer.run(args.query)
655
+ designer.run(args.query)
655
656
  print("Successfully generated image in output.jpg")
656
657
  if args.request_id:
657
658
  request_queue.add_request(
658
659
  args.request_id,
659
660
  RequestValue(
660
- value=DefaultValue(value=response), status=RequestOption.COMPLETED
661
+ value=DefaultValue(value="Successfully generated image"),
662
+ status=RequestOption.COMPLETED,
661
663
  ),
662
664
  )
663
665
  return
@@ -693,6 +695,12 @@ def main(input_args: Optional[List[str]] = None):
693
695
  {"role": "user", "content": args.query}
694
696
  )
695
697
 
698
+ if llm.get_sub_client("chat_model"):
699
+ chat_llm = llm.get_sub_client("chat_model")
700
+ else:
701
+ chat_llm = llm
702
+
703
+ source_count = 0
696
704
  pre_conversations = []
697
705
  if args.context:
698
706
  context = json.loads(args.context)
@@ -701,25 +709,138 @@ def main(input_args: Optional[List[str]] = None):
701
709
  pre_conversations.append(
702
710
  {
703
711
  "role": "user",
704
- "content": f"下面是一些文档和源码,如果用户的问题和他们相关,请参考他们:{file_content}",
712
+ "content": f"下面是一些文档和源码,如果用户的问题和他们相关,请参考他们:\n{file_content}",
705
713
  },
706
714
  )
707
715
  pre_conversations.append({"role": "assistant", "content": "read"})
716
+ source_count += 1
708
717
 
709
- loaded_conversations = (
710
- pre_conversations + chat_history["ask_conversation"][-31:]
711
- )
718
+ from autocoder.index.index import IndexManager, build_index_and_filter_files
719
+ from autocoder.pyproject import PyProject
720
+ from autocoder.tsproject import TSProject
721
+ from autocoder.suffixproject import SuffixProject
712
722
 
713
- if llm.get_sub_client("chat_model"):
714
- chat_llm = llm.get_sub_client("chat_model")
723
+ if args.project_type == "ts":
724
+ pp = TSProject(args=args, llm=llm)
725
+ elif args.project_type == "py":
726
+ pp = PyProject(args=args, llm=llm)
715
727
  else:
716
- chat_llm = llm
728
+ pp = SuffixProject(args=args, llm=llm, file_filter=None)
729
+ pp.run()
730
+ sources = pp.sources
731
+ s = build_index_and_filter_files(llm=llm, args=args, sources=sources)
732
+ if s:
733
+ pre_conversations.append(
734
+ {
735
+ "role": "user",
736
+ "content": f"下面是一些文档和源码,如果用户的问题和他们相关,请参考他们:\n{s}",
737
+ }
738
+ )
739
+ pre_conversations.append({"role": "assistant", "content": "read"})
740
+ source_count += 1
741
+
742
+ loaded_conversations = pre_conversations + chat_history["ask_conversation"]
743
+
744
+ if args.human_as_model:
745
+ console = Console()
746
+
747
+ @byzerllm.prompt()
748
+ def chat_with_human_as_model(
749
+ source_codes, pre_conversations, last_conversation
750
+ ):
751
+ """
752
+ {% if source_codes %}
753
+ {{ source_codes }}
754
+ {% endif %}
755
+
756
+ {% if pre_conversations %}
757
+ 下面是我们之间的历史对话,假设我是A,你是B。
758
+ {% for conv in pre_conversations %}
759
+ {{ "A" if conv.role == "user" else "B" }}: {{ conv.content }}
760
+ {% endfor %}
761
+ {% endif %}
762
+
763
+
764
+ 参考上面的文件以及对话,回答用户的问题。
765
+ 用户的问题: {{ last_conversation.content }}
766
+ """
767
+
768
+ source_codes_conversations = loaded_conversations[0 : source_count * 2]
769
+ source_codes = ""
770
+ for conv in source_codes_conversations:
771
+ if conv["role"] == "user":
772
+ source_codes += conv["content"]
773
+
774
+ chat_content = chat_with_human_as_model.prompt(
775
+ source_codes=source_codes,
776
+ pre_conversations=loaded_conversations[source_count * 2 : -1],
777
+ last_conversation=loaded_conversations[-1],
778
+ )
779
+ try:
780
+ import pyperclip
781
+
782
+ pyperclip.copy(chat_content)
783
+ console.print(
784
+ Panel(
785
+ get_message("chat_human_as_model_instructions"),
786
+ title="Instructions",
787
+ border_style="blue",
788
+ expand=False,
789
+ )
790
+ )
791
+ except Exception:
792
+ logger.warning(get_message("clipboard_not_supported"))
793
+ console.print(
794
+ Panel(
795
+ get_message("human_as_model_instructions_no_clipboard"),
796
+ title="Instructions",
797
+ border_style="blue",
798
+ expand=False,
799
+ )
800
+ )
801
+ return
802
+ # Save chat content to file
803
+ with open(args.target_file, "w") as f:
804
+ f.write(chat_content)
805
+
806
+ lines = []
807
+ while True:
808
+ line = prompt(FormattedText([("#00FF00", "> ")]), multiline=False)
809
+ line_lower = line.strip().lower()
810
+ if line_lower in ["eof", "/eof"]:
811
+ break
812
+ elif line_lower in ["/clear"]:
813
+ lines = []
814
+ print("\033[2J\033[H") # Clear terminal screen
815
+ continue
816
+ elif line_lower in ["/break"]:
817
+ raise Exception("User requested to break the operation.")
818
+ lines.append(line)
819
+
820
+ result = "\n".join(lines)
821
+
822
+ # Update chat history with user's response
823
+ chat_history["ask_conversation"].append(
824
+ {"role": "assistant", "content": result}
825
+ )
826
+
827
+ with open(memory_file, "w") as f:
828
+ json.dump(chat_history, f, ensure_ascii=False)
829
+
830
+ request_queue.add_request(
831
+ args.request_id,
832
+ RequestValue(
833
+ value=DefaultValue(value=result), status=RequestOption.COMPLETED
834
+ ),
835
+ )
836
+
837
+ return {}
717
838
 
718
839
  if args.enable_rag_search or args.enable_rag_context:
719
840
  rag = RAGFactory.get_rag(llm=chat_llm, args=args, path="")
720
841
  response = rag.stream_chat_oai(conversations=loaded_conversations)[0]
721
842
  v = ([item, None] for item in response)
722
- else:
843
+ else:
723
844
  v = chat_llm.stream_chat_oai(
724
845
  conversations=loaded_conversations, delta_mode=True
725
846
  )
@@ -813,7 +934,7 @@ def main(input_args: Optional[List[str]] = None):
813
934
  llm, args, code_auto_execute.Mode.SINGLE_ROUND
814
935
  )
815
936
  executor.run(query=args.query, context=s, source_code="")
816
- return
937
+ return
817
938
  elif raw_args.doc_command == "serve":
818
939
 
819
940
  from autocoder.rag.llm_wrapper import LLWrapper
@@ -838,7 +959,7 @@ def main(input_args: Optional[List[str]] = None):
838
959
  llm_wrapper = LLWrapper(llm=llm, rag=rag)
839
960
  serve(llm=llm_wrapper, args=server_args)
840
961
  return
841
-
962
+
842
963
  elif raw_args.doc_command == "chat":
843
964
  from autocoder.rag.rag_entry import RAGFactory
844
965
 
@@ -16,7 +16,13 @@ MESSAGES = {
16
16
  "The system is waiting for your input. When finished, enter 'EOF' on a new line to submit.\n"
17
17
  "Use '/break' to exit this mode. If you have issues with copy-paste, use '/clear' to clean and paste again."
18
18
  ),
19
-
19
+ "chat_human_as_model_instructions": (
20
+ "Chat is now in Human as Model mode.\n"
21
+ "The question has been copied to your clipboard.\n"
22
+ "Please use Web version model to get the answer.\n"
23
+ "Or use /conf human_as_model:false to close this mode and get the answer in terminal directly."
24
+ "Paste the answer to the input box below, use '/break' to exit, '/clear' to clear the screen, '/eof' to submit."
25
+ )
20
26
  },
21
27
  "zh": {
22
28
  "human_as_model_instructions": (
@@ -33,7 +39,13 @@ MESSAGES = {
33
39
  "系统正在等待您的输入。完成后,在新行输入'EOF'提交。\n"
34
40
  "使用'/break'退出此模式。如果复制粘贴有问题,使用'/clear'清理并重新粘贴。"
35
41
  ),
36
-
42
+ "chat_human_as_model_instructions": (
43
+ "\n============= Chat 处于 Human as Model 模式 =============\n"
44
+ "问题已复制到剪贴板\n"
45
+ "请使用Web版本模型获取答案\n"
46
+ "或者使用 /conf human_as_model:false 关闭该模式直接在终端获得答案。"
47
+ "将获得答案黏贴到下面的输入框,换行后,使用 '/break' 退出,'/clear' 清屏,'/eof' 提交。"
48
+ ),
37
49
  }
38
50
  }
39
51
 
@@ -17,6 +17,7 @@ import shlex
17
17
  from rich.console import Console
18
18
  from rich.table import Table
19
19
  import os
20
+ from loguru import logger
20
21
 
21
22
  from autocoder.rag.document_retriever import process_file_local
22
23
  from autocoder.rag.token_counter import TokenCounter
@@ -144,6 +145,20 @@ def main(input_args: Optional[List[str]] = None):
144
145
  parser = argparse.ArgumentParser(description="Auto Coder RAG Server")
145
146
  subparsers = parser.add_subparsers(dest="command", help="Available commands")
146
147
 
148
+ # Build hybrid index command
149
+ build_index_parser = subparsers.add_parser("build_hybrid_index", help="Build hybrid index for RAG")
150
+ build_index_parser.add_argument("--quick", action="store_true", help="Skip system initialization")
151
+ build_index_parser.add_argument("--file", default="", help=desc["file"])
152
+ build_index_parser.add_argument("--model", default="deepseek_chat", help=desc["model"])
153
+ build_index_parser.add_argument("--index_model", default="", help=desc["index_model"])
154
+ build_index_parser.add_argument("--emb_model", default="", help=desc["emb_model"])
155
+ build_index_parser.add_argument("--ray_address", default="auto", help=desc["ray_address"])
156
+ build_index_parser.add_argument("--required_exts", default="", help=desc["doc_build_parse_required_exts"])
157
+ build_index_parser.add_argument("--source_dir", default=".", help="Source directory path")
158
+ build_index_parser.add_argument("--tokenizer_path", default="", help="Path to tokenizer file")
159
+ build_index_parser.add_argument("--doc_dir", default="", help="Document directory path")
160
+ build_index_parser.add_argument("--enable_hybrid_index", action="store_true", help="Enable hybrid index")
161
+
147
162
  # Serve command
148
163
  serve_parser = subparsers.add_parser("serve", help="Start the RAG server")
149
164
  serve_parser.add_argument(
@@ -242,6 +257,18 @@ def main(input_args: Optional[List[str]] = None):
242
257
  help="Enable deep thought in inference mode",
243
258
  )
244
259
 
260
+ serve_parser.add_argument(
261
+ "--enable_hybrid_index",
262
+ action="store_true",
263
+ help="Enable hybrid index",
264
+ )
265
+ serve_parser.add_argument(
266
+ "--hybrid_index_max_output_tokens",
267
+ type=int,
268
+ default=1000000,
269
+ help="The maximum number of tokens in the output. This is only used when enable_hybrid_index is true.",
270
+ )
271
+
245
272
  # Tools command
246
273
  tools_parser = subparsers.add_parser("tools", help="Various tools")
247
274
  tools_subparsers = tools_parser.add_subparsers(dest="tool", help="Available tools")
@@ -275,10 +302,28 @@ def main(input_args: Optional[List[str]] = None):
275
302
  }
276
303
  )
277
304
 
278
- byzerllm.connect_cluster(address=args.ray_address)
305
+ if auto_coder_args.enable_hybrid_index:
306
+ # 尝试连接storage
307
+ try:
308
+ from byzerllm.apps.byzer_storage.simple_api import ByzerStorage
309
+ storage = ByzerStorage("byzerai_store", "rag", "files")
310
+ storage.retrieval.cluster_info("byzerai_store")
311
+ except Exception as e:
312
+ logger.error("When enable_hybrid_index is true, ByzerStorage must be started")
313
+ logger.error("Please run 'byzerllm storage start' first")
314
+ return
315
+ else:
316
+ byzerllm.connect_cluster(address=args.ray_address)
279
317
  llm = byzerllm.ByzerLLM()
280
318
  llm.setup_default_model_name(args.model)
281
319
 
320
+ # 当启用hybrid_index时,检查必要的组件
321
+ if auto_coder_args.enable_hybrid_index:
322
+ if not llm.is_model_exist("emb"):
323
+ logger.error("When enable_hybrid_index is true, an 'emb' model must be deployed")
324
+ return
325
+ llm.setup_default_emb_model_name("emb")
326
+
282
327
  if server_args.doc_dir:
283
328
  auto_coder_args.rag_type = "simple"
284
329
  rag = RAGFactory.get_rag(
@@ -292,6 +337,52 @@ def main(input_args: Optional[List[str]] = None):
292
337
 
293
338
  llm_wrapper = LLWrapper(llm=llm, rag=rag)
294
339
  serve(llm=llm_wrapper, args=server_args)
340
+ elif args.command == "build_hybrid_index":
341
+ if not args.quick:
342
+ initialize_system()
343
+
344
+ auto_coder_args = AutoCoderArgs(
345
+ **{
346
+ arg: getattr(args, arg)
347
+ for arg in vars(AutoCoderArgs())
348
+ if hasattr(args, arg)
349
+ }
350
+ )
351
+
352
+ auto_coder_args.enable_hybrid_index = True
353
+ auto_coder_args.rag_type = "simple"
354
+
355
+ try:
356
+ from byzerllm.apps.byzer_storage.simple_api import ByzerStorage
357
+ storage = ByzerStorage("byzerai_store", "rag", "files")
358
+ storage.retrieval.cluster_info("byzerai_store")
359
+ except Exception as e:
360
+ logger.error("When enable_hybrid_index is true, ByzerStorage must be started")
361
+ logger.error("Please run 'byzerllm storage start' first")
362
+ return
363
+
364
+ llm = byzerllm.ByzerLLM()
365
+ llm.setup_default_model_name(args.model)
366
+
367
+ # 当启用hybrid_index时,检查必要的组件
368
+ if auto_coder_args.enable_hybrid_index:
369
+ if not llm.is_model_exist("emb"):
370
+ logger.error("When enable_hybrid_index is true, an 'emb' model must be deployed")
371
+ return
372
+ llm.setup_default_emb_model_name("emb")
373
+
374
+ rag = RAGFactory.get_rag(
375
+ llm=llm,
376
+ args=auto_coder_args,
377
+ path=args.doc_dir,
378
+ tokenizer_path=args.tokenizer_path,
379
+ )
380
+
381
+ if hasattr(rag.document_retriever, "cacher"):
382
+ rag.document_retriever.cacher.build_cache()
383
+ else:
384
+ logger.error("The document retriever does not support hybrid index building")
385
+
295
386
  elif args.command == "tools" and args.tool == "count":
296
387
  # auto-coder.rag tools count --tokenizer_path /Users/allwefantasy/Downloads/tokenizer.json --file /Users/allwefantasy/data/yum/schema/schema.xlsx
297
388
  count_tokens(args.tokenizer_path, args.file)
@@ -718,8 +718,8 @@ class CommandCompleter(Completer):
718
718
 
719
719
  parser.coding()
720
720
  current_word = parser.current_word()
721
-
722
- if len(new_text.strip()) == 0 or new_text.strip()=="/":
721
+
722
+ if len(new_text.strip()) == 0 or new_text.strip() == "/":
723
723
  for command in parser.get_sub_commands():
724
724
  if command.startswith(current_word):
725
725
  yield Completion(command, start_position=-len(current_word))
@@ -797,7 +797,7 @@ class CommandCompleter(Completer):
797
797
  start_position=-len(name),
798
798
  display=f"{symbol.symbol_name} ({display_name}/{symbol.symbol_type})",
799
799
  )
800
-
800
+
801
801
  tags = [tag for tag in parser.tags]
802
802
 
803
803
  if current_word.startswith("<"):
@@ -810,7 +810,7 @@ class CommandCompleter(Completer):
810
810
  )
811
811
  elif tag.startswith(name):
812
812
  yield Completion(tag, start_position=-len(current_word))
813
-
813
+
814
814
  if tags and tags[-1].start_tag == "<img>" and tags[-1].end_tag == "":
815
815
  raw_file_name = tags[0].content
816
816
  file_name = raw_file_name.strip()
@@ -932,7 +932,7 @@ class CommandCompleter(Completer):
932
932
  field_name + ":"
933
933
  for field_name in AutoCoderArgs.model_fields.keys()
934
934
  if field_name.startswith(current_word)
935
- ]
935
+ ]
936
936
 
937
937
  for completion in completions:
938
938
  yield Completion(completion, start_position=-len(current_word))
@@ -1489,46 +1489,39 @@ def coding(query: str):
1489
1489
  @byzerllm.prompt()
1490
1490
  def code_review(query: str) -> str:
1491
1491
  """
1492
- 对前面的代码进行review,参考如下检查点:
1493
-
1492
+ 对代码进行review,参考如下检查点。
1494
1493
  1. 有没有调用不符合方法,类的签名的调用
1495
- 2. 有没有没有未声明直接使用的变量,方法,类
1494
+ 2. 有没有未声明直接使用的变量,方法,类
1496
1495
  3. 有没有明显的语法错误
1497
- 4. 用户的额外的检查需求:{{ query }}
1498
-
1499
- 如果用户的需求包含了@一个文件名 或者 @@符号, 那么重点关注这些文件或者符号(函数,类)进行上述的review
1496
+ 4. 如果是python代码,检查有没有缩进方面的错误
1497
+ 5. 如果是python代码,检查是否 try 后面缺少 except 或者 finally
1498
+ {% if query %}
1499
+ 6. 用户的额外的检查需求:{{ query }}
1500
+ {% endif %}
1501
+
1502
+ 如果用户的需求包含了@一个文件名 或者 @@符号, 那么重点关注这些文件或者符号(函数,类)进行上述的review。
1503
+ review 过程中严格遵循上述的检查点,不要遗漏,没有发现异常的点直接跳过,只对发现的异常点,给出具体的修改后的代码。
1500
1504
  """
1501
1505
 
1502
1506
 
1503
1507
  def chat(query: str):
1504
1508
  conf = memory.get("conf", {})
1505
- current_files = memory["current_files"]["files"] + get_llm_friendly_package_docs(
1506
- return_paths=True
1507
- )
1508
-
1509
- file_contents = []
1510
- for file in current_files:
1511
- if os.path.exists(file):
1512
- try:
1513
- with open(file, "r") as f:
1514
- content = f.read()
1515
- s = f"##File: {file}\n{content}\n\n"
1516
- file_contents.append(s)
1517
- except Exception as e:
1518
- print(f"Failed to read file: {file}. Error: {str(e)}")
1519
-
1520
- all_file_content = "".join(file_contents)
1521
-
1509
+
1522
1510
  yaml_config = {
1523
1511
  "include_file": ["./base/base.yml"],
1524
- "include_project_structure": conf.get("include_project_structure", "true")
1525
- == "true",
1512
+ "include_project_structure": conf.get("include_project_structure", "true") in ["true","True"],
1513
+ "human_as_model": conf.get("human_as_model", "false") == "true",
1514
+ "skip_build_index": conf.get("skip_build_index", "true") == "true",
1515
+ "skip_confirm": conf.get("skip_confirm", "true") == "true",
1516
+ "silence": conf.get("silence", "true") == "true",
1526
1517
  }
1527
1518
 
1528
- yaml_config["context"] = json.dumps(
1529
- {"file_content": all_file_content}, ensure_ascii=False
1519
+ current_files = memory["current_files"]["files"] + get_llm_friendly_package_docs(
1520
+ return_paths=True
1530
1521
  )
1531
1522
 
1523
+ yaml_config["urls"] = current_files
1524
+
1532
1525
  if "emb_model" in conf:
1533
1526
  yaml_config["emb_model"] = conf["emb_model"]
1534
1527
 
@@ -282,8 +282,10 @@ class AutoCoderArgs(pydantic.BaseModel):
282
282
  command: Optional[str] = None
283
283
  doc_command: Optional[str] = None
284
284
  required_exts: Optional[str] = None
285
+ hybrid_index_max_output_tokens: Optional[int] = 1000000
285
286
 
286
287
  monitor_mode: bool = False
288
+ enable_hybrid_index: bool = False
287
289
  disable_auto_window: bool = False
288
290
  disable_segment_reorder: bool = False
289
291
  rag_doc_filter_relevance: int = 5
@@ -0,0 +1,14 @@
1
+ from pydantic import BaseModel
2
+ from typing import List, Tuple,Dict,Optional,Any
3
+ from abc import ABC, abstractmethod
4
+
5
+ class DeleteEvent(BaseModel):
6
+ file_paths: List[str]
7
+
8
+ class AddOrUpdateEvent(BaseModel):
9
+ file_infos: List[Tuple[str, str, float]]
10
+
11
+ class BaseCacheManager(ABC):
12
+ @abstractmethod
13
+ def get_cache(self,options:Optional[Dict[str,Any]]=None) -> Dict[str, Dict]:
14
+ pass