-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix (provider/bedrock): support budgetTokens #5088
Conversation
I actually don't know if I did the changeset correctly for this. |
docs needs no changeset (only pkg releases) |
…okens in provider options tweak(docs/amazon-bedrock): Standardize on budgetTokens in amazon docs to reflect anthropic tweak(examples/amazon-bedrock): Standarize on budgetTokens
.transform(data => { | ||
if (!data) return data; | ||
|
||
// Normalize the data to ensure we have budget_tokens | ||
if (data.budgetTokens !== undefined && data.budget_tokens === undefined) { | ||
return { | ||
...data, | ||
budget_tokens: data.budgetTokens, | ||
// Remove budgetTokens to avoid duplication | ||
budgetTokens: undefined, | ||
}; | ||
} | ||
|
||
return data; | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this be solved in the thinking budget definition instead of having a transform (line 131)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah let me try that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hesitation here is that if I do:
const BedrockReasoningConfigOptionsSchema = z
.object({
type: z.union([z.literal('enabled'), z.literal('disabled')]),
})
.and(
z.union([
z.object({ budget_tokens: z.number() }),
z.object({ budgetTokens: z.number() }),
])
)
.nullish();
Instead of the transform, it will break type checking here:
const thinkingBudget = reasoningConfigOptions.data?.budget_tokens ??
reasoningConfigOptions.data?.budgetTokens;
I can fix that using in
, but doesn't seem as clean?
e.g.
const thinkingBudget = reasoningConfigOptions.data &&
('budget_tokens' in reasoningConfigOptions.data
? reasoningConfigOptions.data.budget_tokens
: 'budgetTokens' in reasoningConfigOptions.data
? reasoningConfigOptions.data.budgetTokens
: undefined);
I pushed that in: 35cf123
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attempt to simplify: #5093
budgetTokens
budgetTokens
Adds backwards compatibility to support specifying
budgetTokens
in reasoning config for amazon-bedrock provider. This will be transformed tobudget_tokens
before being sent to the model.