|
24 | 24 | } |
25 | 25 |
|
26 | 26 | const recursiveDepthLowerLimit = 1; |
27 | | - |
| 27 | +
|
28 | 28 | /** @type {import('$commonTypes').LabelValuePair[]} */ |
29 | | - const reasonLevelOptions = [ |
| 29 | + const defaultReasonLevelOptions = [ |
30 | 30 | { value: '', label: '' }, |
31 | 31 | ...Object.entries(ReasoningEffortLevel).map(([k, v]) => ({ |
32 | 32 | value: v, |
|
45 | 45 | /** @type {import('$commonTypes').LlmModelSetting[]} */ |
46 | 46 | let models = []; |
47 | 47 |
|
| 48 | + /** @type {import('$commonTypes').LabelValuePair[]} */ |
| 49 | + let reasoningLevelOptions = defaultReasonLevelOptions; |
| 50 | +
|
48 | 51 | $: isReasoningModel = models.find(x => x.name === config.model)?.reasoning != null; |
49 | 52 | $: { |
50 | 53 | if (llmConfigs.length > 0 && innerLlmConfigs.length === 0) { |
|
58 | 61 | const foundModel = models.find(x => x.name === config.model); |
59 | 62 | config.provider = foundProvider || null; |
60 | 63 | config.model = foundModel?.name || null; |
| 64 | + onModelChanged(config); |
61 | 65 | } |
62 | 66 | } |
63 | 67 |
|
|
83 | 87 | config.is_inherit = false; |
84 | 88 | models = getLlmModels(provider); |
85 | 89 | config.model = models[0]?.name; |
| 90 | + onModelChanged(config); |
86 | 91 | handleAgentChange(); |
87 | 92 | } |
88 | 93 |
|
89 | 94 | /** @param {any} e */ |
90 | 95 | function changeModel(e) { |
91 | 96 | config.is_inherit = false; |
92 | 97 | config.model = e.target.value || null; |
| 98 | + onModelChanged(config); |
93 | 99 | handleAgentChange(); |
94 | 100 | } |
95 | 101 |
|
|
125 | 131 | e.preventDefault(); |
126 | 132 | } |
127 | 133 | } |
| 134 | +
|
| 135 | + /** @param {import('$agentTypes').AgentLlmConfig | null} config */ |
| 136 | + function onModelChanged(config) { |
| 137 | + reasoningLevelOptions = getReasoningLevelOptions(config?.model); |
| 138 | +
|
| 139 | + if (config && !reasoningLevelOptions.some(x => x.value === config.reasoning_effort_level)) { |
| 140 | + const defaultOption = reasoningLevelOptions.find(x => !!x.value)?.value || null; |
| 141 | + config.reasoning_effort_level = defaultOption; |
| 142 | + } |
| 143 | + } |
| 144 | +
|
| 145 | + /** @param {string | null | undefined} model */ |
| 146 | + function getReasoningLevelOptions(model) { |
| 147 | + let options = defaultReasonLevelOptions; |
| 148 | + const foundModel = models.find(x => x.name === model); |
| 149 | + if (foundModel?.reasoning == null) { |
| 150 | + return options; |
| 151 | + } |
| 152 | + |
| 153 | + const defaultOptions = foundModel?.reasoning?.parameters?.EffortLevel?.options; |
| 154 | + if (defaultOptions?.length > 0) { |
| 155 | + options = [ |
| 156 | + { value: '', label: '' }, |
| 157 | + // @ts-ignore |
| 158 | + ...defaultOptions.map(x => ({ value: x, label: x })) |
| 159 | + ]; |
| 160 | + } |
| 161 | +
|
| 162 | + return options; |
| 163 | + } |
128 | 164 | </script> |
129 | 165 |
|
130 | 166 | <div class="agent-config-container"> |
|
203 | 239 | {#if isReasoningModel} |
204 | 240 | <div class="mb-3 row llm-config-item"> |
205 | 241 | <label for="chat-reasoning-effort" class="col-form-label llm-config-label"> |
206 | | - Reasoning effort |
| 242 | + Reasoning level |
207 | 243 | </label> |
208 | 244 | <div class="llm-config-input"> |
209 | 245 | <Input type="select" id="chat-reasoning-effort" value={config.reasoning_effort_level} on:change={e => changeReasoningEffortLevel(e)}> |
210 | | - {#each reasonLevelOptions as option} |
| 246 | + {#each reasoningLevelOptions as option} |
211 | 247 | <option value={option.value} selected={option.value == config.reasoning_effort_level}> |
212 | 248 | {option.label} |
213 | 249 | </option> |
|
0 commit comments