mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-21 17:00:45 +00:00
fix(ai): handle openai responses arguments.done events
This commit is contained in:
parent
c6e966bd1c
commit
151099e17e
1 changed files with 11 additions and 1 deletions
|
|
@ -380,6 +380,11 @@ export async function processResponsesStream<TApi extends Api>(
|
||||||
partial: output,
|
partial: output,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
} else if (event.type === "response.function_call_arguments.done") {
|
||||||
|
if (currentItem?.type === "function_call" && currentBlock?.type === "toolCall") {
|
||||||
|
currentBlock.partialJson = event.arguments;
|
||||||
|
currentBlock.arguments = parseStreamingJson(currentBlock.partialJson);
|
||||||
|
}
|
||||||
} else if (event.type === "response.output_item.done") {
|
} else if (event.type === "response.output_item.done") {
|
||||||
const item = event.item;
|
const item = event.item;
|
||||||
|
|
||||||
|
|
@ -404,13 +409,18 @@ export async function processResponsesStream<TApi extends Api>(
|
||||||
});
|
});
|
||||||
currentBlock = null;
|
currentBlock = null;
|
||||||
} else if (item.type === "function_call") {
|
} else if (item.type === "function_call") {
|
||||||
|
const args =
|
||||||
|
currentBlock?.type === "toolCall" && currentBlock.partialJson
|
||||||
|
? JSON.parse(currentBlock.partialJson)
|
||||||
|
: JSON.parse(item.arguments);
|
||||||
const toolCall: ToolCall = {
|
const toolCall: ToolCall = {
|
||||||
type: "toolCall",
|
type: "toolCall",
|
||||||
id: `${item.call_id}|${item.id}`,
|
id: `${item.call_id}|${item.id}`,
|
||||||
name: item.name,
|
name: item.name,
|
||||||
arguments: JSON.parse(item.arguments),
|
arguments: args,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
currentBlock = null;
|
||||||
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, partial: output });
|
stream.push({ type: "toolcall_end", contentIndex: blockIndex(), toolCall, partial: output });
|
||||||
}
|
}
|
||||||
} else if (event.type === "response.completed") {
|
} else if (event.type === "response.completed") {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue