11<script >
2- import { Button , Card , CardBody , CardHeader , Col } from ' @sveltestrap/sveltestrap' ;
2+ import { Button , Card , CardBody , CardHeader , Col , Input } from ' @sveltestrap/sveltestrap' ;
33 import { getLlmProviders , getLlmProviderModels } from ' $lib/services/llm-provider-service' ;
44 import { onMount } from ' svelte' ;
55
66 /** @type {string[]} */
7- let options = [];
7+ let providers = [];
88
99 /** @type {import('$types').AgentModel} */
1010 export let agent;
1111
1212 /** @type {import('$types').LlmModelSetting[]} */
13- let models = []
13+ let models = [];
14+
15+ const lowerLimit = 1 ;
16+ const upperLimit = 10 ;
1417
1518 let config = agent .llm_config ;
1619
1720 onMount (async () => {
18- options = await getLlmProviders ();
19- models = await getLlmProviderModels (config .provider );
21+ providers = await getLlmProviders ();
22+ providers = [' ' , ... providers]
23+ if (!! config .provider ) {
24+ models = await getLlmProviderModels (config .provider );
25+ }
2026 });
2127
22- /** @param {string} provider */
23- async function handleProviderChanged (provider ) {
28+ /** @param {any} e */
29+ async function changeProvider (e ) {
30+ const provider = e .target .value ;
31+ config .provider = provider || null ;
32+
33+ if (!!! provider) {
34+ models = [];
35+ config .model = null ;
36+ return ;
37+ }
38+
2439 config .is_inherit = false ;
2540 models = await getLlmProviderModels (provider);
2641 config .model = models[0 ]? .name ;
2742 }
43+
44+ /** @param {any} e */
45+ function changeModel (e ) {
46+ config .is_inherit = false ;
47+ config .model = e .target .value || null ;
48+ }
49+
50+ /** @param {any} e */
51+ function changeMaxRecursiveDepth (e ) {
52+ let value = Number (e .target .value ) || 0 ;
53+
54+ if (value < lowerLimit) {
55+ value = lowerLimit;
56+ } else if (value > upperLimit) {
57+ value = upperLimit;
58+ }
59+
60+ config .max_recursion_depth = value;
61+ }
2862< / script>
2963
3064< Card>
3872 < / div>
3973
4074 < div class = " mb-3 row" >
41- < label class = " col-md-3 col-form-label" for = " example-large" > Provider< / label>
42- < div class = " col-md-9" >
43- < select class = " form-select" bind: value= {config .provider } on: change= {() => handleProviderChanged (config .provider )}>
44- {#each options as option}
45- < option value= {option}> {option}< / option>
46- {/ each}
47- < / select>
75+ < label for = " example-large" class = " col-md-3 col-form-label" >
76+ Provider
77+ < / label>
78+ < div class = " col-md-9 config-item-container" >
79+ < Input type= " select" value= {config .provider } on: change= {e => changeProvider (e)}>
80+ {#each providers as option}
81+ < option value= {option}> {option}< / option>
82+ {/ each}
83+ < / Input>
4884 < / div>
4985 < / div>
5086
5389 Model
5490 < / label>
5591 < div class = " col-md-9" >
56- < select class = " form- select" bind : value= {config .model } on: change= {() => config . is_inherit = false }>
92+ < Input type = " select" value= {config .model } disabled = { models . length === 0 } on: change= {e => changeModel (e) }>
5793 {#each models as option}
5894 < option value= {option .name }> {option .name }< / option>
5995 {/ each}
60- < / select>
96+ < / Input>
97+ < / div>
98+ < / div>
99+
100+ < div class = " mb-3 row" >
101+ < label for = " example-text-input" class = " col-md-3 col-form-label" >
102+ Maximum recursive depth
103+ < / label>
104+ < div class = " col-md-9" >
105+ < Input type= " number" min= {lowerLimit} max= {upperLimit} style= " text-align: center;" value= {config .max_recursion_depth } on: change= {e => changeMaxRecursiveDepth (e)} / >
61106 < / div>
62107 < / div>
63108 < / CardBody>
64- < / Card>
109+ < / Card>
0 commit comments