Skip to content

Commit f5f0697

Browse files
authored
Merge pull request #409 from iceljc/features/refine-chat-window
adjust reasoning level options based on models
2 parents 1a011ba + e2926d8 commit f5f0697

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

src/lib/helpers/enums.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ const llmModelCapability = {
239239
export const LlmModelCapability = Object.freeze(llmModelCapability);
240240

241241
const reasoningEffortLevel = {
242+
None: "none",
242243
Minimal: "minimal",
243244
Low: "low",
244245
Medium: "medium",
245-
High: "high"
246+
High: "high",
247+
XHigh: "xhigh"
246248
};
247249
export const ReasoningEffortLevel = Object.freeze(reasoningEffortLevel);
248250

src/routes/page/agent/[agentId]/agent-components/llm-configs/chat-config.svelte

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
}
2525
2626
const recursiveDepthLowerLimit = 1;
27-
27+
2828
/** @type {import('$commonTypes').LabelValuePair[]} */
29-
const reasonLevelOptions = [
29+
const defaultReasonLevelOptions = [
3030
{ value: '', label: '' },
3131
...Object.entries(ReasoningEffortLevel).map(([k, v]) => ({
3232
value: v,
@@ -45,6 +45,9 @@
4545
/** @type {import('$commonTypes').LlmModelSetting[]} */
4646
let models = [];
4747
48+
/** @type {import('$commonTypes').LabelValuePair[]} */
49+
let reasoningLevelOptions = defaultReasonLevelOptions;
50+
4851
$: isReasoningModel = models.find(x => x.name === config.model)?.reasoning != null;
4952
$: {
5053
if (llmConfigs.length > 0 && innerLlmConfigs.length === 0) {
@@ -58,6 +61,7 @@
5861
const foundModel = models.find(x => x.name === config.model);
5962
config.provider = foundProvider || null;
6063
config.model = foundModel?.name || null;
64+
onModelChanged(config);
6165
}
6266
}
6367
@@ -83,13 +87,15 @@
8387
config.is_inherit = false;
8488
models = getLlmModels(provider);
8589
config.model = models[0]?.name;
90+
onModelChanged(config);
8691
handleAgentChange();
8792
}
8893
8994
/** @param {any} e */
9095
function changeModel(e) {
9196
config.is_inherit = false;
9297
config.model = e.target.value || null;
98+
onModelChanged(config);
9399
handleAgentChange();
94100
}
95101
@@ -125,6 +131,36 @@
125131
e.preventDefault();
126132
}
127133
}
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+
}
128164
</script>
129165
130166
<div class="agent-config-container">
@@ -203,11 +239,11 @@
203239
{#if isReasoningModel}
204240
<div class="mb-3 row llm-config-item">
205241
<label for="chat-reasoning-effort" class="col-form-label llm-config-label">
206-
Reasoning effort
242+
Reasoning level
207243
</label>
208244
<div class="llm-config-input">
209245
<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}
211247
<option value={option.value} selected={option.value == config.reasoning_effort_level}>
212248
{option.label}
213249
</option>

0 commit comments

Comments
 (0)