( providerId: string | undefined, )
| 258 | } |
| 259 | |
| 260 | export function getProviderConfigById( |
| 261 | providerId: string | undefined, |
| 262 | ): ActiveProviderConfig { |
| 263 | if (!providerId) { |
| 264 | return getBuiltinProviderConfig('firstParty') |
| 265 | } |
| 266 | |
| 267 | const configuredProviders = getConfiguredProviders() |
| 268 | |
| 269 | if (isBuiltinProviderId(providerId)) { |
| 270 | const builtin = getBuiltinProviderConfig(providerId) |
| 271 | const configured = configuredProviders[providerId] |
| 272 | return configured |
| 273 | ? { |
| 274 | ...builtin, |
| 275 | ...configured, |
| 276 | id: providerId, |
| 277 | type: resolveConfiguredProviderType(providerId, configured), |
| 278 | name: configured.name ?? builtin.name, |
| 279 | isCustom: false, |
| 280 | } |
| 281 | : builtin |
| 282 | } |
| 283 | |
| 284 | const configured = configuredProviders[providerId] |
| 285 | if (!configured) { |
| 286 | return getBuiltinProviderConfig('firstParty') |
| 287 | } |
| 288 | |
| 289 | return { |
| 290 | id: providerId, |
| 291 | type: resolveConfiguredProviderType(providerId, configured), |
| 292 | name: configured.name ?? providerId, |
| 293 | baseURL: configured.baseURL, |
| 294 | apiKeyEnv: configured.apiKeyEnv, |
| 295 | authTokenEnv: configured.authTokenEnv, |
| 296 | defaultModel: configured.defaultModel, |
| 297 | models: configured.models, |
| 298 | smallFastModel: configured.smallFastModel, |
| 299 | region: configured.region, |
| 300 | projectId: configured.projectId, |
| 301 | resource: configured.resource, |
| 302 | isCustom: true, |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | export function getAllProviderConfigs(): ActiveProviderConfig[] { |
| 307 | const customProviderIds = Object.keys(getConfiguredProviders()) |
no test coverage detected