From 6a0fa4f9fad3c244cbe92e644a54199ea3e3631b Mon Sep 17 00:00:00 2001 From: Enrico Ros Date: Tue, 18 Nov 2025 19:44:16 -0800 Subject: [PATCH] LLMs: Gemini Parameters --- src/common/stores/llms/llms.parameters.ts | 49 ++++++++++++--- .../llms/models-modal/LLMParametersEditor.tsx | 61 +++++++++++++++++++ src/modules/llms/server/llm.server.types.ts | 11 ++++ 3 files changed, 113 insertions(+), 8 deletions(-) diff --git a/src/common/stores/llms/llms.parameters.ts b/src/common/stores/llms/llms.parameters.ts index 126c11c6d..61b9e161b 100644 --- a/src/common/stores/llms/llms.parameters.ts +++ b/src/common/stores/llms/llms.parameters.ts @@ -126,6 +126,24 @@ export const DModelParameterRegistry = { // No initial value - when undefined, the model decides the aspect ratio } as const, + llmVndGeminiCodeExecution: { + label: 'Code Execution', + type: 'enum' as const, + description: 'Enable automatic Python code generation and execution by the model', + values: ['auto'] as const, + // No initialValue - undefined means off + } as const, + + llmVndGeminiComputerUse: { + label: 'Computer Use Environment', + type: 'enum' as const, + description: 'Environment type for Computer Use tool (required for Computer Use model)', + values: ['browser'] as const, + initialValue: 'browser', + // requiredFallback: 'browser', // See `const _requiredParamId: DModelParameterId[]` in llms.parameters.ts for why custom params don't have required values at AIX invocation... + hidden: true, + } as const, + llmVndGeminiGoogleSearch: { label: 'Google Search', type: 'enum' as const, @@ -134,6 +152,14 @@ export const DModelParameterRegistry = { // No initialValue - undefined means off } as const, + llmVndGeminiMediaResolution: { + label: 'Media Resolution', + type: 'enum' as const, + description: 'Controls vision processing quality for multimodal inputs. Higher resolution improves text reading and detail identification but increases token usage.', + values: ['mr_high', 'mr_medium', 'mr_low'] as const, + // No initialValue - undefined: "If unspecified, the model uses optimal defaults based on the media type." (Images: high, PDFs: medium, Videos: low/medium (rec: high for OCR)) + } as const, + llmVndGeminiShowThoughts: { label: 'Show Thoughts', type: 'boolean' as const, @@ -154,16 +180,23 @@ export const DModelParameterRegistry = { description: 'Budget for extended thinking. 0 disables thinking. If not set, the model chooses automatically.', } as const, - llmVndGeminiComputerUse: { - label: 'Computer Use Environment', + llmVndGeminiThinkingLevel: { + label: 'Thinking Level', type: 'enum' as const, - description: 'Environment type for Computer Use tool (required for Computer Use model)', - values: ['browser'] as const, - initialValue: 'browser', - // requiredFallback: 'browser', // See `const _requiredParamId: DModelParameterId[]` in llms.parameters.ts for why custom params don't have required values at AIX invocation... - hidden: true, + description: 'Controls internal reasoning depth. Replaces thinking_budget for Gemini 3 models. When unset, the model decides dynamically.', + values: ['high', 'medium' /* not present at launch */, 'low' /* default when unset */] as const, + // No initialValue - undefined means 'dynamic', which for Gemini Pro is the same as 'high' (which is the equivalent of 'medium' for OpenAI's effort levels.. somehow) } as const, + // NOTE: we don't have this as a parameter, as for now we use it in tandem with llmVndGeminiGoogleSearch + // llmVndGeminiUrlContext: { + // label: 'URL Context', + // type: 'enum' as const, + // description: 'Enable fetching and analyzing content from URLs provided in prompts (up to 20 URLs, 34MB each)', + // values: ['auto'] as const, + // // No initialValue - undefined means off + // } as const, + // Moonshot-specific parameters llmVndMoonshotWebSearch: { @@ -362,7 +395,7 @@ export function applyModelParameterInitialValues(destValues: DModelParameterValu const _requiredParamId: DModelParameterId[] = [ // 'llmRef', // disabled: we know this can't have a fallback value in the registry 'llmResponseTokens', // DModelParameterRegistry.llmResponseTokens.requiredFallback = FALLBACK_LLM_PARAM_RESPONSE_TOKENS - 'llmTemperature' // DModelParameterRegistry.llmTemperature.requiredFallback = FALLBACK_LLM_PARAM_TEMPERATURE + 'llmTemperature', // DModelParameterRegistry.llmTemperature.requiredFallback = FALLBACK_LLM_PARAM_TEMPERATURE ] as const; export function getAllModelParameterValues(initialParameters: undefined | DModelParameterValues, userParameters?: DModelParameterValues): DModelParameterValues { diff --git a/src/modules/llms/models-modal/LLMParametersEditor.tsx b/src/modules/llms/models-modal/LLMParametersEditor.tsx index 1b392466b..b2c15551b 100644 --- a/src/modules/llms/models-modal/LLMParametersEditor.tsx +++ b/src/modules/llms/models-modal/LLMParametersEditor.tsx @@ -68,6 +68,11 @@ const _geminiAspectRatioOptions = [ { value: '21:9', label: '21:9', description: 'Ultra wide' }, ] as const; +const _geminiCodeExecutionOptions = [ + { value: 'auto', label: 'On', description: 'Enable code generation and execution' }, + { value: _UNSPECIFIED, label: 'Off', description: 'Disabled (default)' }, +] as const; + const _geminiGoogleSearchOptions = [ { value: 'unfiltered', label: 'On', description: 'Web Search' }, { value: '1d', label: 'Last Day', description: 'Last 24 hours' }, @@ -78,6 +83,20 @@ const _geminiGoogleSearchOptions = [ { value: _UNSPECIFIED, label: 'Off', description: 'Default (disabled)' }, ] as const; +const _geminiMediaResolutionOptions = [ + { value: 'mr_high', label: 'High', description: 'Best quality, higher token usage' }, + { value: 'mr_medium', label: 'Medium', description: 'Balanced quality and cost' }, + { value: 'mr_low', label: 'Low', description: 'Faster, lower cost' }, + { value: _UNSPECIFIED, label: 'Auto', description: 'Model optimizes based on media type (default)' }, +] as const; + +const _geminiThinkingLevelOptions = [ + { value: 'high', label: 'High', description: 'Maximum reasoning depth' }, + { value: 'medium', label: 'Medium', description: 'Balanced reasoning' }, + { value: 'low', label: 'Low', description: 'Quick responses (default when unset)' }, + { value: _UNSPECIFIED, label: 'Dynamic', description: 'Model decides automatically (default)' }, +] as const; + const _xaiSearchModeOptions = [ { value: 'auto', label: 'Auto', description: 'Model decides (default)' }, { value: 'on', label: 'On', description: 'Always search active sources' }, @@ -166,9 +185,12 @@ export function LLMParametersEditor(props: { llmVndAntWebFetch, llmVndAntWebSearch, llmVndGeminiAspectRatio, + llmVndGeminiCodeExecution, llmVndGeminiGoogleSearch, + llmVndGeminiMediaResolution, llmVndGeminiShowThoughts, llmVndGeminiThinkingBudget, + llmVndGeminiThinkingLevel, // llmVndMoonshotWebSearch, llmVndOaiReasoningEffort, llmVndOaiReasoningEffort4, @@ -390,6 +412,19 @@ export function LLMParametersEditor(props: { /> )} + {showParam('llmVndGeminiCodeExecution') && ( + { + if (value === _UNSPECIFIED || !value) onRemoveParameter('llmVndGeminiCodeExecution'); + else onChangeParameter({ llmVndGeminiCodeExecution: value }); + }} + options={_geminiCodeExecutionOptions} + /> + )} + {showParam('llmVndGeminiGoogleSearch') && ( )} + {showParam('llmVndGeminiMediaResolution') && ( + { + if (value === _UNSPECIFIED || !value) onRemoveParameter('llmVndGeminiMediaResolution'); + else onChangeParameter({ llmVndGeminiMediaResolution: value }); + }} + options={_geminiMediaResolutionOptions} + /> + )} + + {showParam('llmVndGeminiThinkingLevel') && ( + { + if (value === _UNSPECIFIED || !value) onRemoveParameter('llmVndGeminiThinkingLevel'); + else onChangeParameter({ llmVndGeminiThinkingLevel: value }); + }} + options={_geminiThinkingLevelOptions} + /> + )} + {/*{showParam('llmVndMoonshotWebSearch') && (*/} {/*