]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
4c525daa7b07921e25b2cd5ec31f72e1978359e9
[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 { isStreaming = false, section }: 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
28 if (parsed && typeof parsed === 'object' && !Array.isArray(parsed)) {
29 const obj = parsed as Record<string, unknown>;
30
31 if (typeof obj.error === 'string') return { errorMessage: obj.error };
32
33 if (typeof obj.result === 'string') return { dateString: obj.result.trim() };
34 }
35 } catch {
36 return { dateString: toolResultString.trim() };
37 }
38
39 return {};
40 }
41
42 const dateMeta = $derived(parseGetDatetimeMeta(section.toolResult));
43 </script>
44
45 <div class="text-muted-foreground flex items-center gap-2 py-1.5">
46 <Clock class="text-muted-foreground/60 h-3.5 w-3.5 shrink-0" />
47 {#if showSpinner}
48 <span class="text-foreground/80 text-sm font-medium">Current time</span>
49 <Loader2 class="text-muted-foreground/70 h-3 w-3 animate-spin" />
50 {:else if dateMeta.errorMessage}
51 <span class="text-foreground/80 text-sm font-medium">Current time&nbsp;</span>
52 <span class="text-red-600 text-xs italic dark:text-red-400">-&nbsp;{dateMeta.errorMessage}</span
53 >
54 {:else if dateMeta.dateString}
55 <span class="text-foreground/80 text-sm font-medium">Current time is&nbsp;</span>
56 <span class="font-mono text-foreground/90 text-sm">{dateMeta.dateString}</span>
57 {:else}
58 <span class="text-foreground/80 text-sm font-medium">Current time</span>
59 {/if}
60 </div>