diff --git a/backend/services/chat.py b/backend/services/chat.py
index 7ce3943..efd8c13 100644
--- a/backend/services/chat.py
+++ b/backend/services/chat.py
@@ -127,6 +127,11 @@ class ChatService:
yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'thinking', 'content': full_thinking}, ensure_ascii=False)}\n\n"
step_index += 1
+ # Send text as a step if exists (text before tool calls)
+ if full_content:
+ yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'text', 'content': full_content}, ensure_ascii=False)}\n\n"
+ step_index += 1
+
# Also send legacy tool_calls event for backward compatibility
yield f"event: tool_calls\ndata: {json.dumps({'calls': tool_calls_list}, ensure_ascii=False)}\n\n"
@@ -169,6 +174,11 @@ class ChatService:
yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'thinking', 'content': full_thinking}, ensure_ascii=False)}\n\n"
step_index += 1
+ # Send text as a step if exists
+ if full_content:
+ yield f"event: process_step\ndata: {json.dumps({'index': step_index, 'type': 'text', 'content': full_content}, ensure_ascii=False)}\n\n"
+ step_index += 1
+
suggested_title = None
with app.app_context():
# Build content JSON
diff --git a/docs/Design.md b/docs/Design.md
index afe7f93..2289f0c 100644
--- a/docs/Design.md
+++ b/docs/Design.md
@@ -402,7 +402,7 @@ def process_tool_calls(self, tool_calls, context=None):
| `message` | 回复内容的增量片段 |
| `tool_calls` | 工具调用信息 |
| `tool_result` | 工具执行结果 |
-| `process_step` | 处理步骤(按顺序:thinking/tool_call/tool_result),支持交替显示 |
+| `process_step` | 处理步骤(按顺序:thinking/text/tool_call/tool_result),支持穿插显示 |
| `error` | 错误信息 |
| `done` | 回复结束,携带 message_id 和 token_count |
@@ -412,11 +412,14 @@ def process_tool_calls(self, tool_calls, context=None):
// 思考过程
{"index": 0, "type": "thinking", "content": "完整思考内容..."}
+// 回复文本(可穿插在任意步骤之间)
+{"index": 1, "type": "text", "content": "回复文本内容..."}
+
// 工具调用
-{"index": 1, "type": "tool_call", "id": "call_abc123", "name": "web_search", "arguments": "{\"query\": \"...\"}"}
+{"index": 2, "type": "tool_call", "id": "call_abc123", "name": "web_search", "arguments": "{\"query\": \"...\"}"}
// 工具返回
-{"index": 2, "type": "tool_result", "id": "call_abc123", "name": "web_search", "content": "{\"success\": true, ...}", "skipped": false}
+{"index": 3, "type": "tool_result", "id": "call_abc123", "name": "web_search", "content": "{\"success\": true, ...}", "skipped": false}
```
字段说明:
diff --git a/frontend/package-lock.json b/frontend/package-lock.json
index ceef20e..2b6fc93 100644
--- a/frontend/package-lock.json
+++ b/frontend/package-lock.json
@@ -11,6 +11,7 @@
"highlight.js": "^11.10.0",
"katex": "^0.16.40",
"marked": "^15.0.0",
+ "marked-highlight": "^2.2.3",
"vue": "^3.4.0"
},
"devDependencies": {
@@ -1151,6 +1152,7 @@
"resolved": "https://registry.npmmirror.com/marked/-/marked-15.0.12.tgz",
"integrity": "sha512-8dD6FusOQSrpv9Z1rdNMdlSgQOIP880DHqnohobOmYLElGEqAL/JvxvuxZO16r4HtjTlfPRDC1hbvxC9dPN2nA==",
"license": "MIT",
+ "peer": true,
"bin": {
"marked": "bin/marked.js"
},
@@ -1158,6 +1160,15 @@
"node": ">= 18"
}
},
+ "node_modules/marked-highlight": {
+ "version": "2.2.3",
+ "resolved": "https://registry.npmmirror.com/marked-highlight/-/marked-highlight-2.2.3.tgz",
+ "integrity": "sha512-FCfZRxW/msZAiasCML4isYpxyQWKEEx44vOgdn5Kloae+Qc3q4XR7WjpKKf8oMLk7JP9ZCRd2vhtclJFdwxlWQ==",
+ "license": "MIT",
+ "peerDependencies": {
+ "marked": ">=4 <18"
+ }
+ },
"node_modules/nanoid": {
"version": "3.3.11",
"resolved": "https://registry.npmmirror.com/nanoid/-/nanoid-3.3.11.tgz",
diff --git a/frontend/package.json b/frontend/package.json
index 176b2ef..e368977 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -12,6 +12,7 @@
"highlight.js": "^11.10.0",
"katex": "^0.16.40",
"marked": "^15.0.0",
+ "marked-highlight": "^2.2.3",
"vue": "^3.4.0"
},
"devDependencies": {
diff --git a/frontend/src/App.vue b/frontend/src/App.vue
index 5e74dd1..41d151a 100644
--- a/frontend/src/App.vue
+++ b/frontend/src/App.vue
@@ -14,7 +14,6 @@
/>