Vercel AI SDK migration to V5 (#3223)
Co-authored-by: Saket Aryan <94069182+whysosaket@users.noreply.github.com>
This commit is contained in:
co-authored by
Saket Aryan
parent
42e60d6724
commit
0e18f54d36
@@ -23,32 +23,24 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
|
||||
user_id: userId, // Use the uniform userId
|
||||
}),
|
||||
prompt: "Write only the name of the car I prefer and its color.",
|
||||
onChunk({ chunk }) {
|
||||
if (chunk.type === "text-delta") {
|
||||
// Store chunk text for assertions
|
||||
chunkTexts.push(chunk.textDelta);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Wait for the stream to complete
|
||||
for await (const _ of textStream) {
|
||||
chunkTexts.push(_);
|
||||
}
|
||||
|
||||
// Ensure chunks are collected
|
||||
expect(chunkTexts.length).toBeGreaterThan(0);
|
||||
expect(chunkTexts.every((text) => typeof text === "string")).toBe(true);
|
||||
expect(chunkTexts.every((text) => typeof text === "string" || typeof text === "object")).toBe(true);
|
||||
});
|
||||
|
||||
it("should call onFinish handler without throwing an error", async () => {
|
||||
await streamText({
|
||||
streamText({
|
||||
model: mem0(provider.activeModel, {
|
||||
user_id: userId, // Use the uniform userId
|
||||
}),
|
||||
prompt: "Write only the name of the car I prefer and its color.",
|
||||
onFinish({ text, finishReason, usage }) {
|
||||
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -60,8 +52,6 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
|
||||
model: mem0.completion(provider.activeModel, {
|
||||
user_id: userId,
|
||||
}), // Ensure the model name is correct
|
||||
maxSteps: 5, // Enable multi-step calls
|
||||
experimental_continueSteps: true,
|
||||
prompt:
|
||||
"Suggest me some good cars to buy. Each response MUST HAVE at least 200 words.",
|
||||
});
|
||||
@@ -70,9 +60,9 @@ describe.each(testConfig.providers)('TEXT/STREAM PROPERTIES: Tests with model %s
|
||||
expect(typeof text).toBe("string");
|
||||
|
||||
// Check usage
|
||||
expect(usage.promptTokens).toBeGreaterThanOrEqual(10);
|
||||
expect(usage.promptTokens).toBeLessThanOrEqual(500);
|
||||
expect(usage.completionTokens).toBeGreaterThanOrEqual(10);
|
||||
expect(usage.inputTokens).toBeGreaterThanOrEqual(10);
|
||||
expect(usage.inputTokens).toBeLessThanOrEqual(500);
|
||||
expect(usage.outputTokens).toBeGreaterThanOrEqual(10);
|
||||
expect(usage.totalTokens).toBeGreaterThan(10);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user