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