MCPcopy Create free account
hub / github.com/freecodexyz/free-code / get3PModelFallbackSuggestion

Function get3PModelFallbackSuggestion

src/services/api/errors.ts:940–959  ·  view source on GitHub ↗

* For 3P users, suggest a fallback model when the selected model is unavailable. * Returns a model name suggestion, or undefined if no suggestion is applicable.

(model: string)

Source from the content-addressed store, hash-verified

938 * Returns a model name suggestion, or undefined if no suggestion is applicable.
939 */
940function get3PModelFallbackSuggestion(model: string): string | undefined {
941 if (getAPIProvider() === 'firstParty') {
942 return undefined
943 }
944 // @[MODEL LAUNCH]: Add a fallback suggestion chain for the new model → previous version for 3P
945 const m = model.toLowerCase()
946 // If the failing model looks like an Opus 4.6 variant, suggest the default Opus (4.1 for 3P)
947 if (m.includes('opus-4-6') || m.includes('opus_4_6')) {
948 return getModelStrings().opus41
949 }
950 // If the failing model looks like a Sonnet 4.6 variant, suggest Sonnet 4.5
951 if (m.includes('sonnet-4-6') || m.includes('sonnet_4_6')) {
952 return getModelStrings().sonnet45
953 }
954 // If the failing model looks like a Sonnet 4.5 variant, suggest Sonnet 4
955 if (m.includes('sonnet-4-5') || m.includes('sonnet_4_5')) {
956 return getModelStrings().sonnet40
957 }
958 return undefined
959}
960
961/**
962 * Classifies an API error into a specific error type for analytics tracking.

Callers 1

Calls 2

getAPIProviderFunction · 0.85
getModelStringsFunction · 0.50

Tested by

no test coverage detected