ai 3.2.33 → 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,7 +1,7 @@
1
1
  {
2
2
  "name": "ai",
3
- "version": "3.2.33",
4
- "description": "The AI Toolkit for TypeScript",
3
+ "version": "3.2.35",
4
+ "description": "Vercel AI SDK - The AI Toolkit for TypeScript and JavaScript",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
7
7
  "main": "./dist/index.js",
@@ -58,20 +58,19 @@
58
58
  }
59
59
  },
60
60
  "dependencies": {
61
- "@ai-sdk/provider": "0.0.12",
62
- "@ai-sdk/provider-utils": "1.0.2",
63
- "@ai-sdk/react": "0.0.26",
64
- "@ai-sdk/solid": "0.0.19",
65
- "@ai-sdk/svelte": "0.0.20",
66
- "@ai-sdk/ui-utils": "0.0.17",
67
- "@ai-sdk/vue": "0.0.21",
61
+ "@ai-sdk/provider": "0.0.13",
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
  }
@@ -245,6 +245,13 @@ type CallSettings = {
245
245
  */
246
246
  topP?: number;
247
247
  /**
248
+ Only sample from the top K options for each subsequent token.
249
+
250
+ Used to remove "long tail" low probability responses.
251
+ Recommended for advanced use cases only. You usually only need to use temperature.
252
+ */
253
+ topK?: number;
254
+ /**
248
255
  Presence penalty setting. It affects the likelihood of the model to
249
256
  repeat information that is already in the prompt.
250
257
 
@@ -265,6 +272,12 @@ type CallSettings = {
265
272
  */
266
273
  frequencyPenalty?: number;
267
274
  /**
275
+ Stop sequences.
276
+ If set, the model will stop generating text when one of the stop sequences is generated.
277
+ Providers may have limits on the number of stop sequences.
278
+ */
279
+ stopSequences?: string[];
280
+ /**
268
281
  The seed (integer) to use for random sampling. If set and supported
269
282
  by the model, calls will generate deterministic results.
270
283
  */
@@ -243,6 +243,13 @@ type CallSettings = {
243
243
  */
244
244
  topP?: number;
245
245
  /**
246
+ Only sample from the top K options for each subsequent token.
247
+
248
+ Used to remove "long tail" low probability responses.
249
+ Recommended for advanced use cases only. You usually only need to use temperature.
250
+ */
251
+ topK?: number;
252
+ /**
246
253
  Presence penalty setting. It affects the likelihood of the model to
247
254
  repeat information that is already in the prompt.
248
255
 
@@ -263,6 +270,12 @@ type CallSettings = {
263
270
  */
264
271
  frequencyPenalty?: number;
265
272
  /**
273
+ Stop sequences.
274
+ If set, the model will stop generating text when one of the stop sequences is generated.
275
+ Providers may have limits on the number of stop sequences.
276
+ */
277
+ stopSequences?: string[];
278
+ /**
266
279
  The seed (integer) to use for random sampling. If set and supported
267
280
  by the model, calls will generate deterministic results.
268
281
  */
@@ -489,6 +489,7 @@ function prepareCallSettings({
489
489
  topP,
490
490
  presencePenalty,
491
491
  frequencyPenalty,
492
+ stopSequences,
492
493
  seed,
493
494
  maxRetries
494
495
  }) {
@@ -575,6 +576,7 @@ function prepareCallSettings({
575
576
  topP,
576
577
  presencePenalty,
577
578
  frequencyPenalty,
579
+ stopSequences: stopSequences != null && stopSequences.length > 0 ? stopSequences : void 0,
578
580
  seed,
579
581
  maxRetries: maxRetries != null ? maxRetries : 2
580
582
  };
@@ -589,10 +591,39 @@ function calculateCompletionTokenUsage(usage) {
589
591
  };
590
592
  }
591
593
 
592
- // core/util/convert-zod-to-json-schema.ts
594
+ // core/util/schema.ts
595
+ import { validatorSymbol } from "@ai-sdk/provider-utils";
593
596
  import zodToJsonSchema from "zod-to-json-schema";
594
- function convertZodToJSONSchema(zodSchema) {
595
- 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
+ );
596
627
  }
597
628
 
598
629
  // core/util/is-non-empty-object.ts
@@ -616,7 +647,7 @@ function prepareToolsAndToolChoice({
616
647
  type: "function",
617
648
  name,
618
649
  description: tool.description,
619
- parameters: convertZodToJSONSchema(tool.parameters)
650
+ parameters: asSchema(tool.parameters).jsonSchema
620
651
  })),
621
652
  toolChoice: toolChoice == null ? { type: "auto" } : typeof toolChoice === "string" ? { type: toolChoice } : { type: "tool", toolName: toolChoice.toolName }
622
653
  };