MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / getModelParams

Function getModelParams

src/api/transform/model-params.ts:75–196  ·  view source on GitHub ↗
({
	format,
	modelId,
	model,
	settings,
	defaultTemperature,
}: GetModelParamsOptions<Format>)

Source from the content-addressed store, hash-verified

73export function getModelParams(options: GetModelParamsOptions<"gemini">): GeminiModelParams
74export function getModelParams(options: GetModelParamsOptions<"openrouter">): OpenRouterModelParams
75export function getModelParams({
76 format,
77 modelId,
78 model,
79 settings,
80 defaultTemperature,
81}: GetModelParamsOptions<Format>): ModelParams {
82 const {
83 modelMaxTokens: customMaxTokens,
84 modelMaxThinkingTokens: customMaxThinkingTokens,
85 modelTemperature: customTemperature,
86 reasoningEffort: customReasoningEffort,
87 verbosity: customVerbosity,
88 } = settings
89
90 // Use the centralized logic for computing maxTokens
91 const maxTokens = getModelMaxOutputTokens({
92 modelId,
93 model,
94 settings,
95 format,
96 })
97
98 let temperature = customTemperature ?? model.defaultTemperature ?? defaultTemperature
99 let reasoningBudget: ModelParams["reasoningBudget"] = undefined
100 let reasoningEffort: ModelParams["reasoningEffort"] = undefined
101 const verbosity: VerbosityLevel | undefined = customVerbosity
102
103 if (shouldUseReasoningBudget({ model, settings })) {
104 // Check if this is a Gemini 2.5 Pro model
105 const isGemini25Pro = modelId.includes("gemini-2.5-pro")
106
107 // If `customMaxThinkingTokens` is not specified use the default.
108 // For Gemini 2.5 Pro, default to 128 instead of 8192
109 const defaultThinkingTokens = isGemini25Pro
110 ? GEMINI_25_PRO_MIN_THINKING_TOKENS
111 : DEFAULT_HYBRID_REASONING_MODEL_THINKING_TOKENS
112 reasoningBudget = customMaxThinkingTokens ?? defaultThinkingTokens
113
114 // Reasoning cannot exceed 80% of the `maxTokens` value.
115 // maxTokens should always be defined for reasoning budget models, but add a guard just in case
116 if (maxTokens && reasoningBudget > Math.floor(maxTokens * 0.8)) {
117 reasoningBudget = Math.floor(maxTokens * 0.8)
118 }
119
120 // Reasoning cannot be less than minimum tokens.
121 // For Gemini 2.5 Pro models, the minimum is 128 tokens
122 // For other models, the minimum is 1024 tokens
123 const minThinkingTokens = isGemini25Pro ? GEMINI_25_PRO_MIN_THINKING_TOKENS : 1024
124 if (reasoningBudget < minThinkingTokens) {
125 reasoningBudget = minThinkingTokens
126 }
127
128 // Let's assume that "Hybrid" reasoning models require a temperature of
129 // 1.0 since Anthropic does.
130 temperature = 1.0
131 } else if (shouldUseReasoningEffort({ model, settings })) {
132 // "Traditional" reasoning models use the `reasoningEffort` parameter.

Callers 15

getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
resolveModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90
getModelMethod · 0.90

Calls 7

getModelMaxOutputTokensFunction · 0.90
shouldUseReasoningBudgetFunction · 0.90
shouldUseReasoningEffortFunction · 0.90
getAnthropicReasoningFunction · 0.90
getOpenAiReasoningFunction · 0.90
getGeminiReasoningFunction · 0.90
getOpenRouterReasoningFunction · 0.90

Tested by

no test coverage detected