(fastMode = false)
| 498 | } |
| 499 | |
| 500 | export function getModelOptions(fastMode = false): ModelOption[] { |
| 501 | const options = getModelOptionsBase(fastMode) |
| 502 | |
| 503 | // Add the custom model from the ANTHROPIC_CUSTOM_MODEL_OPTION env var |
| 504 | const envCustomModel = process.env.ANTHROPIC_CUSTOM_MODEL_OPTION |
| 505 | if ( |
| 506 | envCustomModel && |
| 507 | !options.some(existing => existing.value === envCustomModel) |
| 508 | ) { |
| 509 | options.push({ |
| 510 | value: envCustomModel, |
| 511 | label: process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME ?? envCustomModel, |
| 512 | description: |
| 513 | process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION ?? |
| 514 | `Custom model (${envCustomModel})`, |
| 515 | }) |
| 516 | } |
| 517 | |
| 518 | // Append additional model options fetched during bootstrap |
| 519 | for (const opt of getGlobalConfig().additionalModelOptionsCache ?? []) { |
| 520 | if (!options.some(existing => existing.value === opt.value)) { |
| 521 | options.push(opt) |
| 522 | } |
| 523 | } |
| 524 | |
| 525 | // Add custom model from either the current model value or the initial one |
| 526 | // if it is not already in the options. |
| 527 | let customModel: ModelSetting = null |
| 528 | const currentMainLoopModel = getUserSpecifiedModelSetting() |
| 529 | const initialMainLoopModel = getInitialMainLoopModel() |
| 530 | if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) { |
| 531 | customModel = currentMainLoopModel |
| 532 | } else if (initialMainLoopModel !== null) { |
| 533 | customModel = initialMainLoopModel |
| 534 | } |
| 535 | if (customModel === null || options.some(opt => opt.value === customModel)) { |
| 536 | return filterModelOptionsByAllowlist(options) |
| 537 | } else if (customModel === 'opusplan') { |
| 538 | return filterModelOptionsByAllowlist([...options, getOpusPlanOption()]) |
| 539 | } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') { |
| 540 | return filterModelOptionsByAllowlist([ |
| 541 | ...options, |
| 542 | getMaxOpusOption(fastMode), |
| 543 | ]) |
| 544 | } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') { |
| 545 | return filterModelOptionsByAllowlist([ |
| 546 | ...options, |
| 547 | getMergedOpus1MOption(fastMode), |
| 548 | ]) |
| 549 | } else { |
| 550 | // Try to show a human-readable label for known Anthropic models, with an |
| 551 | // upgrade hint if the alias now resolves to a newer version. |
| 552 | const knownOption = getKnownModelOption(customModel) |
| 553 | if (knownOption) { |
| 554 | options.push(knownOption) |
| 555 | } else { |
| 556 | options.push({ |
| 557 | value: customModel, |
no test coverage detected