auto-coder 0.1.345__py3-none-any.whl → 0.1.346__py3-none-any.whl
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.345.dist-info → auto_coder-0.1.346.dist-info}/METADATA +1 -1
- {auto_coder-0.1.345.dist-info → auto_coder-0.1.346.dist-info}/RECORD +12 -12
- autocoder/auto_coder_runner.py +4 -5
- autocoder/common/v2/agent/agentic_edit.py +31 -1
- autocoder/common/v2/agent/agentic_edit_tools/ask_followup_question_tool_resolver.py +2 -2
- autocoder/rag/long_context_rag.py +1 -2
- autocoder/rag/qa_conversation_strategy.py +161 -11
- autocoder/version.py +1 -1
- {auto_coder-0.1.345.dist-info → auto_coder-0.1.346.dist-info}/LICENSE +0 -0
- {auto_coder-0.1.345.dist-info → auto_coder-0.1.346.dist-info}/WHEEL +0 -0
- {auto_coder-0.1.345.dist-info → auto_coder-0.1.346.dist-info}/entry_points.txt +0 -0
- {auto_coder-0.1.345.dist-info → auto_coder-0.1.346.dist-info}/top_level.txt +0 -0
|
@@ -4,7 +4,7 @@ autocoder/auto_coder_lang.py,sha256=Rtupq6N3_HT7JRhDKdgCBcwRaiAnyCOR_Gsp4jUomrI,
|
|
|
4
4
|
autocoder/auto_coder_rag.py,sha256=NesRm7sIJrRQL1xxm_lbMtM7gi-KrYv9f26RfBuloZE,35386
|
|
5
5
|
autocoder/auto_coder_rag_client_mcp.py,sha256=QRxUbjc6A8UmDMQ8lXgZkjgqtq3lgKYeatJbDY6rSo0,6270
|
|
6
6
|
autocoder/auto_coder_rag_mcp.py,sha256=-RrjNwFaS2e5v8XDIrKR-zlUNUE8UBaeOtojffBrvJo,8521
|
|
7
|
-
autocoder/auto_coder_runner.py,sha256
|
|
7
|
+
autocoder/auto_coder_runner.py,sha256=2hI2095L5GWP1J04Lr7xBBTDOcNq_l4-HctcJ8bVaFE,111833
|
|
8
8
|
autocoder/auto_coder_server.py,sha256=bLORGEclcVdbBVfM140JCI8WtdrU0jbgqdJIVVupiEU,20578
|
|
9
9
|
autocoder/benchmark.py,sha256=Ypomkdzd1T3GE6dRICY3Hj547dZ6_inqJbBJIp5QMco,4423
|
|
10
10
|
autocoder/chat_auto_coder.py,sha256=CthuvdjVjTQOVv-zREsl8OCsZHPSP9OQcIgHULrW2Ro,25842
|
|
@@ -14,7 +14,7 @@ autocoder/command_parser.py,sha256=fx1g9E6GaM273lGTcJqaFQ-hoksS_Ik2glBMnVltPCE,1
|
|
|
14
14
|
autocoder/lang.py,sha256=PFtATuOhHRnfpqHQkXr6p4C893JvpsgwTMif3l-GEi0,14321
|
|
15
15
|
autocoder/models.py,sha256=_SCar82QIeBFTZZBdM2jPS6atKVhHnvE0gX3V0CsxD4,11590
|
|
16
16
|
autocoder/run_context.py,sha256=IUfSO6_gp2Wt1blFWAmOpN0b0nDrTTk4LmtCYUBIoro,1643
|
|
17
|
-
autocoder/version.py,sha256=
|
|
17
|
+
autocoder/version.py,sha256=FUAij2FADNMtAmQCx7M7pqiOpTP65zxKY6khe4EGQUs,23
|
|
18
18
|
autocoder/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
19
19
|
autocoder/agent/agentic_edit.py,sha256=XsfePZ-t6M-uBSdG1VLZXk1goqXk2HPeJ_A8IYyBuWQ,58896
|
|
20
20
|
autocoder/agent/agentic_edit_types.py,sha256=oFcDd_cxJ2yH9Ed1uTpD3BipudgoIEWDMPb5pAkq4gI,3288
|
|
@@ -126,13 +126,13 @@ autocoder/common/v2/code_editblock_manager.py,sha256=G0CIuV9Ki0FqMLnpA8nBT4pnkCN
|
|
|
126
126
|
autocoder/common/v2/code_manager.py,sha256=C403bS-f6urixwitlKHcml-J03hci-UyNwHJOqBiY6Q,9182
|
|
127
127
|
autocoder/common/v2/code_strict_diff_manager.py,sha256=v-J1kDyLg7tLGg_6_lbO9S4fNkx7M_L8Xr2G7fPptiU,9347
|
|
128
128
|
autocoder/common/v2/agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
129
|
-
autocoder/common/v2/agent/agentic_edit.py,sha256=
|
|
129
|
+
autocoder/common/v2/agent/agentic_edit.py,sha256=Ghx6HTCdjIYj96zoB5xkL6aGLizftgCmy5ZcUSaFXtQ,92599
|
|
130
130
|
autocoder/common/v2/agent/agentic_edit_conversation.py,sha256=qLLhTegH619JQTp3s1bj5FVn2hAcoV-DlhGO3UyIOMc,7338
|
|
131
131
|
autocoder/common/v2/agent/agentic_edit_types.py,sha256=6qBLLmvdlcsbzrpMHsYQVIHqbOWubMXOnmkqTs1pBWQ,4629
|
|
132
132
|
autocoder/common/v2/agent/agentic_tool_display.py,sha256=WKirt-2V346KLnbHgH3NVJiK3xvriD9oaCWj2IdvzLU,7309
|
|
133
133
|
autocoder/common/v2/agent/ignore_utils.py,sha256=gnUchRzKMLbUm_jvnKL-r-K9MWKPtt-6iiuzijY7Es0,1717
|
|
134
134
|
autocoder/common/v2/agent/agentic_edit_tools/__init__.py,sha256=wGICCc1dYh07osB21j62zOQ9Ws0PyyOQ12UYRHmHrtI,1229
|
|
135
|
-
autocoder/common/v2/agent/agentic_edit_tools/ask_followup_question_tool_resolver.py,sha256=
|
|
135
|
+
autocoder/common/v2/agent/agentic_edit_tools/ask_followup_question_tool_resolver.py,sha256=bwtf4m9N82TCP3piK5UglJk1FVFFm7ZX59XerA2qxko,3131
|
|
136
136
|
autocoder/common/v2/agent/agentic_edit_tools/attempt_completion_tool_resolver.py,sha256=82ZGKeRBSDKeead_XVBW4FxpiE-5dS7tBOk_3RZ6B5s,1511
|
|
137
137
|
autocoder/common/v2/agent/agentic_edit_tools/base_tool_resolver.py,sha256=Zid2m1uZd-2wVFGc_n_KAViXZyNjbdLSpI5n7ut1RUQ,1036
|
|
138
138
|
autocoder/common/v2/agent/agentic_edit_tools/execute_command_tool_resolver.py,sha256=GueQfIY2hVu2R5j9R5rBtn2znl5MlmEdGtsa6snsMHs,4112
|
|
@@ -214,8 +214,8 @@ autocoder/rag/doc_filter.py,sha256=UduVO2mlrngwJICrefjDJTYfdmQ4GcRXrfWDQ7xXksk,1
|
|
|
214
214
|
autocoder/rag/document_retriever.py,sha256=5BDqKVJqLPScEnua5S5suXhWuCaALIfPf5obXeJoWfs,8461
|
|
215
215
|
autocoder/rag/lang.py,sha256=HvcMeu6jReEJOGxyLMn4rwBoD-myFwmykS3VLceBJLs,3364
|
|
216
216
|
autocoder/rag/llm_wrapper.py,sha256=Ht5GF5yJtrztoliujsZzx_ooWZmHkd5xLZKcGEiicZw,4303
|
|
217
|
-
autocoder/rag/long_context_rag.py,sha256=
|
|
218
|
-
autocoder/rag/qa_conversation_strategy.py,sha256=
|
|
217
|
+
autocoder/rag/long_context_rag.py,sha256=84haMjfbPd2Rw_8Zdj-Azf_v9tbYST_OUPW0NZlmeJY,42189
|
|
218
|
+
autocoder/rag/qa_conversation_strategy.py,sha256=vv62JhmdZvLJ3U1gG4ZZ3m9thIlGvU1H0RXHtrRTJ6s,11788
|
|
219
219
|
autocoder/rag/rag_config.py,sha256=8LwFcTd8OJWWwi1_WY4IzjqgtT6RyE2j4PjxS5cCTDE,802
|
|
220
220
|
autocoder/rag/rag_entry.py,sha256=6TKtErZ0Us9XSV6HgRKXA6yR3SiZGPHpynOKSaR1wgE,2463
|
|
221
221
|
autocoder/rag/raw_rag.py,sha256=BOr0YGf3umjqXOIDVO1LXQ0bIHx8hzBdiubND2ezyxc,2946
|
|
@@ -277,9 +277,9 @@ autocoder/utils/types.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
277
277
|
autocoder/utils/auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
278
278
|
autocoder/utils/auto_coder_utils/chat_stream_out.py,sha256=KW0mlmcHlStXi8-_6fXZ2-ifeJ5mgP0OV7DQFzCtIsw,14008
|
|
279
279
|
autocoder/utils/chat_auto_coder_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
280
|
-
auto_coder-0.1.
|
|
281
|
-
auto_coder-0.1.
|
|
282
|
-
auto_coder-0.1.
|
|
283
|
-
auto_coder-0.1.
|
|
284
|
-
auto_coder-0.1.
|
|
285
|
-
auto_coder-0.1.
|
|
280
|
+
auto_coder-0.1.346.dist-info/LICENSE,sha256=HrhfyXIkWY2tGFK11kg7vPCqhgh5DcxleloqdhrpyMY,11558
|
|
281
|
+
auto_coder-0.1.346.dist-info/METADATA,sha256=pXxlRR0gvLNboAcWQtU9VzpKpiaCTj4evVC9Ztas7R4,2728
|
|
282
|
+
auto_coder-0.1.346.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
283
|
+
auto_coder-0.1.346.dist-info/entry_points.txt,sha256=0nzHtHH4pNcM7xq4EBA2toS28Qelrvcbrr59GqD_0Ak,350
|
|
284
|
+
auto_coder-0.1.346.dist-info/top_level.txt,sha256=Jqc0_uJSw2GwoFQAa9iJxYns-2mWla-9ok_Y3Gcznjk,10
|
|
285
|
+
auto_coder-0.1.346.dist-info/RECORD,,
|
autocoder/auto_coder_runner.py
CHANGED
|
@@ -40,7 +40,7 @@ from rich.markdown import Markdown
|
|
|
40
40
|
from byzerllm.utils.nontext import Image
|
|
41
41
|
import git
|
|
42
42
|
from autocoder.common import git_utils
|
|
43
|
-
from autocoder.chat_auto_coder_lang import get_message
|
|
43
|
+
from autocoder.chat_auto_coder_lang import get_message,get_message_with_format
|
|
44
44
|
from autocoder.agent.auto_guess_query import AutoGuessQuery
|
|
45
45
|
from autocoder.common.mcp_server import get_mcp_server
|
|
46
46
|
from autocoder.common.mcp_server_types import (
|
|
@@ -273,8 +273,8 @@ def initialize_system(args:InitializeSystemRequest):
|
|
|
273
273
|
else:
|
|
274
274
|
print(f" {message}")
|
|
275
275
|
|
|
276
|
-
def init_project():
|
|
277
|
-
if not os.path.exists(".auto-coder"):
|
|
276
|
+
def init_project():
|
|
277
|
+
if not os.path.exists(".auto-coder") or not os.path.exists("actions"):
|
|
278
278
|
first_time[0] = True
|
|
279
279
|
print_status(get_message("not_initialized"), "warning")
|
|
280
280
|
init_choice = input(
|
|
@@ -295,8 +295,7 @@ def initialize_system(args:InitializeSystemRequest):
|
|
|
295
295
|
|
|
296
296
|
if not os.path.exists(base_persist_dir):
|
|
297
297
|
os.makedirs(base_persist_dir, exist_ok=True)
|
|
298
|
-
print_status(
|
|
299
|
-
base_persist_dir), "success")
|
|
298
|
+
print_status(get_message_with_format("created_dir",path=base_persist_dir), "success")
|
|
300
299
|
|
|
301
300
|
if first_time[0]:
|
|
302
301
|
configure_project_type()
|
|
@@ -221,7 +221,7 @@ class AgenticEdit:
|
|
|
221
221
|
{{files}}
|
|
222
222
|
</files>
|
|
223
223
|
|
|
224
|
-
====
|
|
224
|
+
====
|
|
225
225
|
|
|
226
226
|
TOOL USE
|
|
227
227
|
|
|
@@ -667,7 +667,35 @@ class AgenticEdit:
|
|
|
667
667
|
You can use the tool `read_file` to read these description files, which helps you decide exactly which files need detailed attention. Note that the `active.md` file does not contain information about all files within the directory—it only includes information
|
|
668
668
|
about the files that were recently changed.
|
|
669
669
|
{% endif %}
|
|
670
|
+
|
|
671
|
+
{% if extra_docs %}
|
|
672
|
+
====
|
|
673
|
+
|
|
674
|
+
RULES PROVIDED BY USER
|
|
675
|
+
|
|
676
|
+
The following rules are provided by the user, and you must follow them strictly.
|
|
677
|
+
|
|
678
|
+
{% for key, value in extra_docs.items() %}
|
|
679
|
+
### {{ key }}
|
|
680
|
+
{{ value }}
|
|
681
|
+
{% endfor %}
|
|
682
|
+
{% endif %}
|
|
670
683
|
"""
|
|
684
|
+
import os
|
|
685
|
+
extra_docs = {}
|
|
686
|
+
rules_dir = os.path.join(self.args.source_dir,".auto-coder", "autocoderrules")
|
|
687
|
+
if os.path.isdir(rules_dir):
|
|
688
|
+
for fname in os.listdir(rules_dir):
|
|
689
|
+
if fname.endswith(".md"):
|
|
690
|
+
fpath = os.path.join(rules_dir, fname)
|
|
691
|
+
try:
|
|
692
|
+
with open(fpath, "r", encoding="utf-8") as f:
|
|
693
|
+
content = f.read()
|
|
694
|
+
key = os.path.splitext(fname)[0]
|
|
695
|
+
extra_docs[key] = content
|
|
696
|
+
except Exception:
|
|
697
|
+
continue
|
|
698
|
+
|
|
671
699
|
env_info = detect_env()
|
|
672
700
|
shell_type = "bash"
|
|
673
701
|
if shells.is_running_in_cmd():
|
|
@@ -687,6 +715,7 @@ class AgenticEdit:
|
|
|
687
715
|
"files": self.files.to_str(),
|
|
688
716
|
"mcp_server_info": self.mcp_server_info,
|
|
689
717
|
"enable_active_context": self.args.enable_active_context,
|
|
718
|
+
"extra_docs": extra_docs,
|
|
690
719
|
}
|
|
691
720
|
|
|
692
721
|
# Removed _execute_command_result and execute_auto_command methods
|
|
@@ -971,6 +1000,7 @@ class AgenticEdit:
|
|
|
971
1000
|
global_cancel.check_and_raise()
|
|
972
1001
|
|
|
973
1002
|
meta_holder.meta = metadata
|
|
1003
|
+
logger.info(f"metadata: {metadata.input_tokens_count}")
|
|
974
1004
|
if not content_chunk:
|
|
975
1005
|
continue
|
|
976
1006
|
buffer += content_chunk
|
|
@@ -29,12 +29,12 @@ class AskFollowupQuestionToolResolver(BaseToolResolver):
|
|
|
29
29
|
This resolver doesn't directly ask the user but prepares the data for it.
|
|
30
30
|
"""
|
|
31
31
|
question = self.tool.question
|
|
32
|
-
options = self.tool.options
|
|
32
|
+
options = self.tool.options or []
|
|
33
33
|
options_text = "\n".join([f"{i+1}. {option}" for i, option in enumerate(options)])
|
|
34
34
|
if get_run_context().is_web():
|
|
35
35
|
answer = get_event_manager(
|
|
36
36
|
self.args.event_file).ask_user(prompt=question)
|
|
37
|
-
self.result_manager.append(content=answer + "\n" + options_text, meta={
|
|
37
|
+
self.result_manager.append(content=answer + ("\n" + options_text if options_text else ""), meta={
|
|
38
38
|
"action": "ask_user",
|
|
39
39
|
"input": {
|
|
40
40
|
"question": question
|
|
@@ -841,8 +841,7 @@ class LongContextRAG:
|
|
|
841
841
|
self._print_rag_stats(rag_stat)
|
|
842
842
|
else:
|
|
843
843
|
|
|
844
|
-
qa_strategy = get_qa_strategy(
|
|
845
|
-
self.args.rag_qa_conversation_strategy)
|
|
844
|
+
qa_strategy = get_qa_strategy(self.args)
|
|
846
845
|
new_conversations = qa_strategy.create_conversation(
|
|
847
846
|
documents=[doc.source_code for doc in relevant_docs],
|
|
848
847
|
conversations=conversations, local_image_host=self.args.local_image_host
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from typing import List, Dict, Any,Generator
|
|
2
|
+
from typing import List, Dict, Any, Generator
|
|
3
3
|
import byzerllm
|
|
4
|
+
from autocoder.common import AutoCoderArgs
|
|
4
5
|
|
|
5
6
|
class QAConversationStrategy(ABC):
|
|
6
7
|
"""
|
|
@@ -26,6 +27,9 @@ class MultiRoundStrategy(QAConversationStrategy):
|
|
|
26
27
|
Multi-round strategy: First let the model read documents, then do Q&A.
|
|
27
28
|
Creates multiple conversation turns.
|
|
28
29
|
"""
|
|
30
|
+
def __init__(self, args: AutoCoderArgs):
|
|
31
|
+
self.args = args
|
|
32
|
+
|
|
29
33
|
def create_conversation(self, documents: List[Any], conversations: List[Dict[str,str]], local_image_host: str) -> List[Dict]:
|
|
30
34
|
messages = []
|
|
31
35
|
messages.extend([
|
|
@@ -36,7 +40,7 @@ class MultiRoundStrategy(QAConversationStrategy):
|
|
|
36
40
|
return messages
|
|
37
41
|
|
|
38
42
|
@byzerllm.prompt()
|
|
39
|
-
def
|
|
43
|
+
def _read_docs_prompt_old(
|
|
40
44
|
self, relevant_docs: List[str], local_image_host: str
|
|
41
45
|
) -> Generator[str, None, None]:
|
|
42
46
|
"""
|
|
@@ -68,6 +72,75 @@ class MultiRoundStrategy(QAConversationStrategy):
|
|
|
68
72
|
例如:/path/to/images/image.png, 返回 http://{{ local_image_host }}/static/path/to/images/image.png
|
|
69
73
|
{% endif %}
|
|
70
74
|
"""
|
|
75
|
+
|
|
76
|
+
@byzerllm.prompt()
|
|
77
|
+
def _read_docs_prompt(
|
|
78
|
+
self, relevant_docs: List[str], local_image_host: str
|
|
79
|
+
) -> Generator[str, None, None]:
|
|
80
|
+
"""
|
|
81
|
+
You are a knowledgeable assistant capable of answering any user question strictly based on the retrieved documents.
|
|
82
|
+
|
|
83
|
+
====
|
|
84
|
+
|
|
85
|
+
FILES CONTEXT
|
|
86
|
+
|
|
87
|
+
The following files are provided to you as context for the user's task. Use these files to understand the project and answer questions strictly based on their content.
|
|
88
|
+
|
|
89
|
+
<documents>
|
|
90
|
+
{% for doc in relevant_docs %}
|
|
91
|
+
{{ doc }}
|
|
92
|
+
{% endfor %}
|
|
93
|
+
</documents>
|
|
94
|
+
|
|
95
|
+
====
|
|
96
|
+
|
|
97
|
+
{% if extra_docs %}
|
|
98
|
+
AUTO EXTENSION DOCS
|
|
99
|
+
|
|
100
|
+
The following extension documents are loaded dynamically to enhance your understanding or provide special instructions, rules, or context.
|
|
101
|
+
|
|
102
|
+
{% for key, value in extra_docs.items() %}
|
|
103
|
+
### {{ key }}
|
|
104
|
+
{{ value }}
|
|
105
|
+
{% endfor %}
|
|
106
|
+
|
|
107
|
+
====
|
|
108
|
+
{% endif %}
|
|
109
|
+
|
|
110
|
+
INSTRUCTIONS
|
|
111
|
+
|
|
112
|
+
- Use ONLY the information from the provided documents and extension docs.
|
|
113
|
+
- If the documents do not contain enough information to answer, reply: "抱歉,文档中没有足够的信息来回答这个问题。"
|
|
114
|
+
- Do NOT invent, guess, or add information beyond what is provided.
|
|
115
|
+
|
|
116
|
+
- For Markdown images like :
|
|
117
|
+
- Analyze surrounding text to determine relevance.
|
|
118
|
+
- Include relevant images naturally in your answer, preserving image paths.
|
|
119
|
+
- Convert Windows paths to Linux style (e.g., C:\\path\\to\\img.png -> C:/path/to/img.png)
|
|
120
|
+
{% if local_image_host %}
|
|
121
|
+
- Prefix image URLs with http://{{ local_image_host }}/static/
|
|
122
|
+
{% endif %}
|
|
123
|
+
|
|
124
|
+
- Format your answer with Markdown for readability.
|
|
125
|
+
- Always use the language used by the user in their question.
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
import os
|
|
130
|
+
extra_docs = {}
|
|
131
|
+
rules_dir = os.path.join(self.args.source_dir, ".autocoderrules")
|
|
132
|
+
if os.path.isdir(rules_dir):
|
|
133
|
+
for fname in os.listdir(rules_dir):
|
|
134
|
+
if fname.endswith(".md"):
|
|
135
|
+
fpath = os.path.join(rules_dir, fname)
|
|
136
|
+
try:
|
|
137
|
+
with open(fpath, "r", encoding="utf-8") as f:
|
|
138
|
+
content = f.read()
|
|
139
|
+
key = os.path.splitext(fname)[0]
|
|
140
|
+
extra_docs[key] = content
|
|
141
|
+
except Exception:
|
|
142
|
+
continue
|
|
143
|
+
return {"extra_docs": extra_docs}
|
|
71
144
|
|
|
72
145
|
class SingleRoundStrategy(QAConversationStrategy):
|
|
73
146
|
"""
|
|
@@ -81,7 +154,7 @@ class SingleRoundStrategy(QAConversationStrategy):
|
|
|
81
154
|
return messages
|
|
82
155
|
|
|
83
156
|
@byzerllm.prompt()
|
|
84
|
-
def
|
|
157
|
+
def _single_round_answer_question_old(
|
|
85
158
|
self, relevant_docs: List[str], conversations: List[Dict[str, str]], local_image_host: str
|
|
86
159
|
) -> Generator[str, None, None]:
|
|
87
160
|
"""
|
|
@@ -120,26 +193,103 @@ class SingleRoundStrategy(QAConversationStrategy):
|
|
|
120
193
|
例如:/path/to/images/image.png, 返回 http://{{ local_image_host }}/static/path/to/images/image.png
|
|
121
194
|
{% endif %}
|
|
122
195
|
"""
|
|
196
|
+
|
|
197
|
+
@byzerllm.prompt()
|
|
198
|
+
def _single_round_answer_question(
|
|
199
|
+
self, relevant_docs: List[str], conversations: List[Dict[str, str]], local_image_host: str
|
|
200
|
+
) -> Generator[str, None, None]:
|
|
201
|
+
"""
|
|
202
|
+
You are a knowledgeable assistant capable of answering any user question strictly based on the retrieved documents.
|
|
203
|
+
|
|
204
|
+
====
|
|
205
|
+
|
|
206
|
+
FILES CONTEXT
|
|
207
|
+
|
|
208
|
+
The following files are provided to you as context for the user's task. Use these files to understand the project and answer questions strictly based on their content.
|
|
209
|
+
|
|
210
|
+
<documents>
|
|
211
|
+
{% for doc in relevant_docs %}
|
|
212
|
+
{{ doc }}
|
|
213
|
+
{% endfor %}
|
|
214
|
+
</documents>
|
|
215
|
+
|
|
216
|
+
====
|
|
217
|
+
{% if extra_docs %}
|
|
218
|
+
AUTO EXTENSION DOCS
|
|
219
|
+
|
|
220
|
+
The following extension documents are loaded dynamically to enhance your understanding or provide special instructions, rules, or context.
|
|
221
|
+
|
|
222
|
+
{% for key, value in extra_docs.items() %}
|
|
223
|
+
### {{ key }}
|
|
224
|
+
{{ value }}
|
|
225
|
+
{% endfor %}
|
|
226
|
+
|
|
227
|
+
====
|
|
228
|
+
{% endif %}
|
|
229
|
+
|
|
230
|
+
USER CONVERSATION HISTORY
|
|
231
|
+
|
|
232
|
+
{% for msg in conversations %}
|
|
233
|
+
<{{ msg.role }}>: {{ msg.content }}
|
|
234
|
+
{% endfor %}
|
|
235
|
+
|
|
236
|
+
====
|
|
237
|
+
|
|
238
|
+
INSTRUCTIONS
|
|
239
|
+
|
|
240
|
+
- Use ONLY the information from the provided documents and extension docs.
|
|
241
|
+
- If the documents do not contain enough information to answer, reply: "抱歉,文档中没有足够的信息来回答这个问题。"
|
|
242
|
+
- Do NOT invent, guess, or add information beyond what is provided.
|
|
243
|
+
|
|
244
|
+
- For Markdown images like :
|
|
245
|
+
- Analyze surrounding text to determine relevance.
|
|
246
|
+
- Include relevant images naturally in your answer, preserving image paths.
|
|
247
|
+
- Convert Windows paths to Linux style (e.g., C:\\path\\to\\img.png -> C:/path/to/img.png)
|
|
248
|
+
{% if local_image_host %}
|
|
249
|
+
- Prefix image URLs with http://{{ local_image_host }}/static/
|
|
250
|
+
{% endif %}
|
|
251
|
+
|
|
252
|
+
- Format your answer with Markdown for readability.
|
|
253
|
+
- Always use the language used by the user in their question.
|
|
254
|
+
|
|
255
|
+
"""
|
|
256
|
+
import os
|
|
257
|
+
extra_docs = {}
|
|
258
|
+
rules_dir = os.path.join(getattr(self, 'args', None).source_dir if getattr(self, 'args', None) else ".", ".autocoderrules")
|
|
259
|
+
if os.path.isdir(rules_dir):
|
|
260
|
+
for fname in os.listdir(rules_dir):
|
|
261
|
+
if fname.endswith(".md"):
|
|
262
|
+
fpath = os.path.join(rules_dir, fname)
|
|
263
|
+
try:
|
|
264
|
+
with open(fpath, "r", encoding="utf-8") as f:
|
|
265
|
+
content = f.read()
|
|
266
|
+
key = os.path.splitext(fname)[0]
|
|
267
|
+
extra_docs[key] = content
|
|
268
|
+
except Exception:
|
|
269
|
+
continue
|
|
270
|
+
return {"extra_docs": extra_docs}
|
|
123
271
|
|
|
124
|
-
def get_qa_strategy(
|
|
272
|
+
def get_qa_strategy(args: AutoCoderArgs) -> QAConversationStrategy:
|
|
125
273
|
"""
|
|
126
|
-
Factory method to get the appropriate conversation strategy
|
|
127
|
-
|
|
274
|
+
Factory method to get the appropriate conversation strategy based on AutoCoderArgs
|
|
275
|
+
|
|
128
276
|
Args:
|
|
129
|
-
|
|
130
|
-
|
|
277
|
+
args: AutoCoderArgs instance containing configuration, including strategy name in `rag_qa_conversation_strategy`
|
|
278
|
+
|
|
131
279
|
Returns:
|
|
132
280
|
An instance of the requested strategy
|
|
133
|
-
|
|
281
|
+
|
|
134
282
|
Raises:
|
|
135
283
|
ValueError: If the requested strategy doesn't exist
|
|
136
284
|
"""
|
|
285
|
+
strategy_name = getattr(args, 'rag_qa_conversation_strategy', None) or "multi_round"
|
|
286
|
+
|
|
137
287
|
strategies = {
|
|
138
288
|
"multi_round": MultiRoundStrategy,
|
|
139
289
|
"single_round": SingleRoundStrategy,
|
|
140
290
|
}
|
|
141
|
-
|
|
291
|
+
|
|
142
292
|
if strategy_name not in strategies:
|
|
143
293
|
raise ValueError(f"Unknown strategy: {strategy_name}. Available strategies: {list(strategies.keys())}")
|
|
144
|
-
|
|
294
|
+
|
|
145
295
|
return strategies[strategy_name]()
|
autocoder/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.1.
|
|
1
|
+
__version__ = "0.1.346"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|