Vercel AI SDK migration to V5 (#3223)

Co-authored-by: Saket Aryan <94069182+whysosaket@users.noreply.github.com>
This commit is contained in:
Parshva Daftari
2025-08-05 20:27:57 +05:30
committed by GitHub
co-authored by Saket Aryan
parent 42e60d6724
commit 0e18f54d36
23 changed files with 321 additions and 423 deletions
+33 -20
View File
@@ -31,10 +31,8 @@ describe("Tool Calls Tests", () => {
tools: {
weather: tool({
description: "Get the weather in a location",
parameters: z.object({
location: z
.string()
.describe("The location to get the weather for"),
inputSchema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
execute: async ({ location }) => ({
location,
@@ -45,12 +43,21 @@ describe("Tool Calls Tests", () => {
prompt: "What is the temperature in the city that I live in?",
});
// @ts-ignore
const text = result.response.messages[1].content[0].result.location;
// Expect text to be a string
expect(typeof text).toBe("string");
expect(text.length).toBeGreaterThan(0);
// Check if the response is valid
expect(result).toHaveProperty('text');
expect(typeof result.text).toBe("string");
// For tool calls, we should have either text response or tool call results
if (result.text && result.text.length > 0) {
expect(result.text.length).toBeGreaterThan(0);
// Check if the response mentions weather or temperature
expect(result.text.toLowerCase()).toMatch(/(weather|temperature|mumbai)/);
} else {
// If text is empty, check if there are tool call results
expect(result).toHaveProperty('toolResults');
expect(Array.isArray(result.toolResults)).toBe(true);
expect(result.toolResults.length).toBeGreaterThan(0);
}
});
it("should Execute a Tool Call Using Anthropic", async () => {
@@ -67,10 +74,8 @@ describe("Tool Calls Tests", () => {
tools: {
weather: tool({
description: "Get the weather in a location",
parameters: z.object({
location: z
.string()
.describe("The location to get the weather for"),
inputSchema: z.object({
location: z.string().describe("The location to get the weather for"),
}),
execute: async ({ location }) => ({
location,
@@ -81,11 +86,19 @@ describe("Tool Calls Tests", () => {
prompt: "What is the temperature in the city that I live in?",
});
// @ts-ignore
const text = result.response.messages[1].content[0].result.location;
// Expect text to be a string
expect(typeof text).toBe("string");
expect(text.length).toBeGreaterThan(0);
// Check if the response is valid
expect(result).toHaveProperty('text');
expect(typeof result.text).toBe("string");
if (result.text && result.text.length > 0) {
expect(result.text.length).toBeGreaterThan(0);
// Check if the response mentions weather or temperature
expect(result.text.toLowerCase()).toMatch(/(weather|temperature|mumbai)/);
} else {
// If text is empty, check if there are tool call results
expect(result).toHaveProperty('toolResults');
expect(Array.isArray(result.toolResults)).toBe(true);
expect(result.toolResults.length).toBeGreaterThan(0);
}
});
});