Skip to content

Commit c5df33c

Browse files
feat: standard (json) schema compliance (TanStack#165)
* feat: standard (json) schema compliance * add changeset * update lock * ci: apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent aaafd69 commit c5df33c

24 files changed

Lines changed: 753 additions & 483 deletions

File tree

.changeset/honest-bugs-tell.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
'@tanstack/tests-adapters': minor
3+
'@tanstack/ai-anthropic': minor
4+
'@tanstack/ai-client': minor
5+
'@tanstack/ai-ollama': minor
6+
'@tanstack/ai-svelte': minor
7+
'@tanstack/ai-react': minor
8+
'@tanstack/ai-solid': minor
9+
'@tanstack/ai-vue': minor
10+
'ts-svelte-chat': minor
11+
'@tanstack/ai': minor
12+
'ts-vue-chat': minor
13+
---
14+
15+
Standard schema / standard json schema support for TanStack AI

examples/ts-react-chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"remark-gfm": "^4.0.1",
3939
"tailwindcss": "^4.1.18",
4040
"vite-tsconfig-paths": "^5.1.4",
41-
"zod": "^4.1.13"
41+
"zod": "^4.2.0"
4242
},
4343
"devDependencies": {
4444
"@tanstack/devtools-vite": "^0.3.11",

examples/ts-solid-chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"solid-markdown": "^2.1.0",
3636
"tailwindcss": "^4.1.18",
3737
"vite-tsconfig-paths": "^5.1.4",
38-
"zod": "^4.1.13"
38+
"zod": "^4.2.0"
3939
},
4040
"devDependencies": {
4141
"@solidjs/testing-library": "^0.8.10",

examples/ts-svelte-chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"lucide-svelte": "^0.468.0",
2424
"marked": "^15.0.6",
2525
"marked-highlight": "^2.2.0",
26-
"zod": "^4.1.13"
26+
"zod": "^4.2.0"
2727
},
2828
"devDependencies": {
2929
"@sveltejs/adapter-auto": "^3.3.1",

examples/ts-vue-chat/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"marked": "^15.0.6",
2222
"vue": "^3.5.25",
2323
"vue-router": "^4.5.0",
24-
"zod": "^4.1.13"
24+
"zod": "^4.2.0"
2525
},
2626
"devDependencies": {
2727
"@tailwindcss/vite": "^4.1.18",

packages/typescript/ai-anthropic/src/tools/custom-tool.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import type { JSONSchema, Tool } from '@tanstack/ai'
2-
import type { z } from 'zod'
1+
import type { JSONSchema, SchemaInput, Tool } from '@tanstack/ai'
32
import type { CacheControl } from '../text/text-provider-options'
43

54
export interface CustomTool {
@@ -53,7 +52,7 @@ export function convertCustomToolToAdapterFormat(tool: Tool): CustomTool {
5352
export function customTool(
5453
name: string,
5554
description: string,
56-
inputSchema: z.ZodType,
55+
inputSchema: SchemaInput,
5756
cacheControl?: CacheControl | null,
5857
): Tool {
5958
return {

packages/typescript/ai-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
"devDependencies": {
4949
"@vitest/coverage-v8": "4.0.14",
5050
"vite": "^7.2.7",
51-
"zod": "^4.1.13"
51+
"zod": "^4.2.0"
5252
}
5353
}

packages/typescript/ai-ollama/src/adapters/text.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,17 +294,19 @@ export class OllamaTextAdapter<TModel extends string> extends BaseTextAdapter<
294294
return undefined
295295
}
296296

297-
// Tool schemas are already converted to JSON Schema in the ai layer
297+
// Tool schemas are already converted to JSON Schema in the ai layer.
298+
// We use a type assertion because our JSONSchema type is more flexible
299+
// than ollama's expected schema type (e.g., type can be string | string[]).
298300
return tools.map((tool) => ({
299301
type: 'function',
300302
function: {
301303
name: tool.name,
302304
description: tool.description,
303-
parameters: tool.inputSchema ?? {
305+
parameters: (tool.inputSchema ?? {
304306
type: 'object',
305307
properties: {},
306308
required: [],
307-
},
309+
}) as OllamaTool['function']['parameters'],
308310
},
309311
}))
310312
}

packages/typescript/ai-react/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@
4949
"@types/react": "^19.2.7",
5050
"@vitest/coverage-v8": "4.0.14",
5151
"jsdom": "^27.2.0",
52-
"vite": "^7.2.7",
53-
"zod": "^4.1.13"
52+
"vite": "^7.2.7"
5453
},
5554
"peerDependencies": {
5655
"@tanstack/ai": "workspace:*",

packages/typescript/ai-solid/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@
4040
],
4141
"dependencies": {
4242
"@tanstack/ai": "workspace:*",
43-
"@tanstack/ai-client": "workspace:*",
44-
"zod": "^4.1.13"
43+
"@tanstack/ai-client": "workspace:*"
4544
},
4645
"devDependencies": {
4746
"@solidjs/testing-library": "^0.8.10",

0 commit comments

Comments
 (0)