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