feat(ai-sdk): Added Support for Google Provider in AI SDK (#2771)

This commit is contained in:
Saket Aryan
2025-05-23 00:37:58 +05:30
committed by GitHub
parent 816039036d
commit d21970efcc
7 changed files with 172 additions and 72 deletions

View File

@@ -18,7 +18,7 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
it("should stream text with onChunk handler", async () => {
const chunkTexts: string[] = [];
const { textStream } = await streamText({
const { textStream } = streamText({
model: mem0(provider.activeModel, {
user_id: userId, // Use the uniform userId
}),
@@ -57,7 +57,9 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
text, // combined text
usage, // combined usage of all steps
} = await generateText({
model: mem0.completion(provider.activeModel), // Ensure the model name is correct
model: mem0.completion(provider.activeModel, {
user_id: userId,
}), // Ensure the model name is correct
maxSteps: 5, // Enable multi-step calls
experimental_continueSteps: true,
prompt:
@@ -68,10 +70,9 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
expect(typeof text).toBe("string");
// Check usage
// promptTokens is a number, so we use toBeCloseTo instead of toBe and it should be in the range 155 to 165
expect(usage.promptTokens).toBeGreaterThanOrEqual(100);
expect(usage.promptTokens).toBeGreaterThanOrEqual(10);
expect(usage.promptTokens).toBeLessThanOrEqual(500);
expect(usage.completionTokens).toBeGreaterThanOrEqual(250); // Check completion tokens are above 250
expect(usage.totalTokens).toBeGreaterThan(400); // Check total tokens are above 400
expect(usage.completionTokens).toBeGreaterThanOrEqual(10);
expect(usage.totalTokens).toBeGreaterThan(10);
});
});