ForcePilot/web/src/components/ToolCallingResult/ToolCallRenderer.vue

90 lines
2.8 KiB
Vue
Raw Normal View History

<template>
<component
:is="currentRenderer"
v-if="currentRenderer"
2026-03-04 04:13:05 +08:00
:tool-call="toolCall"
ref="toolRendererRef"
2026-03-04 04:13:05 +08:00
/>
<BaseToolCall v-else-if="!isHidden" :tool-call="toolCall" />
</template>
<script setup>
import { computed, ref } from 'vue'
import BaseToolCall from './BaseToolCall.vue'
import WebSearchTool from './tools/WebSearchTool.vue'
import ListKbsTool from './tools/ListKbsTool.vue'
import GetMindmapTool from './tools/GetMindmapTool.vue'
import QueryKbTool from './tools/QueryKbTool.vue'
import KnowledgeGraphTool from './tools/KnowledgeGraphTool.vue'
import CalculatorTool from './tools/CalculatorTool.vue'
import TodoListTool from './tools/TodoListTool.vue'
import ImageTool from './tools/ImageTool.vue'
import WriteFileTool from './tools/WriteFileTool.vue'
2026-02-03 14:03:57 +08:00
import ReadFileTool from './tools/ReadFileTool.vue'
import ListDirectoryTool from './tools/ListDirectoryTool.vue'
import SearchFileContentTool from './tools/SearchFileContentTool.vue'
import GrepTool from './tools/GrepTool.vue'
2026-02-03 14:03:57 +08:00
import GlobTool from './tools/GlobTool.vue'
import EditFileTool from './tools/EditFileTool.vue'
import MysqlQueryTool from './tools/MysqlQueryTool.vue'
import MysqlDescribeTableTool from './tools/MysqlDescribeTableTool.vue'
import MysqlListTablesTool from './tools/MysqlListTablesTool.vue'
2026-03-09 01:23:15 +08:00
import AskUserQuestionTool from './tools/AskUserQuestionTool.vue'
import ExecuteTool from './tools/ExecuteTool.vue'
import { getToolCallId } from './toolRegistry'
const props = defineProps({
toolCall: {
type: Object,
required: true
}
})
const toolId = computed(() => getToolCallId(props.toolCall))
const TOOL_RENDERERS = {
ask_user_question: AskUserQuestionTool,
bash: ExecuteTool,
calculator: CalculatorTool,
cmd: ExecuteTool,
edit_file: EditFileTool,
execute: ExecuteTool,
get_mindmap: GetMindmapTool,
glob: GlobTool,
grep: GrepTool,
list_directory: ListDirectoryTool,
list_kbs: ListKbsTool,
ls: ListDirectoryTool,
mysql_describe_table: MysqlDescribeTableTool,
mysql_list_tables: MysqlListTablesTool,
mysql_query: MysqlQueryTool,
query_kb: QueryKbTool,
query_knowledge_graph: KnowledgeGraphTool,
read_file: ReadFileTool,
replace: EditFileTool,
run_shell_command: ExecuteTool,
search_file_content: SearchFileContentTool,
tavily_search: WebSearchTool,
text_to_img_qwen_image: ImageTool,
write_file: WriteFileTool,
write_todos: TodoListTool
}
2026-03-29 13:49:54 +08:00
const TOOL_RENDERER_HIDE = ['present_artifacts']
const currentRenderer = computed(() => TOOL_RENDERERS[toolId.value] || null)
const isHidden = computed(() => TOOL_RENDERER_HIDE.includes(toolId.value))
const toolRendererRef = ref(null)
const refreshGraph = () => {
if (toolRendererRef.value && typeof toolRendererRef.value.refreshGraph === 'function') {
toolRendererRef.value.refreshGraph()
}
}
defineExpose({ refreshGraph })
</script>
<style lang="less" scoped></style>