Skip to content

Commit

Permalink
Change bedrock validation to only require at least one user message, …
Browse files Browse the repository at this point in the history
…rather than two messages. (#50)
  • Loading branch information
DavidSouther authored Apr 16, 2024
1 parent 536e776 commit 1ebfb4f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/engine/bedrock/bedrock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export async function generate(
const bedrock = new BedrockRuntimeClient({});
model = MODEL_MAP[model] ?? model;
let messages = c.meta?.messages ?? [];
if (messages.length < 2) {
throw new Error("Not enough messages");
if (!messages.find((m) => m.role == "user")) {
throw new Error("Bedrock must have at least one message with role: user");
}
if (messages.at(-1)?.role == "assistant") {
messages = messages.slice(0, -1);
Expand Down

0 comments on commit 1ebfb4f

Please sign in to comment.