Skip to content

Commit

Permalink
wip community tools support
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin committed Dec 16, 2024
1 parent df063d8 commit 33e7478
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/lib/components/ToolLogo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
export let color: string;
export let icon: string;
export let size: "sm" | "md" | "lg" = "md";
export let size: "xs" | "sm" | "md" | "lg" = "md";
$: gradientColor = (() => {
switch (color) {
Expand Down Expand Up @@ -72,6 +72,8 @@
$: sizeClass = (() => {
switch (size) {
case "xs":
return "size-4";
case "sm":
return "size-8";
case "md":
Expand Down
19 changes: 18 additions & 1 deletion src/lib/components/chat/ChatInput.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
webSearchToolId,
} from "$lib/utils/toolIds";
import type { Assistant } from "$lib/types/Assistant";
import { page } from "$app/stores";
import type { ToolFront } from "$lib/types/Tool";
import IconTool from "../icons/IconTool.svelte";

Check failure on line 19 in src/lib/components/chat/ChatInput.svelte

View workflow job for this annotation

GitHub Actions / lint

'IconTool' is defined but never used
import ToolLogo from "../ToolLogo.svelte";
export let files: File[] = [];
export let mimeTypes: string[] = [];
Expand Down Expand Up @@ -92,6 +96,10 @@
textareaElement.focus();
}
});
$: extraTools = $page.data.tools.filter((t: ToolFront) =>
[documentParserToolId, imageGenToolId, webSearchToolId, fetchUrlToolId].includes(t._id)
) satisfies ToolFront[];
</script>

<div class="relative min-w-0 flex-1" on:paste>
Expand Down Expand Up @@ -119,7 +127,7 @@

{#if !assistant}
<div
class="absolute bottom-0 left-0 flex h-8 w-full items-center justify-start gap-2 p-3 text-smd text-gray-500 dark:text-gray-400"
class="mt-auto flex h-8 w-full flex-wrap items-center justify-start gap-2 p-3 text-smd text-gray-500 dark:text-gray-400"
>
<button
class="flex items-center gap-1 transition-all hover:text-gray-400 dark:hover:text-gray-300"
Expand Down Expand Up @@ -189,6 +197,15 @@
Document Parser
{/if}
</button>
{#each extraTools as tool}
<button
class="active-tool flex items-center gap-1 transition-all hover:text-gray-400 dark:hover:text-gray-300"
disabled={loading}
>
<ToolLogo icon={tool.icon} color={tool.color} size="xs" />
{tool.displayName}
</button>
{/each}
{/if}
</div>
{/if}
Expand Down

0 comments on commit 33e7478

Please sign in to comment.