( host: SlashCommandHost, modelDict: Record<string, ModelAlias>, )
| 200 | } |
| 201 | |
| 202 | export function runModelSelector( |
| 203 | host: SlashCommandHost, |
| 204 | modelDict: Record<string, ModelAlias>, |
| 205 | ): Promise<{ alias: string; thinking: ThinkingEffort } | undefined> { |
| 206 | return new Promise((resolve) => { |
| 207 | const firstAlias = Object.keys(modelDict)[0] ?? ''; |
| 208 | const caps = modelDict[firstAlias]?.capabilities ?? []; |
| 209 | const initialThinking = caps.includes('always_thinking') || caps.includes('thinking'); |
| 210 | const selector = new ModelSelectorComponent({ |
| 211 | models: modelDict, |
| 212 | currentValue: firstAlias, |
| 213 | currentThinkingEffort: initialThinking ? 'on' : 'off', |
| 214 | searchable: true, |
| 215 | onSelect: ({ alias, thinking }) => { |
| 216 | host.restoreEditor(); |
| 217 | resolve({ alias, thinking }); |
| 218 | }, |
| 219 | onCancel: () => { |
| 220 | host.restoreEditor(); |
| 221 | resolve(undefined); |
| 222 | }, |
| 223 | }); |
| 224 | host.mountEditorReplacement(selector); |
| 225 | }); |
| 226 | } |
no test coverage detected