From f3297bedcacbae9d1d9f4ef61662a473a8c45e5f Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Fri, 30 Aug 2024 17:50:42 +0530 Subject: [PATCH 1/2] Fix cohere message param transform --- src/providers/cohere/chatComplete.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/providers/cohere/chatComplete.ts b/src/providers/cohere/chatComplete.ts index 5fc9342be..4193e256d 100644 --- a/src/providers/cohere/chatComplete.ts +++ b/src/providers/cohere/chatComplete.ts @@ -32,7 +32,7 @@ export const CohereChatCompleteConfig: ProviderConfig = { return prompt.content ?.filter((_msg) => _msg.type === 'text') - .map((_msg) => _msg.text); + .reduce((acc, _msg) => acc + _msg.text, ''); }, }, { @@ -44,7 +44,7 @@ export const CohereChatCompleteConfig: ProviderConfig = { 0, messages.length - 1 ); - // generate history and forware it to model + // generate history and forward it to model const history: { message?: string; role: string }[] = messagesWithoutLastMessage.map((message) => { const _message: { role: any; message: string } = { From 232dacca3c6db29976f065a4af72c9f09ec0837e Mon Sep 17 00:00:00 2001 From: Narendranath Gogineni Date: Sat, 31 Aug 2024 14:08:26 +0530 Subject: [PATCH 2/2] fix finish_reason for cohere chat completions --- src/providers/cohere/chatComplete.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/providers/cohere/chatComplete.ts b/src/providers/cohere/chatComplete.ts index 4193e256d..f3c0d2b0a 100644 --- a/src/providers/cohere/chatComplete.ts +++ b/src/providers/cohere/chatComplete.ts @@ -164,7 +164,7 @@ export const CohereChatCompleteResponseTransform: ( { message: { role: 'assistant', content: response.text }, index: 0, - finish_reason: 'length', + finish_reason: response.finish_reason, }, ], usage: {