From 95485305c728d73debd593b8f3ecfaabad908a1f Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Wed, 10 Jul 2024 11:35:58 +0530 Subject: [PATCH] Allow assistant message content to be an object for anthropic inside vertex and bedrock --- src/providers/bedrock/chatComplete.ts | 11 +++++++++++ src/providers/google-vertex-ai/chatComplete.ts | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/providers/bedrock/chatComplete.ts b/src/providers/bedrock/chatComplete.ts index 2cd3f799b..bc60752bc 100644 --- a/src/providers/bedrock/chatComplete.ts +++ b/src/providers/bedrock/chatComplete.ts @@ -75,6 +75,17 @@ const transformAssistantMessageForAnthropic = ( type: 'text', text: msg.content, }); + } else if ( + msg.content && + typeof msg.content === 'object' && + msg.content.length + ) { + if (msg.content[0].text) { + content.push({ + type: 'text', + text: msg.content[0].text, + }); + } } if (containsToolCalls) { msg.tool_calls.forEach((toolCall: any) => { diff --git a/src/providers/google-vertex-ai/chatComplete.ts b/src/providers/google-vertex-ai/chatComplete.ts index a64b15ea2..a0661629f 100644 --- a/src/providers/google-vertex-ai/chatComplete.ts +++ b/src/providers/google-vertex-ai/chatComplete.ts @@ -261,6 +261,17 @@ const transformAssistantMessageForAnthropic = ( type: 'text', text: msg.content, }); + } else if ( + msg.content && + typeof msg.content === 'object' && + msg.content.length + ) { + if (msg.content[0].text) { + content.push({ + type: 'text', + text: msg.content[0].text, + }); + } } if (containsToolCalls) { msg.tool_calls.forEach((toolCall: any) => {