fix: Stream模式下使用toolChoice,toolCall的function和type可能为null

This commit is contained in:
shilin66
2024-09-12 14:19:11 +08:00
committed by Archer
parent 0abbcf1401
commit 424c745cbb

View File

@@ -423,8 +423,8 @@ async function streamResponse({
// Start call tool
if (toolCall.id) {
callingTool = {
name: toolCall.function.name || '',
arguments: toolCall.function.arguments || ''
name: toolCall.function?.name || '',
arguments: toolCall.function?.arguments || ''
};
} else if (callingTool) {
// Continue call
@@ -442,6 +442,7 @@ async function streamResponse({
toolCalls.push({
...toolCall,
id: toolId,
type: 'function',
function: toolFunction,
toolName: toolNode.name,
toolAvatar: toolNode.avatar