Skip to content
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: 3328 fix Amazon Bedrock as LLM provider #3329

Closed
wants to merge 3 commits into from
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,23 @@ export async function generateText({
break;
}

case ModelProviderName.BEDROCK: {
elizaLogger.debug("Initializing Bedrock model.");

const { text: bedrockResponse } = await aiGenerateText({
model: bedrock(model),
maxSteps: maxSteps,
temperature: temperature,
maxTokens: max_response_length,
frequencyPenalty: frequency_penalty,
presencePenalty: presence_penalty,
experimental_telemetry: experimental_telemetry,
});

response = bedrockResponse;
elizaLogger.debug("Received response from Bedrock model.");
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing break statement after the BEDROCK case block will cause execution to fall through to the default case. This means the code will log an "Unsupported provider" error even after successfully handling Bedrock requests. Adding break; before the default case will resolve this issue.

Suggested change
case ModelProviderName.BEDROCK: {
elizaLogger.debug("Initializing Bedrock model.");
const { text: bedrockResponse } = await aiGenerateText({
model: bedrock(model),
maxSteps: maxSteps,
temperature: temperature,
maxTokens: max_response_length,
frequencyPenalty: frequency_penalty,
presencePenalty: presence_penalty,
experimental_telemetry: experimental_telemetry,
});
response = bedrockResponse;
elizaLogger.debug("Received response from Bedrock model.");
}
case ModelProviderName.BEDROCK: {
elizaLogger.debug("Initializing Bedrock model.");
const { text: bedrockResponse } = await aiGenerateText({
model: bedrock(model),
maxSteps: maxSteps,
temperature: temperature,
maxTokens: max_response_length,
frequencyPenalty: frequency_penalty,
presencePenalty: presence_penalty,
experimental_telemetry: experimental_telemetry,
});
response = bedrockResponse;
elizaLogger.debug("Received response from Bedrock model.");
break;
}

Spotted by Graphite Reviewer

Is this helpful? React 👍 or 👎 to let us know.


default: {
const errorMessage = `Unsupported provider: ${provider}`;
elizaLogger.error(errorMessage);
Expand Down