ai 4.3.14 → 4.3.16

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/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # ai
2
2
 
3
+ ## 4.3.16
4
+
5
+ ### Patch Changes
6
+
7
+ - ed0ebeb: Avoid JSON.strinfigy on UInt8Arrays for telemetry
8
+
9
+ ## 4.3.15
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [d87b9d1]
14
+ - @ai-sdk/provider-utils@2.2.8
15
+ - @ai-sdk/react@1.2.12
16
+ - @ai-sdk/ui-utils@1.2.11
17
+
3
18
  ## 4.3.14
4
19
 
5
20
  ### Patch Changes
package/dist/index.js CHANGED
@@ -2691,6 +2691,26 @@ function validateObjectGenerationInput({
2691
2691
  }
2692
2692
  }
2693
2693
 
2694
+ // core/prompt/stringify-for-telemetry.ts
2695
+ function stringifyForTelemetry(prompt) {
2696
+ const processedPrompt = prompt.map((message) => {
2697
+ return {
2698
+ ...message,
2699
+ content: typeof message.content === "string" ? message.content : message.content.map(processPart)
2700
+ };
2701
+ });
2702
+ return JSON.stringify(processedPrompt);
2703
+ }
2704
+ function processPart(part) {
2705
+ if (part.type === "image") {
2706
+ return {
2707
+ ...part,
2708
+ image: part.image instanceof Uint8Array ? convertDataContentToBase64String(part.image) : part.image
2709
+ };
2710
+ }
2711
+ return part;
2712
+ }
2713
+
2694
2714
  // core/generate-object/generate-object.ts
2695
2715
  var originalGenerateId = (0, import_provider_utils7.createIdGenerator)({ prefix: "aiobj", size: 24 });
2696
2716
  async function generateObject({
@@ -2918,7 +2938,7 @@ async function generateObject({
2918
2938
  input: () => inputFormat
2919
2939
  },
2920
2940
  "ai.prompt.messages": {
2921
- input: () => JSON.stringify(promptMessages)
2941
+ input: () => stringifyForTelemetry(promptMessages)
2922
2942
  },
2923
2943
  "ai.settings.mode": mode,
2924
2944
  // standardized gen-ai llm span attributes:
@@ -3517,7 +3537,7 @@ var DefaultStreamObjectResult = class {
3517
3537
  input: () => callOptions.inputFormat
3518
3538
  },
3519
3539
  "ai.prompt.messages": {
3520
- input: () => JSON.stringify(callOptions.prompt)
3540
+ input: () => stringifyForTelemetry(callOptions.prompt)
3521
3541
  },
3522
3542
  "ai.settings.mode": mode,
3523
3543
  // standardized gen-ai llm span attributes:
@@ -4308,7 +4328,7 @@ async function generateText({
4308
4328
  // prompt:
4309
4329
  "ai.prompt.format": { input: () => promptFormat },
4310
4330
  "ai.prompt.messages": {
4311
- input: () => JSON.stringify(promptMessages)
4331
+ input: () => stringifyForTelemetry(promptMessages)
4312
4332
  },
4313
4333
  "ai.prompt.tools": {
4314
4334
  // convert the language model level tools:
@@ -5654,7 +5674,7 @@ var DefaultStreamTextResult = class {
5654
5674
  input: () => promptFormat
5655
5675
  },
5656
5676
  "ai.prompt.messages": {
5657
- input: () => JSON.stringify(promptMessages)
5677
+ input: () => stringifyForTelemetry(promptMessages)
5658
5678
  },
5659
5679
  "ai.prompt.tools": {
5660
5680
  // convert the language model level tools: