Skip to content

Commit aeeb21a

Browse files
committed
support anthropic_beta as a top level parameter for anthropic on bedrock, support both string and array of strings to be compatible with anthropic signature
1 parent de327f6 commit aeeb21a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/providers/bedrock/chatComplete.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,14 @@ export interface BedrockChatCompletionsParams extends Params {
4343
}
4444

4545
export interface BedrockConverseAnthropicChatCompletionsParams
46-
extends BedrockChatCompletionsParams {
46+
extends Omit<BedrockChatCompletionsParams, 'anthropic_beta'> {
4747
anthropic_version?: string;
4848
user?: string;
4949
thinking?: {
5050
type: string;
5151
budget_tokens: number;
5252
};
53+
anthropic_beta?: string | string[];
5354
}
5455

5556
export interface BedrockConverseCohereChatCompletionsParams
@@ -717,7 +718,9 @@ export const BedrockConverseAnthropicChatCompleteConfig: ProviderConfig = {
717718
transformAnthropicAdditionalModelRequestFields(params),
718719
},
719720
anthropic_beta: {
720-
param: 'anthropic_beta',
721+
param: 'additionalModelRequestFields',
722+
transform: (params: BedrockConverseAnthropicChatCompletionsParams) =>
723+
transformAnthropicAdditionalModelRequestFields(params),
721724
},
722725
};
723726

src/providers/bedrock/utils.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ export const transformAnthropicAdditionalModelRequestFields = (
120120
if (params['thinking']) {
121121
additionalModelRequestFields['thinking'] = params['thinking'];
122122
}
123+
if (params['anthropic_beta']) {
124+
if (typeof params['anthropic_beta'] === 'string') {
125+
additionalModelRequestFields['anthropic_beta'] = [
126+
params['anthropic_beta'],
127+
];
128+
} else {
129+
additionalModelRequestFields['anthropic_beta'] = params['anthropic_beta'];
130+
}
131+
}
123132
return additionalModelRequestFields;
124133
};
125134

0 commit comments

Comments
 (0)