fix: Fixing tools working with generative-ai (Google) and streamText
YBeletsky117 opened this issue · comments
Yaroslav Beletsky commented
Feature Description
When using generative-ai from Google and streamText from ai, the Stream receives a message about the end of the Stream. But this is not true, since after discovering new functions in the LLM response, the exit status of stream must also be changed
My suggestion
diff --git a/node_modules/@ai-sdk/google/dist/index.js b/node_modules/@ai-sdk/google/dist/index.js
index 9f4b89b..444fe6a 100644
--- a/node_modules/@ai-sdk/google/dist/index.js
+++ b/node_modules/@ai-sdk/google/dist/index.js
@@ -390,6 +390,10 @@ var GoogleGenerativeAILanguageModel = class {
args: toolCall.args
});
hasToolCalls = true;
+ finishReason = mapGoogleGenerativeAIFinishReason({
+ finishReason: candidate.finishReason,
+ hasToolCalls
+ });
}
}
},
Lars Grammel commented
The hasToolCalls
flag is used earlier for any chunk candidate that has a finishReason.