Skip to content
Snippets Groups Projects
Unverified Commit 56746c24 authored by Parham Saidi's avatar Parham Saidi Committed by GitHub
Browse files

fix: bedrock handle empty content and added max tokens export (#1034)

parent 5c1c2c7f
No related branches found
No related tags found
No related merge requests found
---
"@llamaindex/community": patch
---
fix: llama3 patched to handle empty content (can happen with system) and added max tokens export
export { BEDROCK_MODELS, Bedrock } from "./llm/bedrock/base.js";
export {
BEDROCK_MODELS,
BEDROCK_MODEL_MAX_TOKENS,
Bedrock,
} from "./llm/bedrock/base.js";
......@@ -150,6 +150,18 @@ export type BedrockModelParams = {
maxTokens?: number;
};
export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
{
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET]: 4096,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU]: 4096,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS]: 4096,
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_SONNET]: 4096,
[BEDROCK_MODELS.META_LLAMA2_13B_CHAT]: 2048,
[BEDROCK_MODELS.META_LLAMA2_70B_CHAT]: 2048,
[BEDROCK_MODELS.META_LLAMA3_8B_INSTRUCT]: 2048,
[BEDROCK_MODELS.META_LLAMA3_70B_INSTRUCT]: 2048,
};
const DEFAULT_BEDROCK_PARAMS = {
temperature: 0.1,
topP: 1,
......
......@@ -154,10 +154,10 @@ export const mapChatMessagesToMetaMessages = <T extends ChatMessage>(
messages: T[],
): MetaMessage[] => {
return messages.map((msg) => {
let content: string;
let content: string = "";
if (typeof msg.content === "string") {
content = msg.content;
} else {
} else if (msg.content.length) {
content = (msg.content[0] as MessageContentTextDetail).text;
}
return {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment