]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
e0c701deaa580effe5b9178501a36998864c3d25
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { Clock, Loader2 } from '@lucide/svelte';
3 import { AgenticSectionType } from '$lib/enums';
4 import type { AgenticSection } from '$lib/utils';
5
6 interface Props {
7 section: AgenticSection;
8 isStreaming?: boolean;
9 }
10
11 let { section, isStreaming = false }: Props = $props();
12
13 const isPending = $derived(section.type === AgenticSectionType.TOOL_CALL_PENDING);
14 const isStreamingCall = $derived(section.type === AgenticSectionType.TOOL_CALL_STREAMING);
15 const showSpinner = $derived(isPending || (isStreamingCall && isStreaming));
16
17 type GetDatetimeMeta = {
18 dateString?: string;
19 errorMessage?: string;
20 };
21
22 function parseGetDatetimeMeta(toolResultString: string | undefined): GetDatetimeMeta {
23 if (!toolResultString) return {};
24
25 try {
26 const parsed: unknown = JSON.parse(toolResultString);
27 if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
28 const obj = parsed as Record<string, unknown>;
29 if (typeof obj.error === 'string') return { errorMessage: obj.error };
30 if (typeof obj.result === 'string') return { dateString: obj.result.trim() };
31 }
32 } catch {
33 return { dateString: toolResultString.trim() };
34 }
35
36 return {};
37 }
38
39 const dateMeta = $derived(parseGetDatetimeMeta(section.toolResult));
40 </script>
41
42 <div class="text-muted-foreground flex items-center gap-2 py-1.5">
43 <Clock class="text-muted-foreground/60 h-3.5 w-3.5 shrink-0" />
44 {#if showSpinner}
45 <span class="text-foreground/80 text-sm font-medium">Current time</span>
46 <Loader2 class="text-muted-foreground/70 h-3 w-3 animate-spin" />
47 {:else if dateMeta.errorMessage}
48 <span class="text-foreground/80 text-sm font-medium">Current time&nbsp;</span>
49 <span class="text-red-600 text-xs italic dark:text-red-400">-&nbsp;{dateMeta.errorMessage}</span
50 >
51 {:else if dateMeta.dateString}
52 <span class="text-foreground/80 text-sm font-medium">Current time is&nbsp;</span>
53 <span class="font-mono text-foreground/90 text-sm">{dateMeta.dateString}</span>
54 {:else}
55 <span class="text-foreground/80 text-sm font-medium">Current time</span>
56 {/if}
57 </div>