Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
fix(cohere): pass toolResults only when needed to cohere endpoint type (#1382)
Browse files
src/lib/server/endpoints/cohere/endpointCohere.ts
CHANGED
@@ -91,12 +91,15 @@ export async function endpointCohere(
|
|
91 |
stopSequences: parameters?.stop,
|
92 |
frequencyPenalty: parameters?.frequency_penalty,
|
93 |
tools,
|
94 |
-
toolResults:
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
|
|
|
|
|
|
100 |
})
|
101 |
.catch(async (err) => {
|
102 |
if (!err.body) throw err;
|
|
|
91 |
stopSequences: parameters?.stop,
|
92 |
frequencyPenalty: parameters?.frequency_penalty,
|
93 |
tools,
|
94 |
+
toolResults:
|
95 |
+
toolResults?.length && toolResults?.length > 0
|
96 |
+
? toolResults?.map((toolResult) => {
|
97 |
+
if (toolResult.status === ToolResultStatus.Error) {
|
98 |
+
return { call: toolResult.call, outputs: [{ error: toolResult.message }] };
|
99 |
+
}
|
100 |
+
return { call: toolResult.call, outputs: toolResult.outputs };
|
101 |
+
})
|
102 |
+
: undefined,
|
103 |
})
|
104 |
.catch(async (err) => {
|
105 |
if (!err.body) throw err;
|