fix(ui): show a chat tool run as N tool calls with one status row per call
This commit is contained in:
1 parent
76ffa4e01c
commit
a3eeeca672
3 files changed
+120
-115
No files matched your search
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { Wrench } from "@lucide/vue";
|
||||
import { CircleCheck, CircleX, LoaderCircle } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
|
||||
import { CodeBlock, CodeBlockContent } from "@/components/ui/code-block";
|
||||
@@ -51,6 +51,7 @@ const outcome = computed(
|
||||
"",
|
||||
);
|
||||
const running = computed(() => !outcome.value && !failed.value && !!props.streaming);
|
||||
const argument = computed(() => parameters.value.split("\n", 1)[0]);
|
||||
const detail = computed(() =>
|
||||
[parameters.value && `> ${parameters.value}`, outcome.value].filter(Boolean).join("\n\n"),
|
||||
);
|
||||
@@ -61,8 +62,13 @@ const detail = computed(() =>
|
||||
<TraceCollapsible v-else-if="detail" :default-open="failed">
|
||||
<TraceCollapsibleTrigger>
|
||||
<TraceLine :status="failed ? 'error' : running ? 'running' : undefined">
|
||||
<TraceIcon><Wrench /></TraceIcon>
|
||||
<TraceTitle>{{ name }}</TraceTitle>
|
||||
<TraceIcon>
|
||||
<CircleX v-if="failed" />
|
||||
<LoaderCircle v-else-if="running" class="animate-spin" />
|
||||
<CircleCheck v-else class="text-success" />
|
||||
</TraceIcon>
|
||||
<span class="font-mono text-foreground">{{ name }}</span>
|
||||
<TraceTitle class="font-mono text-xs">{{ argument }}</TraceTitle>
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
@@ -72,7 +78,12 @@ const detail = computed(() =>
|
||||
</TraceCollapsibleContent>
|
||||
</TraceCollapsible>
|
||||
<TraceLine v-else :status="failed ? 'error' : running ? 'running' : undefined">
|
||||
<TraceIcon><Wrench /></TraceIcon>
|
||||
<TraceTitle>{{ name }}</TraceTitle>
|
||||
<TraceIcon>
|
||||
<CircleX v-if="failed" />
|
||||
<LoaderCircle v-else-if="running" class="animate-spin" />
|
||||
<CircleCheck v-else class="text-success" />
|
||||
</TraceIcon>
|
||||
<span class="font-mono text-foreground">{{ name }}</span>
|
||||
<TraceTitle class="font-mono text-xs">{{ argument }}</TraceTitle>
|
||||
</TraceLine>
|
||||
</template>
|
||||
@@ -19,17 +19,10 @@ import type { ChatToolCall as ToolCall } from "./state";
|
||||
*/
|
||||
const props = defineProps<{ tools: ToolCall[]; streaming?: boolean }>();
|
||||
|
||||
const toolName = (tool: ToolCall) => tool.name || tool.Name || tool.tool || "tool";
|
||||
const failed = (tool: ToolCall) => Boolean(tool.err || tool.Err || tool.failed);
|
||||
|
||||
const failures = computed(() => props.tools.filter(failed).length);
|
||||
const anyFailed = computed(() => failures.value > 0);
|
||||
const title = computed(() => {
|
||||
const n = props.tools.length;
|
||||
if (props.streaming) return `Running ${toolName(props.tools[n - 1])}`;
|
||||
const calls = n === 1 ? `Used ${toolName(props.tools[0])}` : `Used ${n} tools`;
|
||||
return failures.value ? `${calls}, ${failures.value} failed` : calls;
|
||||
});
|
||||
const anyFailed = computed(() => props.tools.some(failed));
|
||||
const title = computed(() => `${props.tools.length} tool call${props.tools.length === 1 ? "" : "s"}`);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -41,7 +34,7 @@ const title = computed(() => {
|
||||
</TraceLine>
|
||||
</TraceCollapsibleTrigger>
|
||||
<TraceCollapsibleContent>
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex flex-col gap-1.5">
|
||||
<ChatToolCall
|
||||
v-for="(tool, i) in tools"
|
||||
:key="i"
|
||||
|
||||
Reference in new issue
Block a user