diff --git a/src/lib/helpers/enums.js b/src/lib/helpers/enums.js index 11ed7675..84d02a51 100644 --- a/src/lib/helpers/enums.js +++ b/src/lib/helpers/enums.js @@ -239,10 +239,12 @@ const llmModelCapability = { export const LlmModelCapability = Object.freeze(llmModelCapability); const reasoningEffortLevel = { + None: "none", Minimal: "minimal", Low: "low", Medium: "medium", - High: "high" + High: "high", + XHigh: "xhigh" }; export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel); diff --git a/src/routes/page/agent/[agentId]/agent-components/llm-configs/chat-config.svelte b/src/routes/page/agent/[agentId]/agent-components/llm-configs/chat-config.svelte index 4940300c..007236d9 100644 --- a/src/routes/page/agent/[agentId]/agent-components/llm-configs/chat-config.svelte +++ b/src/routes/page/agent/[agentId]/agent-components/llm-configs/chat-config.svelte @@ -24,9 +24,9 @@ } const recursiveDepthLowerLimit = 1; - + /** @type {import('$commonTypes').LabelValuePair[]} */ - const reasonLevelOptions = [ + const defaultReasonLevelOptions = [ { value: '', label: '' }, ...Object.entries(ReasoningEffortLevel).map(([k, v]) => ({ value: v, @@ -45,6 +45,9 @@ /** @type {import('$commonTypes').LlmModelSetting[]} */ let models = []; + /** @type {import('$commonTypes').LabelValuePair[]} */ + let reasoningLevelOptions = defaultReasonLevelOptions; + $: isReasoningModel = models.find(x => x.name === config.model)?.reasoning != null; $: { if (llmConfigs.length > 0 && innerLlmConfigs.length === 0) { @@ -58,6 +61,7 @@ const foundModel = models.find(x => x.name === config.model); config.provider = foundProvider || null; config.model = foundModel?.name || null; + onModelChanged(config); } } @@ -83,6 +87,7 @@ config.is_inherit = false; models = getLlmModels(provider); config.model = models[0]?.name; + onModelChanged(config); handleAgentChange(); } @@ -90,6 +95,7 @@ function changeModel(e) { config.is_inherit = false; config.model = e.target.value || null; + onModelChanged(config); handleAgentChange(); } @@ -125,6 +131,36 @@ e.preventDefault(); } } + + /** @param {import('$agentTypes').AgentLlmConfig | null} config */ + function onModelChanged(config) { + reasoningLevelOptions = getReasoningLevelOptions(config?.model); + + if (config && !reasoningLevelOptions.some(x => x.value === config.reasoning_effort_level)) { + const defaultOption = reasoningLevelOptions.find(x => !!x.value)?.value || null; + config.reasoning_effort_level = defaultOption; + } + } + + /** @param {string | null | undefined} model */ + function getReasoningLevelOptions(model) { + let options = defaultReasonLevelOptions; + const foundModel = models.find(x => x.name === model); + if (foundModel?.reasoning == null) { + return options; + } + + const defaultOptions = foundModel?.reasoning?.parameters?.EffortLevel?.options; + if (defaultOptions?.length > 0) { + options = [ + { value: '', label: '' }, + // @ts-ignore + ...defaultOptions.map(x => ({ value: x, label: x })) + ]; + } + + return options; + }
@@ -203,11 +239,11 @@ {#if isReasoningModel}
changeReasoningEffortLevel(e)}> - {#each reasonLevelOptions as option} + {#each reasoningLevelOptions as option}