Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit cdcc4cf

Browse files
committed
feat(aws): make topP optional for Bedrock params
1 parent b241339 commit cdcc4cf

4 files changed

Lines changed: 6 additions & 8 deletions

File tree

packages/community/src/llm/bedrock/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,6 @@ export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
350350

351351
const DEFAULT_BEDROCK_PARAMS = {
352352
temperature: 0.1,
353-
topP: 1,
354353
maxTokens: 1024, // required by anthropic
355354
};
356355

@@ -364,7 +363,7 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
364363
protected actualModel: BEDROCK_MODELS | INFERENCE_BEDROCK_MODELS;
365364
model: BEDROCK_MODELS;
366365
temperature: number;
367-
topP: number;
366+
topP?: number | undefined;
368367
maxTokens?: number;
369368
provider: Provider;
370369
topK?: number;
@@ -384,7 +383,7 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
384383
this.provider = getProvider(this.model);
385384
this.maxTokens = maxTokens ?? DEFAULT_BEDROCK_PARAMS.maxTokens;
386385
this.temperature = temperature ?? DEFAULT_BEDROCK_PARAMS.temperature;
387-
this.topP = topP ?? DEFAULT_BEDROCK_PARAMS.topP;
386+
this.topP = topP;
388387
this.client = new BedrockRuntimeClient(params);
389388
}
390389

packages/core/src/llms/type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export interface CompletionResponse {
130130
export type LLMMetadata = {
131131
model: string;
132132
temperature: number;
133-
topP: number;
133+
topP?: number | undefined;
134134
maxTokens?: number | undefined;
135135
contextWindow: number;
136136
tokenizer: Tokenizers | undefined;

packages/providers/anthropic/src/llm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ export class Anthropic extends ToolCallLLM<
209209
return {
210210
model: this.model,
211211
temperature: this.temperature,
212-
topP: this.topP ?? 0, // XXX: topP needs to be returned but might be undefined for Anthropic
212+
topP: this.topP,
213213
maxTokens: this.maxTokens,
214214
contextWindow:
215215
this.model in ALL_AVAILABLE_ANTHROPIC_MODELS

packages/providers/aws/src/llm/bedrock/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,6 @@ export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
544544

545545
const DEFAULT_BEDROCK_PARAMS = {
546546
temperature: 0.1,
547-
topP: 1,
548547
maxTokens: 1024, // required by anthropic
549548
};
550549

@@ -558,7 +557,7 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
558557
protected actualModel: BEDROCK_MODELS | INFERENCE_BEDROCK_MODELS;
559558
model: BEDROCK_MODELS;
560559
temperature: number;
561-
topP: number;
560+
topP?: number | undefined;
562561
maxTokens?: number;
563562
provider: Provider;
564563
topK?: number;
@@ -578,7 +577,7 @@ export class Bedrock extends ToolCallLLM<BedrockAdditionalChatOptions> {
578577
this.provider = getProvider(this.model);
579578
this.maxTokens = maxTokens ?? DEFAULT_BEDROCK_PARAMS.maxTokens;
580579
this.temperature = temperature ?? DEFAULT_BEDROCK_PARAMS.temperature;
581-
this.topP = topP ?? DEFAULT_BEDROCK_PARAMS.topP;
580+
this.topP = topP;
582581
this.client = new BedrockRuntimeClient(params);
583582
}
584583

0 commit comments

Comments
 (0)