Download frontend/src/core/tools/utils.ts from yonagush/deerflow: direct link, hf CLI and curl.
- Browser
- Download file 1.08 kB
-
https://huggingface.co/spaces/yonagush/deerflow/resolve/main/frontend/src/core/tools/utils.ts
- Command line
-
hf download hf://spaces/yonagush/deerflow/frontend/src/core/tools/utils.ts
-
curl -L -o utils.ts https://huggingface.co/spaces/yonagush/deerflow/resolve/main/frontend/src/core/tools/utils.ts
1.08 kB
| 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); | |
| } | |
| } | |