|
19 | 19 | import ModelSelect from '$lib/components/preset/ModelSelect.svelte'; |
20 | 20 | import PromptEditor from '$lib/components/preset/PromptEditor.svelte'; |
21 | 21 | import Range from '$lib/components/Range.svelte'; |
| 22 | + import Checkbox from '$lib/components/Checkbox.svelte'; |
22 | 23 | import { toast, CustomToastDesc } from '$lib/components/ui/sonner'; |
23 | 24 | import { Label } from '$lib/components/ui/label'; |
24 | 25 | import { Button } from '$lib/components/ui/button'; |
|
343 | 344 | ) { |
344 | 345 | selectedGenConfig.max_tokens = modelDetails.context_length; |
345 | 346 | } |
| 347 | + |
| 348 | + // Removes openai only tools for non-openai models |
| 349 | + if (!modelDetails?.id.startsWith('openai/')) { |
| 350 | + const filterTools = selectedGenConfig.tools?.filter( |
| 351 | + (tool) => !['web_search', 'code_interpreter'].includes(tool.type) |
| 352 | + ); |
| 353 | + selectedGenConfig.tools = filterTools?.length === 0 ? null : filterTools; |
| 354 | + } |
346 | 355 | }} |
347 | 356 | class="w-64 border-transparent bg-[#F9FAFB] hover:bg-[#e1e2e6] data-dark:bg-[#42464e]" |
348 | 357 | /> |
|
669 | 678 | /> |
670 | 679 | </div> |
671 | 680 |
|
672 | | - <div class="flex flex-col space-y-1"> |
673 | | - <Label class="text-xs sm:text-sm">Reasoning effort</Label> |
674 | | - |
675 | | - <Select.Root |
676 | | - allowDeselect |
677 | | - type="single" |
678 | | - bind:value={() => selectedGenConfig.reasoning_effort ?? '', |
679 | | - (v) => (selectedGenConfig.reasoning_effort = v || null)} |
680 | | - > |
681 | | - <Select.Trigger |
682 | | - title="Reasoning effort" |
683 | | - class="mb-1 flex h-10 min-w-full items-center justify-between gap-8 border-transparent bg-[#F2F4F7] pl-3 pr-2 hover:bg-[#e1e2e6] data-dark:bg-[#42464e]" |
684 | | - > |
685 | | - {#snippet children()} |
686 | | - <span |
687 | | - class="line-clamp-1 w-full whitespace-nowrap text-left font-normal capitalize" |
688 | | - > |
689 | | - {selectedGenConfig.reasoning_effort ?? 'Default'} |
690 | | - </span> |
691 | | - {/snippet} |
692 | | - </Select.Trigger> |
693 | | - <Select.Content |
694 | | - data-testid="org-plan-select-list" |
695 | | - class="max-h-64 overflow-y-auto" |
| 681 | + {#if $modelsAvailable |
| 682 | + .find((val) => val.id == selectedGenConfig.model) |
| 683 | + ?.capabilities.includes('reasoning')} |
| 684 | + <div class="flex flex-col space-y-1"> |
| 685 | + <Label class="text-xs sm:text-sm">Reasoning effort</Label> |
| 686 | + |
| 687 | + <Select.Root |
| 688 | + allowDeselect |
| 689 | + type="single" |
| 690 | + bind:value={() => selectedGenConfig.reasoning_effort ?? '', |
| 691 | + (v) => (selectedGenConfig.reasoning_effort = v || null)} |
696 | 692 | > |
697 | | - {#each reasoningEffortEnum as reasoningEffort} |
698 | | - <Select.Item |
699 | | - value={reasoningEffort} |
700 | | - class="flex cursor-pointer justify-between gap-10 capitalize" |
701 | | - > |
702 | | - {reasoningEffort} |
703 | | - </Select.Item> |
704 | | - {/each} |
705 | | - </Select.Content> |
706 | | - </Select.Root> |
707 | | - </div> |
| 693 | + <Select.Trigger |
| 694 | + title="Reasoning effort" |
| 695 | + class="mb-1 flex h-10 min-w-full items-center justify-between gap-8 border-transparent bg-[#F2F4F7] pl-3 pr-2 hover:bg-[#e1e2e6] data-dark:bg-[#42464e]" |
| 696 | + > |
| 697 | + {#snippet children()} |
| 698 | + <span |
| 699 | + class="line-clamp-1 w-full whitespace-nowrap text-left font-normal capitalize" |
| 700 | + > |
| 701 | + {selectedGenConfig.reasoning_effort ?? 'Default'} |
| 702 | + </span> |
| 703 | + {/snippet} |
| 704 | + </Select.Trigger> |
| 705 | + <Select.Content |
| 706 | + data-testid="org-plan-select-list" |
| 707 | + class="max-h-64 overflow-y-auto" |
| 708 | + > |
| 709 | + {#each reasoningEffortEnum as reasoningEffort} |
| 710 | + <Select.Item |
| 711 | + value={reasoningEffort} |
| 712 | + class="flex cursor-pointer justify-between gap-10 capitalize" |
| 713 | + > |
| 714 | + {reasoningEffort} |
| 715 | + </Select.Item> |
| 716 | + {/each} |
| 717 | + </Select.Content> |
| 718 | + </Select.Root> |
| 719 | + </div> |
| 720 | + {/if} |
| 721 | + |
| 722 | + {#if selectedGenConfig.model?.startsWith('openai/')} |
| 723 | + <div class="flex flex-col gap-2 space-y-1"> |
| 724 | + <Label class="text-xs sm:text-sm">OpenAI Tools</Label> |
| 725 | + |
| 726 | + <div class="flex items-center gap-2 pl-1"> |
| 727 | + <Checkbox |
| 728 | + disabled={readonly} |
| 729 | + id="openai-tool-websearch" |
| 730 | + name="openai-tool-websearch" |
| 731 | + class="[&>svg]:h-3 [&>svg]:w-3 [&>svg]:translate-x-[1px]" |
| 732 | + bind:checked={() => |
| 733 | + !!selectedGenConfig.tools?.find( |
| 734 | + (tool) => tool.type === 'web_search' |
| 735 | + ), |
| 736 | + () => { |
| 737 | + if ( |
| 738 | + selectedGenConfig.tools?.find( |
| 739 | + (tool) => tool.type === 'web_search' |
| 740 | + ) |
| 741 | + ) { |
| 742 | + const filterTools = selectedGenConfig.tools.filter( |
| 743 | + (tool) => tool.type !== 'web_search' |
| 744 | + ); |
| 745 | + selectedGenConfig.tools = |
| 746 | + filterTools.length === 0 ? null : filterTools; |
| 747 | + } else { |
| 748 | + selectedGenConfig.tools = [ |
| 749 | + ...(selectedGenConfig.tools ?? []), |
| 750 | + { type: 'web_search' } |
| 751 | + ]; |
| 752 | + } |
| 753 | + }} |
| 754 | + /> |
| 755 | + |
| 756 | + <Label for="openai-tool-websearch">Web Search</Label> |
| 757 | + </div> |
| 758 | + |
| 759 | + <div class="flex items-center gap-2 pl-1"> |
| 760 | + <Checkbox |
| 761 | + disabled={readonly} |
| 762 | + id="openai-tool-codeinterpreter" |
| 763 | + name="openai-tool-codeinterpreter" |
| 764 | + class="[&>svg]:h-3 [&>svg]:w-3 [&>svg]:translate-x-[1px]" |
| 765 | + bind:checked={() => |
| 766 | + !!selectedGenConfig.tools?.find( |
| 767 | + (tool) => tool.type === 'code_interpreter' |
| 768 | + ), |
| 769 | + () => { |
| 770 | + if ( |
| 771 | + selectedGenConfig.tools?.find( |
| 772 | + (tool) => tool.type === 'code_interpreter' |
| 773 | + ) |
| 774 | + ) { |
| 775 | + const filterTools = selectedGenConfig.tools.filter( |
| 776 | + (tool) => tool.type !== 'code_interpreter' |
| 777 | + ); |
| 778 | + selectedGenConfig.tools = |
| 779 | + filterTools.length === 0 ? null : filterTools; |
| 780 | + } else { |
| 781 | + selectedGenConfig.tools = [ |
| 782 | + ...(selectedGenConfig.tools ?? []), |
| 783 | + { type: 'code_interpreter' } |
| 784 | + ]; |
| 785 | + } |
| 786 | + }} |
| 787 | + /> |
| 788 | + |
| 789 | + <Label for="openai-tool-codeinterpreter">Code Interpreter</Label> |
| 790 | + </div> |
| 791 | + </div> |
| 792 | + {/if} |
708 | 793 | </div> |
709 | 794 | </div> |
710 | 795 | </div> |
|
0 commit comments