MCPcopy Index your code
hub / github.com/Noumena-Network/code / getModelOptions

Function getModelOptions

src/utils/model/modelOptions.ts:538–605  ·  view source on GitHub ↗
(fastMode = false)

Source from the content-addressed store, hash-verified

536}
537
538export 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)

Callers 5

generateModelSectionFunction · 0.85
ModelPickerFunction · 0.85
runHeadlessStreamingFunction · 0.85

Calls 11

getModelOptionsBaseFunction · 0.85
getInitialMainLoopModelFunction · 0.85
getOpusPlanOptionFunction · 0.85
getAPIProviderFunction · 0.85
getMaxOpusOptionFunction · 0.85
getMergedOpus1MOptionFunction · 0.85
getKnownModelOptionFunction · 0.85
getGlobalConfigFunction · 0.50

Tested by

no test coverage detected