Skip to content

Commit

Permalink
fix(cohere): pass toolResults only when needed to cohere endpoint type (
Browse files Browse the repository at this point in the history
  • Loading branch information
nsarrazin authored Aug 2, 2024
1 parent e5c2b96 commit 6de97af
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/lib/server/endpoints/cohere/endpointCohere.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,15 @@ export async function endpointCohere(
stopSequences: parameters?.stop,
frequencyPenalty: parameters?.frequency_penalty,
tools,
toolResults: toolResults?.map((toolResult) => {
if (toolResult.status === ToolResultStatus.Error) {
return { call: toolResult.call, outputs: [{ error: toolResult.message }] };
}
return { call: toolResult.call, outputs: toolResult.outputs };
}),
toolResults:
toolResults?.length && toolResults?.length > 0
? toolResults?.map((toolResult) => {
if (toolResult.status === ToolResultStatus.Error) {
return { call: toolResult.call, outputs: [{ error: toolResult.message }] };
}
return { call: toolResult.call, outputs: toolResult.outputs };
})
: undefined,
})
.catch(async (err) => {
if (!err.body) throw err;
Expand Down

0 comments on commit 6de97af

Please sign in to comment.