多智能体页面结构修改
This commit is contained in:
1 parent
8e7fc54548
commit
9bd049923e
17 files changed
+5004
-4075
No files matched your search
@@ -155,7 +155,11 @@ export interface StreamIntentRequest {
|
||||
* "正在输出" so users see what's happening during the inevitable LLM
|
||||
* first-token wait.
|
||||
*/
|
||||
onPhaseChange?: (phase: IntentStreamPhase, toolName?: string) => void;
|
||||
onPhaseChange?: (
|
||||
phase: IntentStreamPhase,
|
||||
toolName?: string,
|
||||
args?: Record<string, unknown>,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export interface StreamIntentResult {
|
||||
@@ -269,10 +273,14 @@ export async function streamIntent(req: StreamIntentRequest): Promise<StreamInte
|
||||
// provided, since the same `tool_calling` phase may surface a new tool).
|
||||
let currentPhase: IntentStreamPhase = "connecting";
|
||||
req.onPhaseChange?.("connecting");
|
||||
const setPhase = (next: IntentStreamPhase, toolName?: string) => {
|
||||
const setPhase = (
|
||||
next: IntentStreamPhase,
|
||||
toolName?: string,
|
||||
args?: Record<string, unknown>,
|
||||
) => {
|
||||
if (next === currentPhase && !toolName) return;
|
||||
currentPhase = next;
|
||||
req.onPhaseChange?.(next, toolName);
|
||||
req.onPhaseChange?.(next, toolName, args);
|
||||
};
|
||||
|
||||
const result: StreamIntentResult = {
|
||||
@@ -364,7 +372,14 @@ export async function streamIntent(req: StreamIntentRequest): Promise<StreamInte
|
||||
? (toolCallChunks[0] as Record<string, unknown>)
|
||||
: null;
|
||||
const toolName = firstCall && typeof firstCall.name === "string" ? firstCall.name : "";
|
||||
setPhase("tool_calling", toolName);
|
||||
// 把 tool args 一并透传给 UI;onPhaseChange 在 useStep1Intent 里
|
||||
// 会把 args 累积进 message.steps,让 MessageStepsCard 渲染路径 chip /
|
||||
// 命令代码块等子节点(与主聊天 MessageGroup 视觉一致)。
|
||||
const toolArgs =
|
||||
firstCall && typeof firstCall.args === "object" && firstCall.args !== null
|
||||
? (firstCall.args as Record<string, unknown>)
|
||||
: undefined;
|
||||
setPhase("tool_calling", toolName, toolArgs);
|
||||
} else if (
|
||||
(chunkType === "ai" || chunkType === "aimessagechunk" || chunkType === "aimessage") &&
|
||||
((typeof content === "string" && content.length > 0) || (Array.isArray(content) && content.length > 0))
|
||||
|
||||
Reference in new issue
Block a user