mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-28 16:24:47 +08:00
feat: add realtime subagent status report
This commit is contained in:
29
frontend/src/core/tools/utils.ts
Normal file
29
frontend/src/core/tools/utils.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import type { ToolCall } from "@langchain/core/messages";
|
||||
import type { AIMessage } from "@langchain/langgraph-sdk";
|
||||
|
||||
import type { Translations } from "../i18n";
|
||||
import { hasToolCalls } from "../messages/utils";
|
||||
|
||||
export function explainLastToolCall(message: AIMessage, t: Translations) {
|
||||
if (hasToolCalls(message)) {
|
||||
const lastToolCall = message.tool_calls![message.tool_calls!.length - 1]!;
|
||||
return explainToolCall(lastToolCall, t);
|
||||
}
|
||||
return t.common.thinking;
|
||||
}
|
||||
|
||||
export function explainToolCall(toolCall: ToolCall, t: Translations) {
|
||||
if (toolCall.name === "web_search" || toolCall.name === "image_search") {
|
||||
return t.toolCalls.searchFor(toolCall.args.query);
|
||||
} else if (toolCall.name === "web_fetch") {
|
||||
return t.toolCalls.viewWebPage;
|
||||
} else if (toolCall.name === "present_files") {
|
||||
return t.toolCalls.presentFiles;
|
||||
} else if (toolCall.name === "write_todos") {
|
||||
return t.toolCalls.writeTodos;
|
||||
} else if (toolCall.args.description) {
|
||||
return toolCall.args.description;
|
||||
} else {
|
||||
return t.toolCalls.useTool(toolCall.name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user