48 lines
1.4 KiB
Vue
48 lines
1.4 KiB
Vue
<script setup lang="ts">
|
|
import { Wrench } from "@lucide/vue";
|
|
import { computed } from "vue";
|
|
|
|
import {
|
|
TraceCollapsible,
|
|
TraceCollapsibleContent,
|
|
TraceCollapsibleTrigger,
|
|
TraceIcon,
|
|
TraceLine,
|
|
TraceTitle,
|
|
} from "@/components/ui/trace";
|
|
import ChatToolCall from "./ChatToolCall.vue";
|
|
import type { ChatToolCall as ToolCall } from "./state";
|
|
|
|
/**
|
|
* A run of consecutive tool calls as one line, opened to the individual
|
|
* calls. A failure anywhere in the run opens it.
|
|
*/
|
|
const props = defineProps<{ tools: ToolCall[]; streaming?: boolean }>();
|
|
|
|
const failed = (tool: ToolCall) => Boolean(tool.err || tool.Err || tool.failed);
|
|
|
|
const anyFailed = computed(() => props.tools.some(failed));
|
|
const title = computed(() => `${props.tools.length} tool call${props.tools.length === 1 ? "" : "s"}`);
|
|
</script>
|
|
|
|
<template>
|
|
<TraceCollapsible :default-open="anyFailed">
|
|
<TraceCollapsibleTrigger>
|
|
<TraceLine :status="anyFailed ? 'error' : undefined">
|
|
<TraceIcon><Wrench /></TraceIcon>
|
|
<TraceTitle class="truncate">{{ title }}</TraceTitle>
|
|
</TraceLine>
|
|
</TraceCollapsibleTrigger>
|
|
<TraceCollapsibleContent>
|
|
<div class="flex flex-col gap-1.5">
|
|
<ChatToolCall
|
|
v-for="(tool, i) in tools"
|
|
:key="i"
|
|
:tool="tool"
|
|
:streaming="streaming && i === tools.length - 1"
|
|
/>
|
|
</div>
|
|
</TraceCollapsibleContent>
|
|
</TraceCollapsible>
|
|
</template>
|