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 cohere message param transform #562

Merged
merged 2 commits into from
Aug 31, 2024
Merged
Changes from all 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
6 changes: 3 additions & 3 deletions src/providers/cohere/chatComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
},
},
{
Expand All @@ -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 } = {
Expand Down Expand Up @@ -164,7 +164,7 @@ export const CohereChatCompleteResponseTransform: (
{
message: { role: 'assistant', content: response.text },
index: 0,
finish_reason: 'length',
finish_reason: response.finish_reason,
},
],
usage: {
Expand Down
Loading