Skip to content

Commit b30a55d

Browse files
author
Jicheng Lu
committed
refine agent template config
1 parent 0d951aa commit b30a55d

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

src/routes/page/agent/[agentId]/agent-components/templates/agent-template-config.svelte

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script>
22
import { onMount } from 'svelte';
3+
import { untrack } from 'svelte';
34
import { INTEGER_REGEX } from '$lib/helpers/constants';
45
import { LlmModelCapability, LlmModelType, ReasoningEffortLevel, ResponseFormat } from '$lib/helpers/enums';
56
import { getLlmConfigs } from '$lib/services/llm-provider-service';
@@ -64,6 +65,21 @@
6465
}
6566
});
6667
68+
$effect(() => {
69+
const provider = template.llm_config?.provider;
70+
const model = template.llm_config?.model;
71+
untrack(() => {
72+
if (provider && llmConfigs.length > 0) {
73+
models = getLlmModels(provider);
74+
reasoningLevelOptions = getReasoningLevelOptions(model);
75+
} else {
76+
models = [];
77+
reasoningLevelOptions = defaultReasonLevelOptions;
78+
}
79+
});
80+
});
81+
82+
6783
/** @param {string} provider */
6884
function getLlmModels(provider) {
6985
return llmConfigs.find(x => x.provider === provider)?.models
@@ -197,7 +213,7 @@
197213
<label for="tpl-model" class="form-label config-label">Model</label>
198214
<select class="form-select form-select-sm" id="tpl-model"
199215
value={template.llm_config?.model || ''}
200-
disabled={models.length === 0}
216+
disabled={models.length === 0 || !template.llm_config?.provider}
201217
onchange={e => changeModel(e)}
202218
>
203219
{#each models as option}

src/routes/page/agent/[agentId]/agent-components/templates/agent-template.svelte

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,19 @@
3636
selected_template = unique.length > 0 ? unique[0] : { ...defaultTemplate };
3737
}
3838
39-
return unique.map(x => ({
40-
name: x.name.trim().toLowerCase(),
41-
content: x.content,
42-
response_format: x.response_format || null,
43-
llm_config: x.llm_config || null
44-
}));
39+
return unique.map(x => {
40+
const llmConfig = x.llm_config ? {
41+
...x.llm_config,
42+
max_output_tokens: Number(x.llm_config.max_output_tokens) > 0 ? Number(x.llm_config.max_output_tokens) : null
43+
} : null;
44+
45+
return {
46+
name: x.name.trim().toLowerCase(),
47+
content: x.content,
48+
response_format: x.response_format || null,
49+
llm_config: llmConfig
50+
};
51+
});
4552
}
4653
4754

0 commit comments

Comments
 (0)