]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
eda067662305c83ad0bfae1858bc3520eda9d59d
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { XCircle } from '@lucide/svelte';
3 import { SyntaxHighlightedCode } from '$lib/components/app';
4 import { MAX_HEIGHT_CODE_BLOCK, RESULT_STAT_SEPARATOR } from '$lib/constants';
5 import { type AgenticSection } from '$lib/utils';
6 import { parseWriteFileMeta } from './parsers/write-file';
7 import ToolCallBlock from './ToolCallBlock.svelte';
8
9 interface Props {
10 section: AgenticSection;
11 open: boolean;
12 isStreaming: boolean;
13 onToggle?: () => void;
14 }
15
16 let { section, open, isStreaming, onToggle }: Props = $props();
17
18 const writeFileMeta = $derived(parseWriteFileMeta(section));
19 </script>
20
21 <ToolCallBlock {section} {open} {isStreaming} meta={writeFileMeta} {onToggle}>
22 {#snippet titleSnippet()}
23 <span class="text-muted-foreground">Write file </span>
24 <span class="font-mono">{writeFileMeta?.filePath}</span>
25 {#if writeFileMeta?.errorMessage}
26 <span class="ml-1 text-xs italic text-muted-foreground/70">(failed)</span>
27 {/if}
28 {/snippet}
29
30 {#snippet children(meta, ctx)}
31 {#if meta?.errorMessage}
32 <div
33 class="flex items-start gap-2 rounded bg-red-500/10 p-2 text-xs text-red-600 italic dark:text-red-400"
34 >
35 <XCircle class="mt-0.5 h-3 w-3 shrink-0" />
36 <span>{meta.errorMessage}</span>
37 </div>
38 {:else if meta}
39 <SyntaxHighlightedCode
40 code={meta.content}
41 language={meta.language}
42 maxHeight={MAX_HEIGHT_CODE_BLOCK}
43 streaming={ctx.isCodeStreaming}
44 />
45 <div class="mt-1.5 text-xs text-muted-foreground/70 italic">
46 {#if meta.resultMessage}
47 {meta.resultMessage}{meta.bytesWritten != null ? RESULT_STAT_SEPARATOR : ''}{/if}
48 {#if meta.bytesWritten != null}
49 <span class="font-mono">{meta.bytesWritten}</span>
50 bytes
51 {/if}
52 </div>
53 {/if}
54 {/snippet}
55 </ToolCallBlock>