ai 3.2.34 → 3.2.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "3.2.34",
3
+ "version": "3.2.35",
4
4
  "description": "Vercel AI SDK - The AI Toolkit for TypeScript and JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -59,19 +59,18 @@
59
59
  },
60
60
  "dependencies": {
61
61
  "@ai-sdk/provider": "0.0.13",
62
- "@ai-sdk/provider-utils": "1.0.3",
63
- "@ai-sdk/react": "0.0.27",
64
- "@ai-sdk/solid": "0.0.20",
65
- "@ai-sdk/svelte": "0.0.21",
66
- "@ai-sdk/ui-utils": "0.0.18",
67
- "@ai-sdk/vue": "0.0.22",
62
+ "@ai-sdk/provider-utils": "1.0.4",
63
+ "@ai-sdk/react": "0.0.28",
64
+ "@ai-sdk/solid": "0.0.21",
65
+ "@ai-sdk/svelte": "0.0.22",
66
+ "@ai-sdk/ui-utils": "0.0.19",
67
+ "@ai-sdk/vue": "0.0.23",
68
68
  "@opentelemetry/api": "1.9.0",
69
69
  "eventsource-parser": "1.1.2",
70
70
  "jsondiffpatch": "0.6.0",
71
71
  "json-schema": "0.4.0",
72
72
  "nanoid": "3.3.6",
73
73
  "secure-json-parse": "2.7.0",
74
- "sswr": "2.1.0",
75
74
  "zod-to-json-schema": "3.22.5"
76
75
  },
77
76
  "devDependencies": {
@@ -97,6 +96,7 @@
97
96
  "openai": "4.52.6",
98
97
  "react-dom": "^18",
99
98
  "react-server-dom-webpack": "18.3.0-canary-eb33bd747-20240312",
99
+ "sswr": "2.1.0",
100
100
  "tsup": "^7.2.0",
101
101
  "typescript": "5.1.3",
102
102
  "zod": "3.23.8",
@@ -107,6 +107,7 @@
107
107
  "openai": "^4.42.0",
108
108
  "react": "^18 || ^19",
109
109
  "zod": "^3.0.0",
110
+ "sswr": "^2.1.0",
110
111
  "svelte": "^3.0.0 || ^4.0.0"
111
112
  },
112
113
  "peerDependenciesMeta": {
@@ -119,6 +120,9 @@
119
120
  "openai": {
120
121
  "optional": true
121
122
  },
123
+ "sswr": {
124
+ "optional": true
125
+ },
122
126
  "svelte": {
123
127
  "optional": true
124
128
  }
@@ -591,10 +591,39 @@ function calculateCompletionTokenUsage(usage) {
591
591
  };
592
592
  }
593
593
 
594
- // core/util/convert-zod-to-json-schema.ts
594
+ // core/util/schema.ts
595
+ import { validatorSymbol } from "@ai-sdk/provider-utils";
595
596
  import zodToJsonSchema from "zod-to-json-schema";
596
- function convertZodToJSONSchema(zodSchema) {
597
- return zodToJsonSchema(zodSchema);
597
+ var schemaSymbol = Symbol("vercel.ai.schema");
598
+ function jsonSchema(jsonSchema2, {
599
+ validate
600
+ } = {}) {
601
+ return {
602
+ [schemaSymbol]: true,
603
+ _type: void 0,
604
+ // should never be used directly
605
+ [validatorSymbol]: true,
606
+ jsonSchema: jsonSchema2,
607
+ validate
608
+ };
609
+ }
610
+ function isSchema(value) {
611
+ return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
612
+ }
613
+ function asSchema(schema) {
614
+ return isSchema(schema) ? schema : zodSchema(schema);
615
+ }
616
+ function zodSchema(zodSchema2) {
617
+ return jsonSchema(
618
+ // we assume that zodToJsonSchema will return a valid JSONSchema7:
619
+ zodToJsonSchema(zodSchema2),
620
+ {
621
+ validate: (value) => {
622
+ const result = zodSchema2.safeParse(value);
623
+ return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
624
+ }
625
+ }
626
+ );
598
627
  }
599
628
 
600
629
  // core/util/is-non-empty-object.ts
@@ -618,7 +647,7 @@ function prepareToolsAndToolChoice({
618
647
  type: "function",
619
648
  name,
620
649
  description: tool.description,
621
- parameters: convertZodToJSONSchema(tool.parameters)
650
+ parameters: asSchema(tool.parameters).jsonSchema
622
651
  })),
623
652
  toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
624
653
  };