]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/blob
b1daedfc818c338bf1cc5e1d864746f66e364f54
[pkg/ggml/sources/llama.cpp] /
1 <script lang="ts">
2 import { BuiltInTool } from '$lib/enums';
3 import {
4 extractSearchQuery,
5 extractSearchResults,
6 isWebSearchToolName,
7 type AgenticSection
8 } from '$lib/utils';
9 import type { DatabaseMessageExtra } from '$lib/types';
10 import ChatMessageToolCallBlockDefault from './ChatMessageToolCallBlockDefault.svelte';
11 import ChatMessageToolCallBlockEditFile from './ChatMessageToolCallBlockEditFile.svelte';
12 import ChatMessageToolCallBlockExecShellCommand from './ChatMessageToolCallBlockExecShellCommand.svelte';
13 import ChatMessageToolCallBlockFileGlobSearch from './ChatMessageToolCallBlockFileGlobSearch.svelte';
14 import ChatMessageToolCallBlockGetDatetime from './ChatMessageToolCallBlockGetDatetime.svelte';
15 import ChatMessageToolCallBlockGrepSearch from './ChatMessageToolCallBlockGrepSearch.svelte';
16 import ChatMessageToolCallBlockReadFile from './ChatMessageToolCallBlockReadFile.svelte';
17 import ChatMessageToolCallBlockRunJavascript from './ChatMessageToolCallBlockRunJavascript.svelte';
18 import ChatMessageToolCallBlockSearchResults from './ChatMessageToolCallBlockSearchResults.svelte';
19 import ChatMessageToolCallBlockWriteFile from './ChatMessageToolCallBlockWriteFile.svelte';
20
21 interface Props {
22 section: AgenticSection;
23 attachments?: DatabaseMessageExtra[];
24 open: boolean;
25 isStreaming: boolean;
26 isExecuting?: boolean;
27 onToggle?: () => void;
28 }
29
30 let { section, attachments, open, isStreaming, isExecuting, onToggle }: Props = $props();
31
32 const searchResults = $derived(extractSearchResults(section.toolResult));
33 const searchQuery = $derived(extractSearchQuery(section.toolArgs));
34 const isSearchCall = $derived(
35 searchResults.length > 0 || (searchQuery.length > 0 && isWebSearchToolName(section.toolName))
36 );
37 </script>
38
39 {#if isSearchCall}
40 <ChatMessageToolCallBlockSearchResults {section} {open} {isStreaming} {onToggle} />
41 {:else if section.toolName === BuiltInTool.GET_DATETIME}
42 <ChatMessageToolCallBlockGetDatetime {section} {isStreaming} />
43 {:else if section.toolName === BuiltInTool.READ_FILE}
44 <ChatMessageToolCallBlockReadFile {section} {open} {isStreaming} {onToggle} />
45 {:else if section.toolName === BuiltInTool.EDIT_FILE}
46 <ChatMessageToolCallBlockEditFile {section} {open} {isStreaming} {onToggle} />
47 {:else if section.toolName === BuiltInTool.WRITE_FILE}
48 <ChatMessageToolCallBlockWriteFile {section} {open} {isStreaming} {onToggle} />
49 {:else if section.toolName === BuiltInTool.EXEC_SHELL_COMMAND}
50 <ChatMessageToolCallBlockExecShellCommand
51 {section}
52 {open}
53 {isStreaming}
54 {isExecuting}
55 {attachments}
56 {onToggle}
57 />
58 {:else if section.toolName === BuiltInTool.FILE_GLOB_SEARCH}
59 <ChatMessageToolCallBlockFileGlobSearch {section} {open} {isStreaming} {onToggle} />
60 {:else if section.toolName === BuiltInTool.GREP_SEARCH}
61 <ChatMessageToolCallBlockGrepSearch {section} {open} {isStreaming} {onToggle} />
62 {:else if section.toolName === BuiltInTool.RUN_JAVASCRIPT}
63 <ChatMessageToolCallBlockRunJavascript {section} {open} {isStreaming} {onToggle} />
64 {:else}
65 <ChatMessageToolCallBlockDefault {section} {open} {isStreaming} {attachments} {onToggle} />
66 {/if}