|
1 | 1 | <script> |
2 | 2 | import { slide } from 'svelte/transition'; |
| 3 | + import Select from '$lib/common/dropdowns/Select.svelte'; |
3 | 4 | import { LlmModelCapability, LlmModelType, ReasoningEffortLevel } from '$lib/helpers/enums'; |
4 | 5 |
|
5 | 6 | /** |
|
84 | 85 |
|
85 | 86 | /** @param {any} e */ |
86 | 87 | async function changeProvider(e) { |
87 | | - const provider = e.target.value; |
| 88 | + const values = e?.detail?.selecteds?.map((/** @type {any} */ x) => x.value) || []; |
| 89 | + const provider = values[0] || ''; |
88 | 90 | config.provider = provider || null; |
89 | 91 |
|
90 | 92 | if (!provider) { |
|
104 | 106 |
|
105 | 107 | /** @param {any} e */ |
106 | 108 | function changeModel(e) { |
107 | | - config.model = e.target.value || null; |
| 109 | + const values = e?.detail?.selecteds?.map((/** @type {any} */ x) => x.value) || []; |
| 110 | + config.model = values[0] || null; |
108 | 111 | onModelChanged(config); |
109 | 112 | config.reasoning_effort_level = null; |
110 | 113 | handleAgentChange(); |
111 | 114 | } |
112 | 115 |
|
113 | 116 | /** @param {any} e */ |
114 | 117 | function changeReasoningEffortLevel(e) { |
115 | | - config.reasoning_effort_level = e.target.value || null; |
| 118 | + const values = e?.detail?.selecteds?.map((/** @type {any} */ x) => x.value) || []; |
| 119 | + config.reasoning_effort_level = values[0] || null; |
116 | 120 | handleAgentChange(); |
117 | 121 | } |
118 | 122 |
|
|
143 | 147 | </script> |
144 | 148 |
|
145 | 149 |
|
146 | | -<div class="agent-config-container"> |
| 150 | +<div class="rc-card"> |
147 | 151 | <div |
148 | | - class="config-header text-center" |
| 152 | + class="rc-header" |
149 | 153 | role="button" |
150 | 154 | tabindex="0" |
151 | 155 | onclick={() => collapsed = !collapsed} |
152 | 156 | onkeydown={(e) => e.key === 'Enter' && (collapsed = !collapsed)} |
153 | 157 | > |
154 | | - <h6 class="mt-1 mb-3 d-flex align-items-center justify-content-center gap-2"> |
| 158 | + <h6 class="rc-header-title"> |
155 | 159 | <i class="mdi {collapsed ? 'mdi-chevron-right' : 'mdi-chevron-down'}"></i> |
156 | 160 | {title} |
157 | 161 | </h6> |
158 | 162 | </div> |
159 | 163 |
|
160 | 164 | {#if !collapsed} |
161 | | - <div transition:slide={{ duration: 200 }}> |
162 | | - <div class="mb-3 row llm-config-item"> |
163 | | - <label for={`provider-${title}`} class="col-form-label llm-config-label"> |
| 165 | + <div transition:slide={{ duration: 200 }} class="rc-body"> |
| 166 | + <div class="rc-field"> |
| 167 | + <label for={`provider-${title}`} class="rc-label"> |
164 | 168 | Provider |
165 | 169 | </label> |
166 | | - <div class="llm-config-input"> |
167 | | - <select class="form-select" id={`provider-${title}`} value={config.provider} onchange={e => changeProvider(e)}> |
168 | | - {#each providers as option} |
169 | | - <option value={option} selected={option == config.provider}> |
170 | | - {option} |
171 | | - </option> |
172 | | - {/each} |
173 | | - </select> |
| 170 | + <div class="rc-input-wrap"> |
| 171 | + <Select |
| 172 | + tag={`provider-${title}`} |
| 173 | + containerStyles={'width: 100%;'} |
| 174 | + placeholder={'Select a provider'} |
| 175 | + selectedValues={config.provider ? [config.provider] : []} |
| 176 | + options={providers.filter(p => !!p).map(p => ({ label: p, value: p }))} |
| 177 | + onselect={e => changeProvider(e)} |
| 178 | + /> |
174 | 179 | </div> |
175 | 180 | </div> |
176 | 181 |
|
177 | | - <div class="mb-3 row llm-config-item"> |
178 | | - <label for={`model-${title}`} class="col-form-label llm-config-label"> |
| 182 | + <div class="rc-field"> |
| 183 | + <label for={`model-${title}`} class="rc-label"> |
179 | 184 | Model |
180 | 185 | </label> |
181 | | - <div class="llm-config-input"> |
182 | | - <select class="form-select" id={`model-${title}`} value={config.model} disabled={models.length === 0} onchange={e => changeModel(e)}> |
183 | | - {#each models as option} |
184 | | - <option value={option.name} selected={option.name == config.model}> |
185 | | - {option.name} |
186 | | - </option> |
187 | | - {/each} |
188 | | - </select> |
| 186 | + <div class="rc-input-wrap"> |
| 187 | + <Select |
| 188 | + tag={`model-${title}`} |
| 189 | + containerStyles={'width: 100%;'} |
| 190 | + placeholder={'Select a model'} |
| 191 | + disabled={models.length === 0} |
| 192 | + selectedValues={config.model ? [config.model] : []} |
| 193 | + options={models.map(m => ({ label: m.name, value: m.name }))} |
| 194 | + onselect={e => changeModel(e)} |
| 195 | + /> |
189 | 196 | </div> |
190 | 197 | </div> |
191 | 198 |
|
192 | 199 | {#if isReasoningModel} |
193 | | - <div class="mb-3 row llm-config-item"> |
194 | | - <label for={`reasoning-${title}`} class="col-form-label llm-config-label"> |
| 200 | + <div class="rc-field"> |
| 201 | + <label for={`reasoning-${title}`} class="rc-label"> |
195 | 202 | Reasoning level |
196 | 203 | </label> |
197 | | - <div class="llm-config-input"> |
198 | | - <select class="form-select" id={`reasoning-${title}`} value={config.reasoning_effort_level} onchange={e => changeReasoningEffortLevel(e)}> |
199 | | - {#each reasoningLevelOptions as option} |
200 | | - <option value={option.value} selected={option.value == config.reasoning_effort_level}> |
201 | | - {option.label} |
202 | | - </option> |
203 | | - {/each} |
204 | | - </select> |
| 204 | + <div class="rc-input-wrap"> |
| 205 | + <Select |
| 206 | + tag={`reasoning-${title}`} |
| 207 | + containerStyles={'width: 100%;'} |
| 208 | + placeholder={'Select a level'} |
| 209 | + selectedValues={config.reasoning_effort_level ? [config.reasoning_effort_level] : []} |
| 210 | + options={reasoningLevelOptions.filter(o => !!o.value)} |
| 211 | + onselect={e => changeReasoningEffortLevel(e)} |
| 212 | + /> |
205 | 213 | </div> |
206 | 214 | </div> |
207 | 215 | {/if} |
|
0 commit comments