Skip to content

Commit b6fc9ab

Browse files
authored
fixing the adapter tests (TanStack#42)
1 parent 88fa4ef commit b6fc9ab

2 files changed

Lines changed: 21 additions & 36 deletions

File tree

packages/typescript/smoke-tests/adapters/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
"@tanstack/ai-openai": "workspace:*"
1818
},
1919
"devDependencies": {
20+
"@alcyone-labs/zod-to-json-schema": "^4.0.10",
2021
"@types/node": "^24.10.1",
2122
"dotenv": "^17.2.3",
2223
"tsx": "^4.20.6",
23-
"typescript": "5.9.3"
24+
"typescript": "5.9.3",
25+
"zod": "^4.1.13"
2426
}
2527
}

packages/typescript/smoke-tests/adapters/src/index.ts

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
maxIterations,
88
type Tool,
99
} from '@tanstack/ai'
10+
import { z } from 'zod'
1011
import { createAnthropic } from '@tanstack/ai-anthropic'
1112
import { createGemini } from '@tanstack/ai-gemini'
1213
import { ollama } from '@tanstack/ai-ollama'
@@ -110,23 +111,15 @@ async function testTemperatureTool(
110111
const expectedLocation = 'San Francisco'
111112

112113
const temperatureTool = tool({
113-
type: 'function',
114-
function: {
115-
name: 'get_temperature',
116-
description:
117-
'Get the current temperature in degrees for a specific location',
118-
parameters: {
119-
type: 'object',
120-
properties: {
121-
location: {
122-
type: 'string',
123-
description: 'The city or location to get the temperature for',
124-
},
125-
},
126-
required: ['location'],
127-
},
128-
},
129-
execute: async (args: any) => {
114+
name: 'get_temperature',
115+
description:
116+
'Get the current temperature in degrees for a specific location',
117+
inputSchema: z.object({
118+
location: z
119+
.string()
120+
.describe('The city or location to get the temperature for'),
121+
}),
122+
execute: async (args) => {
130123
toolExecuteCalled = true
131124
toolExecuteCallCount++
132125
const callInfo: any = {
@@ -246,24 +239,14 @@ async function testApprovalToolFlow(
246239
error?: string
247240
}> = []
248241

249-
const addToCartTool: Tool = {
250-
type: 'function',
251-
function: {
252-
name: 'addToCart',
253-
description: 'Add an item to the shopping cart',
254-
parameters: {
255-
type: 'object',
256-
properties: {
257-
item: {
258-
type: 'string',
259-
description: 'The name of the item to add to the cart',
260-
},
261-
},
262-
required: ['item'],
263-
},
264-
},
242+
const addToCartTool: Tool = tool({
243+
name: 'addToCart',
244+
description: 'Add an item to the shopping cart',
245+
inputSchema: z.object({
246+
item: z.string().describe('The name of the item to add to the cart'),
247+
}),
265248
needsApproval: true,
266-
execute: async (args: any) => {
249+
execute: async (args) => {
267250
toolExecuteCalled = true
268251
toolExecuteCallCount++
269252
const callInfo: any = {
@@ -281,7 +264,7 @@ async function testApprovalToolFlow(
281264
throw error
282265
}
283266
},
284-
}
267+
})
285268

286269
const messages = [
287270
{

0 commit comments

Comments
 (0)