auto-coder 0.1.182__tar.gz → 0.1.184__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.182 → auto_coder-0.1.184}/PKG-INFO +2 -2
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/PKG-INFO +2 -2
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/SOURCES.txt +6 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/requires.txt +1 -1
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/auto_coder.py +136 -17
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/auto_coder_lang.py +14 -2
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/auto_coder_rag.py +103 -1
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/chat_auto_coder.py +27 -33
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/__init__.py +5 -0
- auto_coder-0.1.184/src/autocoder/rag/cache/base_cache.py +14 -0
- auto_coder-0.1.184/src/autocoder/rag/cache/byzer_storage_cache.py +394 -0
- auto_coder-0.1.184/src/autocoder/rag/cache/file_monitor_cache.py +146 -0
- auto_coder-0.1.184/src/autocoder/rag/cache/simple_cache.py +204 -0
- auto_coder-0.1.184/src/autocoder/rag/document_retriever.py +238 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/long_context_rag.py +20 -7
- auto_coder-0.1.184/src/autocoder/rag/types.py +0 -0
- auto_coder-0.1.184/src/autocoder/rag/utils.py +133 -0
- auto_coder-0.1.184/src/autocoder/version.py +1 -0
- auto_coder-0.1.182/src/autocoder/rag/document_retriever.py +0 -657
- auto_coder-0.1.182/src/autocoder/version.py +0 -1
- {auto_coder-0.1.182 → auto_coder-0.1.184}/LICENSE +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/README.md +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/setup.cfg +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/setup.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/dependency_links.txt +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/entry_points.txt +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/auto_coder.egg-info/top_level.txt +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/auto_tool.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/coder.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/designer.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/planner.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/agent/project_reader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/auto_coder_server.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/chat/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/chat_auto_coder_lang.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/command_args.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/JupyterClient.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/ShellClient.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/anything2images.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/audio.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/cleaner.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_execute.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_generate.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_generate_diff.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_generate_editblock.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_generate_strict_diff.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_merge.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_merge_diff.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/code_auto_merge_strict_diff.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/command_completer.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/command_generator.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/command_templates.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/const.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/git_utils.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/image_to_page.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/interpreter.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/llm_rerank.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/screenshots.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/search.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/search_replace.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/text.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/common/types.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/db/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/db/store.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/action.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/copilot.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/plugins/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/plugins/action_regex_project.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/dispacher/actions/plugins/action_translate.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/index/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/index/for_command.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/index/index.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/index/symbols_utils.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/lang.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/pyproject/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/api_server.py +0 -0
- /auto_coder-0.1.182/src/autocoder/rag/types.py → /auto_coder-0.1.184/src/autocoder/rag/cache/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/doc_filter.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/llm_wrapper.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/loaders/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/loaders/docx_loader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/loaders/excel_loader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/loaders/pdf_loader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/loaders/ppt_loader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/rag_config.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/rag_entry.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/raw_rag.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/relevant_utils.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/simple_directory_reader.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/simple_rag.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/token_checker.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/token_counter.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/token_limiter.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/rag/variable_holder.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/regexproject/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/suffixproject/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/tsproject/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/__init__.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/conversation_store.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/llm_client_interceptors.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/log_capture.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/multi_turn.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/print_table.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/queue_communicate.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/request_event_queue.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/request_queue.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/rest.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/src/autocoder/utils/tests.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_action_regex_project.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_chat_auto_coder.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_code_auto_merge_editblock.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_command_completer.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_planner.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/tests/test_queue_communicate.py +0 -0
- {auto_coder-0.1.182 → auto_coder-0.1.184}/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.184
|
|
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.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.
|
|
3
|
+
Version: 0.1.184
|
|
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.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
|
|
@@ -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=
|
|
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,136 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
701
709
|
pre_conversations.append(
|
|
702
710
|
{
|
|
703
711
|
"role": "user",
|
|
704
|
-
"content": f"
|
|
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
|
-
|
|
710
|
-
|
|
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
|
|
714
|
-
|
|
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
|
-
|
|
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
|
+
历史对话:
|
|
758
|
+
{% for conv in pre_conversations %}
|
|
759
|
+
[{{ conv.role }}]: {{ conv.content }}
|
|
760
|
+
{% endfor %}
|
|
761
|
+
{% endif %}
|
|
762
|
+
|
|
763
|
+
用户的问题: {{ last_conversation.content }}
|
|
764
|
+
"""
|
|
765
|
+
|
|
766
|
+
source_codes_conversations = loaded_conversations[0 : source_count * 2]
|
|
767
|
+
source_codes = ""
|
|
768
|
+
for conv in source_codes_conversations:
|
|
769
|
+
if conv["role"] == "user":
|
|
770
|
+
source_codes += conv["content"]
|
|
771
|
+
|
|
772
|
+
chat_content = chat_with_human_as_model.prompt(
|
|
773
|
+
source_codes=source_codes,
|
|
774
|
+
pre_conversations=loaded_conversations[source_count * 2 : -1],
|
|
775
|
+
last_conversation=loaded_conversations[-1],
|
|
776
|
+
)
|
|
777
|
+
try:
|
|
778
|
+
import pyperclip
|
|
779
|
+
|
|
780
|
+
pyperclip.copy(chat_content)
|
|
781
|
+
console.print(
|
|
782
|
+
Panel(
|
|
783
|
+
get_message("chat_human_as_model_instructions"),
|
|
784
|
+
title="Instructions",
|
|
785
|
+
border_style="blue",
|
|
786
|
+
expand=False,
|
|
787
|
+
)
|
|
788
|
+
)
|
|
789
|
+
except Exception:
|
|
790
|
+
logger.warning(get_message("clipboard_not_supported"))
|
|
791
|
+
console.print(
|
|
792
|
+
Panel(
|
|
793
|
+
get_message("human_as_model_instructions_no_clipboard"),
|
|
794
|
+
title="Instructions",
|
|
795
|
+
border_style="blue",
|
|
796
|
+
expand=False,
|
|
797
|
+
)
|
|
798
|
+
)
|
|
799
|
+
return
|
|
800
|
+
# Save chat content to file
|
|
801
|
+
with open(args.target_file, "w") as f:
|
|
802
|
+
f.write(chat_content)
|
|
803
|
+
|
|
804
|
+
lines = []
|
|
805
|
+
while True:
|
|
806
|
+
line = prompt(FormattedText([("#00FF00", "> ")]), multiline=False)
|
|
807
|
+
line_lower = line.strip().lower()
|
|
808
|
+
if line_lower in ["eof", "/eof"]:
|
|
809
|
+
break
|
|
810
|
+
elif line_lower in ["/clear"]:
|
|
811
|
+
lines = []
|
|
812
|
+
print("\033[2J\033[H") # Clear terminal screen
|
|
813
|
+
continue
|
|
814
|
+
elif line_lower in ["/break"]:
|
|
815
|
+
raise Exception("User requested to break the operation.")
|
|
816
|
+
lines.append(line)
|
|
817
|
+
|
|
818
|
+
result = "\n".join(lines)
|
|
819
|
+
|
|
820
|
+
# Update chat history with user's response
|
|
821
|
+
chat_history["ask_conversation"].append(
|
|
822
|
+
{"role": "assistant", "content": result}
|
|
823
|
+
)
|
|
824
|
+
|
|
825
|
+
with open(memory_file, "w") as f:
|
|
826
|
+
json.dump(chat_history, f, ensure_ascii=False)
|
|
827
|
+
|
|
828
|
+
request_queue.add_request(
|
|
829
|
+
args.request_id,
|
|
830
|
+
RequestValue(
|
|
831
|
+
value=DefaultValue(value=result), status=RequestOption.COMPLETED
|
|
832
|
+
),
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
return {}
|
|
717
836
|
|
|
718
837
|
if args.enable_rag_search or args.enable_rag_context:
|
|
719
838
|
rag = RAGFactory.get_rag(llm=chat_llm, args=args, path="")
|
|
720
839
|
response = rag.stream_chat_oai(conversations=loaded_conversations)[0]
|
|
721
840
|
v = ([item, None] for item in response)
|
|
722
|
-
else:
|
|
841
|
+
else:
|
|
723
842
|
v = chat_llm.stream_chat_oai(
|
|
724
843
|
conversations=loaded_conversations, delta_mode=True
|
|
725
844
|
)
|
|
@@ -813,7 +932,7 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
813
932
|
llm, args, code_auto_execute.Mode.SINGLE_ROUND
|
|
814
933
|
)
|
|
815
934
|
executor.run(query=args.query, context=s, source_code="")
|
|
816
|
-
return
|
|
935
|
+
return
|
|
817
936
|
elif raw_args.doc_command == "serve":
|
|
818
937
|
|
|
819
938
|
from autocoder.rag.llm_wrapper import LLWrapper
|
|
@@ -838,7 +957,7 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
838
957
|
llm_wrapper = LLWrapper(llm=llm, rag=rag)
|
|
839
958
|
serve(llm=llm_wrapper, args=server_args)
|
|
840
959
|
return
|
|
841
|
-
|
|
960
|
+
|
|
842
961
|
elif raw_args.doc_command == "chat":
|
|
843
962
|
from autocoder.rag.rag_entry import RAGFactory
|
|
844
963
|
|
|
@@ -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(
|
|
@@ -231,6 +246,29 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
231
246
|
help="Disable reordering of document segments after retrieval",
|
|
232
247
|
)
|
|
233
248
|
|
|
249
|
+
serve_parser.add_argument(
|
|
250
|
+
"--disable_inference_enhance",
|
|
251
|
+
action="store_true",
|
|
252
|
+
help="Disable enhanced inference mode",
|
|
253
|
+
)
|
|
254
|
+
serve_parser.add_argument(
|
|
255
|
+
"--inference_deep_thought",
|
|
256
|
+
action="store_true",
|
|
257
|
+
help="Enable deep thought in inference mode",
|
|
258
|
+
)
|
|
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
|
+
|
|
234
272
|
# Tools command
|
|
235
273
|
tools_parser = subparsers.add_parser("tools", help="Various tools")
|
|
236
274
|
tools_subparsers = tools_parser.add_subparsers(dest="tool", help="Available tools")
|
|
@@ -264,10 +302,28 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
264
302
|
}
|
|
265
303
|
)
|
|
266
304
|
|
|
267
|
-
|
|
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)
|
|
268
317
|
llm = byzerllm.ByzerLLM()
|
|
269
318
|
llm.setup_default_model_name(args.model)
|
|
270
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
|
+
|
|
271
327
|
if server_args.doc_dir:
|
|
272
328
|
auto_coder_args.rag_type = "simple"
|
|
273
329
|
rag = RAGFactory.get_rag(
|
|
@@ -281,6 +337,52 @@ def main(input_args: Optional[List[str]] = None):
|
|
|
281
337
|
|
|
282
338
|
llm_wrapper = LLWrapper(llm=llm, rag=rag)
|
|
283
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
|
+
|
|
284
386
|
elif args.command == "tools" and args.tool == "count":
|
|
285
387
|
# auto-coder.rag tools count --tokenizer_path /Users/allwefantasy/Downloads/tokenizer.json --file /Users/allwefantasy/data/yum/schema/schema.xlsx
|
|
286
388
|
count_tokens(args.tokenizer_path, args.file)
|
|
@@ -719,9 +719,10 @@ class CommandCompleter(Completer):
|
|
|
719
719
|
parser.coding()
|
|
720
720
|
current_word = parser.current_word()
|
|
721
721
|
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
722
|
+
if len(new_text.strip()) == 0 or new_text.strip() == "/":
|
|
723
|
+
for command in parser.get_sub_commands():
|
|
724
|
+
if command.startswith(current_word):
|
|
725
|
+
yield Completion(command, start_position=-len(current_word))
|
|
725
726
|
|
|
726
727
|
all_tags = parser.tags
|
|
727
728
|
|
|
@@ -797,6 +798,8 @@ class CommandCompleter(Completer):
|
|
|
797
798
|
display=f"{symbol.symbol_name} ({display_name}/{symbol.symbol_type})",
|
|
798
799
|
)
|
|
799
800
|
|
|
801
|
+
tags = [tag for tag in parser.tags]
|
|
802
|
+
|
|
800
803
|
if current_word.startswith("<"):
|
|
801
804
|
name = current_word[1:]
|
|
802
805
|
for tag in ["<img>", "</img>"]:
|
|
@@ -808,8 +811,6 @@ class CommandCompleter(Completer):
|
|
|
808
811
|
elif tag.startswith(name):
|
|
809
812
|
yield Completion(tag, start_position=-len(current_word))
|
|
810
813
|
|
|
811
|
-
tags = [tag for tag in parser.tags]
|
|
812
|
-
|
|
813
814
|
if tags and tags[-1].start_tag == "<img>" and tags[-1].end_tag == "":
|
|
814
815
|
raw_file_name = tags[0].content
|
|
815
816
|
file_name = raw_file_name.strip()
|
|
@@ -931,7 +932,7 @@ class CommandCompleter(Completer):
|
|
|
931
932
|
field_name + ":"
|
|
932
933
|
for field_name in AutoCoderArgs.model_fields.keys()
|
|
933
934
|
if field_name.startswith(current_word)
|
|
934
|
-
]
|
|
935
|
+
]
|
|
935
936
|
|
|
936
937
|
for completion in completions:
|
|
937
938
|
yield Completion(completion, start_position=-len(current_word))
|
|
@@ -1488,46 +1489,39 @@ def coding(query: str):
|
|
|
1488
1489
|
@byzerllm.prompt()
|
|
1489
1490
|
def code_review(query: str) -> str:
|
|
1490
1491
|
"""
|
|
1491
|
-
|
|
1492
|
-
|
|
1492
|
+
对代码进行review,参考如下检查点。
|
|
1493
1493
|
1. 有没有调用不符合方法,类的签名的调用
|
|
1494
|
-
2.
|
|
1494
|
+
2. 有没有未声明直接使用的变量,方法,类
|
|
1495
1495
|
3. 有没有明显的语法错误
|
|
1496
|
-
4.
|
|
1497
|
-
|
|
1498
|
-
|
|
1496
|
+
4. 如果是python代码,检查有没有缩进方面的错误
|
|
1497
|
+
5. 如果是python代码,检查是否 try 后面缺少 except 或者 finally
|
|
1498
|
+
{% if query %}
|
|
1499
|
+
6. 用户的额外的检查需求:{{ query }}
|
|
1500
|
+
{% endif %}
|
|
1501
|
+
|
|
1502
|
+
如果用户的需求包含了@一个文件名 或者 @@符号, 那么重点关注这些文件或者符号(函数,类)进行上述的review。
|
|
1503
|
+
review 过程中严格遵循上述的检查点,不要遗漏,没有发现异常的点直接跳过,只对发现的异常点,给出具体的修改后的代码。
|
|
1499
1504
|
"""
|
|
1500
1505
|
|
|
1501
1506
|
|
|
1502
1507
|
def chat(query: str):
|
|
1503
1508
|
conf = memory.get("conf", {})
|
|
1504
|
-
|
|
1505
|
-
return_paths=True
|
|
1506
|
-
)
|
|
1507
|
-
|
|
1508
|
-
file_contents = []
|
|
1509
|
-
for file in current_files:
|
|
1510
|
-
if os.path.exists(file):
|
|
1511
|
-
try:
|
|
1512
|
-
with open(file, "r") as f:
|
|
1513
|
-
content = f.read()
|
|
1514
|
-
s = f"##File: {file}\n{content}\n\n"
|
|
1515
|
-
file_contents.append(s)
|
|
1516
|
-
except Exception as e:
|
|
1517
|
-
print(f"Failed to read file: {file}. Error: {str(e)}")
|
|
1518
|
-
|
|
1519
|
-
all_file_content = "".join(file_contents)
|
|
1520
|
-
|
|
1509
|
+
|
|
1521
1510
|
yaml_config = {
|
|
1522
1511
|
"include_file": ["./base/base.yml"],
|
|
1523
|
-
"include_project_structure": conf.get("include_project_structure", "true")
|
|
1524
|
-
== "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",
|
|
1525
1517
|
}
|
|
1526
1518
|
|
|
1527
|
-
|
|
1528
|
-
|
|
1519
|
+
current_files = memory["current_files"]["files"] + get_llm_friendly_package_docs(
|
|
1520
|
+
return_paths=True
|
|
1529
1521
|
)
|
|
1530
1522
|
|
|
1523
|
+
yaml_config["urls"] = current_files
|
|
1524
|
+
|
|
1531
1525
|
if "emb_model" in conf:
|
|
1532
1526
|
yaml_config["emb_model"] = conf["emb_model"]
|
|
1533
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
|
|
@@ -312,5 +314,8 @@ class AutoCoderArgs(pydantic.BaseModel):
|
|
|
312
314
|
segment_ratio: Optional[float] = 0.2
|
|
313
315
|
buff_ratio: Optional[float] = 0.1
|
|
314
316
|
|
|
317
|
+
disable_inference_enhance: Optional[bool] = False
|
|
318
|
+
inference_deep_thought: Optional[bool] = False
|
|
319
|
+
|
|
315
320
|
class Config:
|
|
316
321
|
protected_namespaces = ()
|
|
@@ -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
|