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