fix API Error: A.map is not a function
This commit is contained in:
@@ -58,15 +58,26 @@ export async function streamOpenAIResponse(
|
|||||||
type: "message",
|
type: "message",
|
||||||
role: "assistant",
|
role: "assistant",
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
content: completion.choices[0].message.content || completion.choices[0].message.tool_calls?.map((item) => {
|
content: completion.choices[0].message.content ||
|
||||||
return {
|
completion.choices[0].message.tool_calls?.map((item) => {
|
||||||
type: 'tool_use',
|
return {
|
||||||
id: item.id,
|
type: "tool_use",
|
||||||
name: item.function?.name,
|
id: item.id,
|
||||||
input: item.function?.arguments ? JSON.parse(item.function.arguments) : {},
|
name: item.function?.name,
|
||||||
};
|
input: item.function?.arguments
|
||||||
}) || '',
|
? JSON.parse(item.function.arguments)
|
||||||
stop_reason: completion.choices[0].finish_reason === 'tool_calls' ? "tool_use" : "end_turn",
|
: {},
|
||||||
|
};
|
||||||
|
}) || [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: "",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
stop_reason:
|
||||||
|
completion.choices[0].finish_reason === "tool_calls"
|
||||||
|
? "tool_use"
|
||||||
|
: "end_turn",
|
||||||
stop_sequence: null,
|
stop_sequence: null,
|
||||||
usage: {
|
usage: {
|
||||||
input_tokens: 100,
|
input_tokens: 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user