import * as React from 'react'; import { FormControl, ListDivider, Switch } from '@mui/joy'; import CodeIcon from '@mui/icons-material/Code'; import EditRoundedIcon from '@mui/icons-material/EditRounded'; import WarningRoundedIcon from '@mui/icons-material/WarningRounded'; import type { DModelDomainId } from '~/common/stores/llms/model.domains.types'; import { AIVndAntInlineFilesPolicy, useAIPreferencesStore } from '~/common/stores/store-ai'; import { FormLabelStart } from '~/common/components/forms/FormLabelStart'; import { FormSelectControl, FormSelectOption } from '~/common/components/forms/FormSelectControl'; import { useLLMSelect } from '~/common/components/forms/useLLMSelect'; import { useModelDomain } from '~/common/stores/llms/hooks/useModelDomain'; import type { ChatThinkingPolicy, TokenCountingMethod } from '../chat/store-app-chat'; import { useChatAutoAI } from '../chat/store-app-chat'; const _keepThinkingBlocksOptions: FormSelectOption[] = [ { value: 'last-only', label: 'Most Recent', description: 'Default', }, { value: 'all', label: 'Preserve All', description: 'Keep all traces', }, { value: 'discard-all', label: 'Discard All', description: 'May reduce quality', }, ] as const; const _vndAntInlineFilesOptions: FormSelectOption[] = [ { value: 'off', label: 'Show', description: 'Keep as links' }, { value: 'inline-file', label: 'Embed', description: 'Default, embed in chat' }, { value: 'inline-file-and-delete', label: 'Embed + Free', description: 'Embed, then free' }, { value: 'discard', label: 'Discard', description: 'Free, never embed' }, ] as const; const _tokenCountingMethodOptions: FormSelectOption[] = [ { value: 'approximate', label: 'Fast', description: 'Lightweight: ~90% approximation', }, { value: 'accurate', label: 'Precise', description: 'Accurate tokenizer, heavier', }, ] as const; function FormControlDomainModel(props: { domainId: DModelDomainId, title: React.ReactNode, description?: React.ReactNode, tooltip?: React.ReactNode, }) { // external state const { domainModelId, assignDomainModelId, assignDomainModelAuto, resolvedModelIsAuto, autoModelLabel } = useModelDomain(props.domainId); const [_llm, llmComponent] = useLLMSelect(domainModelId, assignDomainModelId, { label: '', setLlmToAuto: assignDomainModelAuto, isLlmAuto: resolvedModelIsAuto, autoModelLabel, }); return ( {llmComponent} ); } export function AppChatSettingsAI() { const { autoSuggestAttachmentPrompts, setAutoSuggestAttachmentPrompts, autoSuggestDiagrams, setAutoSuggestDiagrams, autoSuggestHTMLUI, setAutoSuggestHTMLUI, // autoSuggestQuestions, setAutoSuggestQuestions, autoTitleChat, setAutoTitleChat, chatThinkingPolicy, setChatThinkingPolicy, tokenCountingMethod, setTokenCountingMethod, } = useChatAutoAI(); const vndAntInlineFiles = useAIPreferencesStore(state => state.vndAntInlineFiles); const showModelIcons = false; // useUIComplexityMode() === 'extra'; // callbacks const handleAutoSetChatTitleChange = (event: React.ChangeEvent) => setAutoTitleChat(event.target.checked); const handleAutoSuggestAttachmentPromptsChange = (event: React.ChangeEvent) => setAutoSuggestAttachmentPrompts(event.target.checked); const handleAutoSuggestDiagramsChange = (event: React.ChangeEvent) => setAutoSuggestDiagrams(event.target.checked); const handleAutoSuggestHTMLUIChange = (event: React.ChangeEvent) => setAutoSuggestHTMLUI(event.target.checked); // const handleAutoSuggestQuestionsChange = (event: React.ChangeEvent) => setAutoSuggestQuestions(event.target.checked); return <> Coding model} description='Code tasks' tooltip={<> Smart code editing model (must support Tool Calls) with great coding skills and not too slow. Used for:
  • Diagrams generation
  • HTML UI generation
  • Forward compatibility
Ideally select a Sonnet 3.5-class model. } /> Utility model} description='Titles, misc tasks' tooltip={<> Lightweight model (must support Tool Calls) used for "fast", low-cost operations, such as:
  • Chat title generation
  • Attachment prompts
  • Drawing prompts
  • And more
For chat messages and similar high-quality content, the chat model is used instead. } /> title='Anthropic Files' tooltip={<> When Claude uses tools like code execution, it may produce text and image files stored in Anthropic's File API. This setting controls whether Big-AGI should automatically download and embed them in the chat.
  • Show: keep as references.
  • Embed: download and embed text/images (default).
  • Embed + Free: embed, then delete from Anthropic to free storage.
  • Discard: delete from Anthropic without embedding; the file stays in the code sandbox for the model.
Only affects Anthropic models. } options={_vndAntInlineFilesOptions} value={vndAntInlineFiles} onChange={useAIPreferencesStore.getState().setVndAntInlineFiles} /> Automatic AI Functions Auto-augment Messages [Coding model] Creates interactive UI components within chat responses when appropriate.
SECURITY WARNING: THIS TURNS ON JS/HTML CODE EXECUTION WITHIN CHAT MESSAGES
ALPHA QUALITY FOR TESTING ONLY. Use at your own risk. } /> On{' '} : 'Off'} slotProps={{ endDecorator: { sx: { minWidth: 26 } } }} />
{/**/} {/* Vote #228} />*/} {/* */} {/**/} ; }