antModels.ts
utils/model/antModels.ts
65
Lines
1798
Bytes
6
Exports
2
Imports
10
Keywords
What this is
This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.
Beginner explanation
This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.
How it is used
Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.
Expert explanation
Architecturally, this file intersects with modes. It contains 65 lines, 2 detected imports, and 6 detected exports.
Important relationships
Detected exports
AntModelAntModelSwitchCalloutConfigAntModelOverrideConfiggetAntModelOverrideConfiggetAntModelsresolveAntModel
Keywords
modelantmodeleffortlevelantmodeloverrideconfigprocessuser_typegetfeaturevalue_cached_may_be_stalealiasdescriptionthinking
Detected imports
src/services/analytics/growthbook.js../effort.js
Source notes
This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.
Full source
import { getFeatureValue_CACHED_MAY_BE_STALE } from 'src/services/analytics/growthbook.js'
import type { EffortLevel } from '../effort.js'
export type AntModel = {
alias: string
model: string
label: string
description?: string
defaultEffortValue?: number
defaultEffortLevel?: EffortLevel
contextWindow?: number
defaultMaxTokens?: number
upperMaxTokensLimit?: number
/** Model defaults to adaptive thinking and rejects `thinking: { type: 'disabled' }`. */
alwaysOnThinking?: boolean
}
export type AntModelSwitchCalloutConfig = {
modelAlias?: string
description: string
version: string
}
export type AntModelOverrideConfig = {
defaultModel?: string
defaultModelEffortLevel?: EffortLevel
defaultSystemPromptSuffix?: string
antModels?: AntModel[]
switchCallout?: AntModelSwitchCalloutConfig
}
// @[MODEL LAUNCH]: Update tengu_ant_model_override with new ant-only models
// @[MODEL LAUNCH]: Add the codename to scripts/excluded-strings.txt to prevent it from leaking to external builds.
export function getAntModelOverrideConfig(): AntModelOverrideConfig | null {
if (process.env.USER_TYPE !== 'ant') {
return null
}
return getFeatureValue_CACHED_MAY_BE_STALE<AntModelOverrideConfig | null>(
'tengu_ant_model_override',
null,
)
}
export function getAntModels(): AntModel[] {
if (process.env.USER_TYPE !== 'ant') {
return []
}
return getAntModelOverrideConfig()?.antModels ?? []
}
export function resolveAntModel(
model: string | undefined,
): AntModel | undefined {
if (process.env.USER_TYPE !== 'ant') {
return undefined
}
if (model === undefined) {
return undefined
}
const lower = model.toLowerCase()
return getAntModels().find(
m => m.alias === model || lower.includes(m.model.toLowerCase()),
)
}