mirror of
https://github.com/csunny/DB-GPT.git
synced 2026-07-16 17:15:22 +00:00
chore:fmt
This commit is contained in:
@@ -22,7 +22,8 @@ def make_html_interpreter(react_state: Dict[str, Any], skills_dir: str):
|
||||
"(包含 <!DOCTYPE html>、<html>、<head>、<body> 等),"
|
||||
"然后传给 html 参数即可。"
|
||||
"HTML 可以很长,没有长度限制,不需要分段传入。"
|
||||
"【技能模式 - 仅在使用技能时可选】如果正在使用技能(skill),可以用模板模式:"
|
||||
"【技能模式 - 仅在使用技能时可选】"
|
||||
"如果正在使用技能(skill),可以用模板模式:"
|
||||
'{"template_path": "技能名/templates/模板.html", '
|
||||
'"data": {"KEY": "值"}, "title": "标题"}。'
|
||||
'也可以用文件模式:{"file_path": "/path/to/report.html"}'
|
||||
@@ -66,7 +67,8 @@ def make_html_interpreter(react_state: Dict[str, Any], skills_dir: str):
|
||||
"output_type": "text",
|
||||
"content": (
|
||||
f"Template not found: {tp}. "
|
||||
"Please retry using the `html` parameter directly — "
|
||||
"Please retry using the `html` parameter "
|
||||
"directly — "
|
||||
"generate complete HTML yourself and pass it via "
|
||||
'{"html": "<html>...</html>", "title": "title"}.'
|
||||
),
|
||||
@@ -243,7 +245,8 @@ def make_html_interpreter(react_state: Dict[str, Any], skills_dir: str):
|
||||
if missing:
|
||||
imgs_html = "".join(
|
||||
f'<div style="margin:16px 0">'
|
||||
f'<img src="{url}" style="max-width:100%;height:auto;border-radius:8px">'
|
||||
f'<img src="{url}" '
|
||||
f'style="max-width:100%;height:auto;border-radius:8px">'
|
||||
f"</div>"
|
||||
for url in missing
|
||||
)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""question tool — human-in-the-loop: ask the user questions and block until answered."""
|
||||
"""question tool — ask user questions and block until answered."""
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
@@ -12,18 +12,28 @@ from .question_manager import question_manager
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_DESCRIPTION = """\
|
||||
Use this tool when you need to ask the user questions during execution. This allows you to:
|
||||
Use this tool when you need to ask the user questions during \
|
||||
execution. This allows you to:
|
||||
1. Gather user preferences or requirements
|
||||
2. Clarify ambiguous instructions
|
||||
3. Get decisions on implementation choices as you work
|
||||
4. Offer choices to the user about what direction to take.
|
||||
|
||||
Usage notes:
|
||||
- IMPORTANT: Always write the question text, header, option labels, and descriptions in the SAME language the user is using. If the user writes in English, all content must be in English; if in Chinese, use Chinese, etc.
|
||||
- When `custom` is enabled (default), a "Type your own answer" option is added automatically; don't include "Other" or catch-all options
|
||||
- Answers are returned as arrays of labels; set `multiple: true` to allow selecting more than one
|
||||
- If you recommend a specific option, make that the first option in the list and add "(Recommended)" at the end of the label
|
||||
Parameter: {"questions": [{"question": "...", "header": "...", "options": [{"label": "...", "description": "..."}], "multiple": false}]}
|
||||
- IMPORTANT: Always write the question text, header, option \
|
||||
labels, and descriptions in the SAME language the user is using. \
|
||||
If the user writes in English, all content must be in English; \
|
||||
if in Chinese, use Chinese, etc.
|
||||
- When `custom` is enabled (default), a "Type your own answer" \
|
||||
option is added automatically; don't include "Other" or \
|
||||
catch-all options
|
||||
- Answers are returned as arrays of labels; set `multiple: true` \
|
||||
to allow selecting more than one
|
||||
- If you recommend a specific option, make that the first option \
|
||||
in the list and add "(Recommended)" at the end of the label
|
||||
Parameter: {"questions": [{"question": "...", "header": "...", \
|
||||
"options": [{"label": "...", "description": "..."}], \
|
||||
"multiple": false}]}
|
||||
"""
|
||||
|
||||
|
||||
@@ -92,7 +102,10 @@ def make_question(react_state: Dict[str, Any], stream_callback: Callable):
|
||||
"chunks": [
|
||||
{
|
||||
"output_type": "text",
|
||||
"content": "Question timed out after 300 seconds. Proceeding without user answer.",
|
||||
"content": (
|
||||
"Question timed out after 300 seconds."
|
||||
" Proceeding without user answer."
|
||||
),
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -108,7 +121,10 @@ def make_question(react_state: Dict[str, Any], stream_callback: Callable):
|
||||
"chunks": [
|
||||
{
|
||||
"output_type": "text",
|
||||
"content": "The user dismissed the question. Proceeding without answer.",
|
||||
"content": (
|
||||
"The user dismissed the question."
|
||||
" Proceeding without answer."
|
||||
),
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -117,11 +133,21 @@ def make_question(react_state: Dict[str, Any], stream_callback: Callable):
|
||||
|
||||
# 5. Format answers for the LLM
|
||||
answers = pq.answers or []
|
||||
formatted = ", ".join(
|
||||
f'"{q.get("question", "")}"="{", ".join(answers[i]) if i < len(answers) and answers[i] else "Unanswered"}"'
|
||||
for i, q in enumerate(parsed_questions)
|
||||
parts = []
|
||||
for i, q in enumerate(parsed_questions):
|
||||
q_text = q.get("question", "")
|
||||
a_text = (
|
||||
", ".join(answers[i])
|
||||
if i < len(answers) and answers[i]
|
||||
else "Unanswered"
|
||||
)
|
||||
parts.append(f'"{q_text}"="{a_text}"')
|
||||
formatted = ", ".join(parts)
|
||||
output = (
|
||||
f"User has answered your questions: {formatted}."
|
||||
" You can now continue with the user's answers"
|
||||
" in mind."
|
||||
)
|
||||
output = f"User has answered your questions: {formatted}. You can now continue with the user's answers in mind."
|
||||
return json.dumps(
|
||||
{"chunks": [{"output_type": "text", "content": output}]},
|
||||
ensure_ascii=False,
|
||||
|
||||
@@ -128,7 +128,9 @@ def make_shell_interpreter(react_state: Dict[str, Any]):
|
||||
ext = os.path.splitext(abs_path)[1].lower()
|
||||
if ext in IMAGE_EXTS:
|
||||
basename = os.path.basename(abs_path)
|
||||
unique_name = f"{uuid.uuid4().hex[:8]}_{basename}"
|
||||
unique_name = (
|
||||
f"{uuid.uuid4().hex[:8]}_{basename}"
|
||||
)
|
||||
dest = os.path.join(
|
||||
STATIC_MESSAGE_IMG_PATH, unique_name
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user