(fastMode = false)
| 536 | } |
| 537 | |
| 538 | export function getModelOptions(fastMode = false): ModelOption[] { |
| 539 | const options = getModelOptionsBase(fastMode) |
| 540 | |
| 541 | // Add the custom model from the ANTHROPIC_CUSTOM_MODEL_OPTION env var |
| 542 | const envCustomModel = process.env.ANTHROPIC_CUSTOM_MODEL_OPTION |
| 543 | if ( |
| 544 | envCustomModel && |
| 545 | !options.some(existing => existing.value === envCustomModel) |
| 546 | ) { |
| 547 | options.push({ |
| 548 | value: envCustomModel, |
| 549 | label: process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME ?? envCustomModel, |
| 550 | description: |
| 551 | process.env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION ?? |
| 552 | `Custom model (${envCustomModel})`, |
| 553 | }) |
| 554 | } |
| 555 | |
| 556 | // Append additional model options fetched during bootstrap |
| 557 | for (const opt of getGlobalConfig().additionalModelOptionsCache ?? []) { |
| 558 | if (!options.some(existing => existing.value === opt.value)) { |
| 559 | options.push(opt) |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | // Add custom model from either the current model value or the initial one |
| 564 | // if it is not already in the options. |
| 565 | let customModel: ModelSetting = null |
| 566 | const currentMainLoopModel = getUserSpecifiedModelSetting() |
| 567 | const initialMainLoopModel = getInitialMainLoopModel() |
| 568 | if (currentMainLoopModel !== undefined && currentMainLoopModel !== null) { |
| 569 | customModel = currentMainLoopModel |
| 570 | } else if (initialMainLoopModel !== null) { |
| 571 | customModel = initialMainLoopModel |
| 572 | } |
| 573 | if ( |
| 574 | customModel === null || |
| 575 | options.some(opt => modelOptionsReferToSameModel(opt.value, customModel)) |
| 576 | ) { |
| 577 | return filterModelOptionsByAllowlist(options) |
| 578 | } else if (customModel === 'opusplan') { |
| 579 | return filterModelOptionsByAllowlist([...options, getOpusPlanOption()]) |
| 580 | } else if (customModel === 'opus' && getAPIProvider() === 'firstParty') { |
| 581 | return filterModelOptionsByAllowlist([ |
| 582 | ...options, |
| 583 | getMaxOpusOption(fastMode), |
| 584 | ]) |
| 585 | } else if (customModel === 'opus[1m]' && getAPIProvider() === 'firstParty') { |
| 586 | return filterModelOptionsByAllowlist([ |
| 587 | ...options, |
| 588 | getMergedOpus1MOption(fastMode), |
| 589 | ]) |
| 590 | } else { |
| 591 | // Try to show a human-readable label for known Anthropic models, with an |
| 592 | // upgrade hint if the alias now resolves to a newer version. |
| 593 | const knownOption = getKnownModelOption(customModel) |
| 594 | if (knownOption) { |
| 595 | options.push(knownOption) |
no test coverage detected