ai 3.2.18 → 3.2.20

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.18",
3
+ "version": "3.2.20",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -57,13 +57,14 @@
57
57
  }
58
58
  },
59
59
  "dependencies": {
60
- "@ai-sdk/provider": "0.0.11",
61
- "@ai-sdk/provider-utils": "1.0.1",
62
- "@ai-sdk/react": "0.0.18",
63
- "@ai-sdk/solid": "0.0.12",
64
- "@ai-sdk/svelte": "0.0.13",
65
- "@ai-sdk/ui-utils": "0.0.10",
66
- "@ai-sdk/vue": "0.0.12",
60
+ "@ai-sdk/provider": "0.0.12",
61
+ "@ai-sdk/provider-utils": "1.0.2",
62
+ "@ai-sdk/react": "0.0.19",
63
+ "@ai-sdk/solid": "0.0.13",
64
+ "@ai-sdk/svelte": "0.0.14",
65
+ "@ai-sdk/ui-utils": "0.0.11",
66
+ "@ai-sdk/vue": "0.0.13",
67
+ "@opentelemetry/api": "1.9.0",
67
68
  "eventsource-parser": "1.1.2",
68
69
  "jsondiffpatch": "0.6.0",
69
70
  "json-schema": "0.4.0",
@@ -427,6 +427,24 @@ type Prompt = {
427
427
  messages?: Array<CoreMessage>;
428
428
  };
429
429
 
430
+ /**
431
+ Represents the number of tokens used in a prompt and completion.
432
+ */
433
+ type CompletionTokenUsage = {
434
+ /**
435
+ The number of tokens used in the prompt
436
+ */
437
+ promptTokens: number;
438
+ /**
439
+ The number of tokens used in the completion.
440
+ */
441
+ completionTokens: number;
442
+ /**
443
+ The total number of tokens used (promptTokens + completionTokens).
444
+ */
445
+ totalTokens: number;
446
+ };
447
+
430
448
  /**
431
449
  Reason why a language model finished generating a response.
432
450
 
@@ -457,24 +475,6 @@ type CoreToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | '
457
475
  toolName: keyof TOOLS;
458
476
  };
459
477
 
460
- /**
461
- Represents the number of tokens used in a prompt and completion.
462
- */
463
- type TokenUsage = {
464
- /**
465
- The number of tokens used in the prompt
466
- */
467
- promptTokens: number;
468
- /**
469
- The number of tokens used in the completion.
470
- */
471
- completionTokens: number;
472
- /**
473
- The total number of tokens used (promptTokens + completionTokens).
474
- */
475
- totalTokens: number;
476
- };
477
-
478
478
  type Streamable = ReactNode | Promise<ReactNode>;
479
479
  type Renderer<T extends Array<any>> = (...args: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
480
480
  type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
@@ -541,7 +541,7 @@ declare function streamUI<TOOLS extends {
541
541
  /**
542
542
  * The token usage of the generated response.
543
543
  */
544
- usage: TokenUsage;
544
+ usage: CompletionTokenUsage;
545
545
  /**
546
546
  * The final ui node that was generated.
547
547
  */
@@ -425,6 +425,24 @@ type Prompt = {
425
425
  messages?: Array<CoreMessage>;
426
426
  };
427
427
 
428
+ /**
429
+ Represents the number of tokens used in a prompt and completion.
430
+ */
431
+ type CompletionTokenUsage = {
432
+ /**
433
+ The number of tokens used in the prompt
434
+ */
435
+ promptTokens: number;
436
+ /**
437
+ The number of tokens used in the completion.
438
+ */
439
+ completionTokens: number;
440
+ /**
441
+ The total number of tokens used (promptTokens + completionTokens).
442
+ */
443
+ totalTokens: number;
444
+ };
445
+
428
446
  /**
429
447
  Reason why a language model finished generating a response.
430
448
 
@@ -455,24 +473,6 @@ type CoreToolChoice<TOOLS extends Record<string, unknown>> = 'auto' | 'none' | '
455
473
  toolName: keyof TOOLS;
456
474
  };
457
475
 
458
- /**
459
- Represents the number of tokens used in a prompt and completion.
460
- */
461
- type TokenUsage = {
462
- /**
463
- The number of tokens used in the prompt
464
- */
465
- promptTokens: number;
466
- /**
467
- The number of tokens used in the completion.
468
- */
469
- completionTokens: number;
470
- /**
471
- The total number of tokens used (promptTokens + completionTokens).
472
- */
473
- totalTokens: number;
474
- };
475
-
476
476
  type Streamable = ReactNode | Promise<ReactNode>;
477
477
  type Renderer<T extends Array<any>> = (...args: T) => Streamable | Generator<Streamable, Streamable, void> | AsyncGenerator<Streamable, Streamable, void>;
478
478
  type RenderTool<PARAMETERS extends z.ZodTypeAny = any> = {
@@ -539,7 +539,7 @@ declare function streamUI<TOOLS extends {
539
539
  /**
540
540
  * The token usage of the generated response.
541
541
  */
542
- usage: TokenUsage;
542
+ usage: CompletionTokenUsage;
543
543
  /**
544
544
  * The final ui node that was generated.
545
545
  */
@@ -239,15 +239,6 @@ async function _retryWithExponentialBackoff(f, {
239
239
  }
240
240
  }
241
241
 
242
- // core/generate-text/token-usage.ts
243
- function calculateTokenUsage(usage) {
244
- return {
245
- promptTokens: usage.promptTokens,
246
- completionTokens: usage.completionTokens,
247
- totalTokens: usage.promptTokens + usage.completionTokens
248
- };
249
- }
250
-
251
242
  // core/util/detect-image-mimetype.ts
252
243
  var mimeTypeSignatures = [
253
244
  { mimeType: "image/gif", bytes: [71, 73, 70] },
@@ -589,6 +580,15 @@ function prepareCallSettings({
589
580
  };
590
581
  }
591
582
 
583
+ // core/types/token-usage.ts
584
+ function calculateCompletionTokenUsage(usage) {
585
+ return {
586
+ promptTokens: usage.promptTokens,
587
+ completionTokens: usage.completionTokens,
588
+ totalTokens: usage.promptTokens + usage.completionTokens
589
+ };
590
+ }
591
+
592
592
  // core/util/convert-zod-to-json-schema.ts
593
593
  import zodToJsonSchema from "zod-to-json-schema";
594
594
  function convertZodToJSONSchema(zodSchema) {
@@ -1642,7 +1642,7 @@ async function streamUI({
1642
1642
  case "finish": {
1643
1643
  onFinish == null ? void 0 : onFinish({
1644
1644
  finishReason: value.finishReason,
1645
- usage: calculateTokenUsage(value.usage),
1645
+ usage: calculateCompletionTokenUsage(value.usage),
1646
1646
  value: ui.value,
1647
1647
  warnings: result.warnings,
1648
1648
  rawResponse: result.rawResponse