(
npm: string,
options: Record<string, any>,
modelLimit: number,
globalLimit: number,
)
| 348 | } |
| 349 | |
| 350 | export function maxOutputTokens( |
| 351 | npm: string, |
| 352 | options: Record<string, any>, |
| 353 | modelLimit: number, |
| 354 | globalLimit: number, |
| 355 | ): number { |
| 356 | const modelCap = modelLimit || globalLimit |
| 357 | const standardLimit = Math.min(modelCap, globalLimit) |
| 358 | |
| 359 | if (npm === "@ai-sdk/anthropic") { |
| 360 | const thinking = options?.["thinking"] |
| 361 | const budgetTokens = typeof thinking?.["budgetTokens"] === "number" ? thinking["budgetTokens"] : 0 |
| 362 | const enabled = thinking?.["type"] === "enabled" |
| 363 | if (enabled && budgetTokens > 0) { |
| 364 | // Return text tokens so that text + thinking <= model cap, preferring 32k text when possible. |
| 365 | if (budgetTokens + standardLimit <= modelCap) { |
| 366 | return standardLimit |
| 367 | } |
| 368 | return modelCap - budgetTokens |
| 369 | } |
| 370 | } |
| 371 | |
| 372 | return standardLimit |
| 373 | } |
| 374 | |
| 375 | export function schema(model: Provider.Model, schema: JSONSchema.BaseSchema) { |
| 376 | /* |
nothing calls this directly
no outgoing calls
no test coverage detected