( config: KimiConfig, options: ApplyCatalogProviderOptions, )
| 100 | * after the merge. |
| 101 | */ |
| 102 | export function applyCatalogProvider( |
| 103 | config: KimiConfig, |
| 104 | options: ApplyCatalogProviderOptions, |
| 105 | ): { defaultModel: string } { |
| 106 | config.providers[options.providerId] = { |
| 107 | type: options.wire, |
| 108 | baseUrl: options.baseUrl, |
| 109 | apiKey: options.apiKey, |
| 110 | }; |
| 111 | |
| 112 | const models = config.models ?? {}; |
| 113 | for (const [key, alias] of Object.entries(models)) { |
| 114 | if (alias.provider === options.providerId) delete models[key]; |
| 115 | } |
| 116 | for (const model of options.models) { |
| 117 | models[`${options.providerId}/${model.id}`] = catalogModelToAlias(options.providerId, model); |
| 118 | } |
| 119 | config.models = models; |
| 120 | |
| 121 | const defaultModel = `${options.providerId}/${options.selectedModelId}`; |
| 122 | config.defaultModel = defaultModel; |
| 123 | config.thinking = { ...config.thinking, enabled: options.thinking }; |
| 124 | return { defaultModel }; |
| 125 | } |
no test coverage detected