From ba807d7cd3ef4644463bc0dba5faf2b19b2455cd Mon Sep 17 00:00:00 2001 From: aries_ckt <916701291@qq.com> Date: Mon, 29 Jun 2026 09:53:52 +0800 Subject: [PATCH] chore:fmt --- .../openapi/api_v1/tools/html_interpreter.py | 9 ++-- .../openapi/api_v1/tools/question.py | 52 ++++++++++++++----- .../openapi/api_v1/tools/shell_interpreter.py | 4 +- 3 files changed, 48 insertions(+), 17 deletions(-) diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/html_interpreter.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/html_interpreter.py index 942ecd491..7ef16c3e9 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/html_interpreter.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/html_interpreter.py @@ -22,7 +22,8 @@ def make_html_interpreter(react_state: Dict[str, Any], skills_dir: str): "(包含 、、、 等)," "然后传给 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": "...", "title": "title"}.' ), @@ -243,7 +245,8 @@ def make_html_interpreter(react_state: Dict[str, Any], skills_dir: str): if missing: imgs_html = "".join( f'
' - f'' + f'' f"
" for url in missing ) diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/question.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/question.py index 14728f78f..d88480de2 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/question.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/question.py @@ -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, diff --git a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/shell_interpreter.py b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/shell_interpreter.py index be33f1419..631fc0ca2 100644 --- a/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/shell_interpreter.py +++ b/packages/dbgpt-app/src/dbgpt_app/openapi/api_v1/tools/shell_interpreter.py @@ -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 )