组件
AI 工具调用 AI Tool
AI 工具调用:复用共享 Collapsible 作为容器。触发器显示调用名称和调用状态,输入与输出折叠在内部。
#基础用法
Input
{"query": "paper stock"}Input
{"query": "paper stock"}Output{"hits": 12}<script setup lang="ts">
import { AiTool } from "@bysages/vue";
</script>
<template>
<!-- The tool call in its states: running and completed. The dot
pairs color with the word — never color alone. -->
<div class="grid gap-3 w-full">
<AiTool name="search_web" status="running">
<template #input>{{ '{"query": "paper stock"}' }}</template>
</AiTool>
<AiTool name="search_web" status="completed" default-open>
<template #input>{{ '{"query": "paper stock"}' }}</template>
<template #output>{{ '{"hits": 12}' }}</template>
</AiTool>
</div>
</template>
#属性
#AiTool
AI 工具调用:复用共享 Collapsible 作为容器。触发器显示调用名称和调用状态,输入与输出折叠在内部。
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
name | String | 调用工具时使用的名称;未通过 label 插槽提供更友好的文字时,触发器原样显示 | |
status | String as PropType<"pending" | "running" | "completed" | "error"> | 调用状态,可为 pending、running、completed 或 error;显示在折叠面板和状态徽章中 | |
defaultOpen | Boolean | false | 设置后折叠面板默认展开,并复用共享折叠组件 |