ai 3.2.45 → 3.3.0

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/dist/index.mjs CHANGED
@@ -13,9 +13,18 @@ import {
13
13
  } from "@ai-sdk/ui-utils";
14
14
  import { generateId as generateIdImpl } from "@ai-sdk/provider-utils";
15
15
 
16
+ // core/telemetry/assemble-operation-name.ts
17
+ function assembleOperationName({
18
+ operationName,
19
+ telemetry
20
+ }) {
21
+ return {
22
+ "operation.name": `${operationName}${(telemetry == null ? void 0 : telemetry.functionId) != null ? ` ${telemetry.functionId}` : ""}`
23
+ };
24
+ }
25
+
16
26
  // core/telemetry/get-base-telemetry-attributes.ts
17
27
  function getBaseTelemetryAttributes({
18
- operationName,
19
28
  model,
20
29
  settings,
21
30
  telemetry,
@@ -31,7 +40,6 @@ function getBaseTelemetryAttributes({
31
40
  return attributes;
32
41
  }, {}),
33
42
  // special telemetry information
34
- "operation.name": operationName,
35
43
  "resource.name": telemetry == null ? void 0 : telemetry.functionId,
36
44
  "ai.telemetry.functionId": telemetry == null ? void 0 : telemetry.functionId,
37
45
  // add metadata as attributes:
@@ -264,7 +272,6 @@ async function embed({
264
272
  }) {
265
273
  var _a;
266
274
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
267
- operationName: "ai.embed",
268
275
  model,
269
276
  telemetry,
270
277
  headers,
@@ -276,6 +283,7 @@ async function embed({
276
283
  attributes: selectTelemetryAttributes({
277
284
  telemetry,
278
285
  attributes: {
286
+ ...assembleOperationName({ operationName: "ai.embed", telemetry }),
279
287
  ...baseTelemetryAttributes,
280
288
  "ai.value": { input: () => JSON.stringify(value) }
281
289
  }
@@ -291,6 +299,10 @@ async function embed({
291
299
  attributes: selectTelemetryAttributes({
292
300
  telemetry,
293
301
  attributes: {
302
+ ...assembleOperationName({
303
+ operationName: "ai.embed.doEmbed",
304
+ telemetry
305
+ }),
294
306
  ...baseTelemetryAttributes,
295
307
  // specific settings that only make sense on the outer level:
296
308
  "ai.values": { input: () => [JSON.stringify(value)] }
@@ -373,7 +385,6 @@ async function embedMany({
373
385
  }) {
374
386
  var _a;
375
387
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
376
- operationName: "ai.embedMany",
377
388
  model,
378
389
  telemetry,
379
390
  headers,
@@ -385,6 +396,7 @@ async function embedMany({
385
396
  attributes: selectTelemetryAttributes({
386
397
  telemetry,
387
398
  attributes: {
399
+ ...assembleOperationName({ operationName: "ai.embedMany", telemetry }),
388
400
  ...baseTelemetryAttributes,
389
401
  // specific settings that only make sense on the outer level:
390
402
  "ai.values": {
@@ -403,6 +415,10 @@ async function embedMany({
403
415
  attributes: selectTelemetryAttributes({
404
416
  telemetry,
405
417
  attributes: {
418
+ ...assembleOperationName({
419
+ operationName: "ai.embedMany.doEmbed",
420
+ telemetry
421
+ }),
406
422
  ...baseTelemetryAttributes,
407
423
  // specific settings that only make sense on the outer level:
408
424
  "ai.values": {
@@ -458,6 +474,10 @@ async function embedMany({
458
474
  attributes: selectTelemetryAttributes({
459
475
  telemetry,
460
476
  attributes: {
477
+ ...assembleOperationName({
478
+ operationName: "ai.embedMany.doEmbed",
479
+ telemetry
480
+ }),
461
481
  ...baseTelemetryAttributes,
462
482
  // specific settings that only make sense on the outer level:
463
483
  "ai.values": {
@@ -1053,7 +1073,6 @@ async function generateObject({
1053
1073
  }) {
1054
1074
  var _a;
1055
1075
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
1056
- operationName: "ai.generateObject",
1057
1076
  model,
1058
1077
  telemetry,
1059
1078
  headers,
@@ -1066,6 +1085,10 @@ async function generateObject({
1066
1085
  attributes: selectTelemetryAttributes({
1067
1086
  telemetry,
1068
1087
  attributes: {
1088
+ ...assembleOperationName({
1089
+ operationName: "ai.generateObject",
1090
+ telemetry
1091
+ }),
1069
1092
  ...baseTelemetryAttributes,
1070
1093
  // specific settings that only make sense on the outer level:
1071
1094
  "ai.prompt": {
@@ -1110,6 +1133,10 @@ async function generateObject({
1110
1133
  attributes: selectTelemetryAttributes({
1111
1134
  telemetry,
1112
1135
  attributes: {
1136
+ ...assembleOperationName({
1137
+ operationName: "ai.generateObject.doGenerate",
1138
+ telemetry
1139
+ }),
1113
1140
  ...baseTelemetryAttributes,
1114
1141
  "ai.prompt.format": {
1115
1142
  input: () => inputFormat
@@ -1183,6 +1210,10 @@ async function generateObject({
1183
1210
  attributes: selectTelemetryAttributes({
1184
1211
  telemetry,
1185
1212
  attributes: {
1213
+ ...assembleOperationName({
1214
+ operationName: "ai.generateObject.doGenerate",
1215
+ telemetry
1216
+ }),
1186
1217
  ...baseTelemetryAttributes,
1187
1218
  "ai.prompt.format": {
1188
1219
  input: () => inputFormat
@@ -1387,7 +1418,6 @@ async function streamObject({
1387
1418
  }) {
1388
1419
  var _a;
1389
1420
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
1390
- operationName: "ai.streamObject",
1391
1421
  model,
1392
1422
  telemetry,
1393
1423
  headers,
@@ -1401,6 +1431,10 @@ async function streamObject({
1401
1431
  attributes: selectTelemetryAttributes({
1402
1432
  telemetry,
1403
1433
  attributes: {
1434
+ ...assembleOperationName({
1435
+ operationName: "ai.streamObject",
1436
+ telemetry
1437
+ }),
1404
1438
  ...baseTelemetryAttributes,
1405
1439
  // specific settings that only make sense on the outer level:
1406
1440
  "ai.prompt": {
@@ -1513,6 +1547,10 @@ async function streamObject({
1513
1547
  attributes: selectTelemetryAttributes({
1514
1548
  telemetry,
1515
1549
  attributes: {
1550
+ ...assembleOperationName({
1551
+ operationName: "ai.streamObject.doStream",
1552
+ telemetry
1553
+ }),
1516
1554
  ...baseTelemetryAttributes,
1517
1555
  "ai.prompt.format": {
1518
1556
  input: () => callOptions.inputFormat
@@ -1861,7 +1899,6 @@ async function generateText({
1861
1899
  }) {
1862
1900
  var _a;
1863
1901
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
1864
- operationName: "ai.generateText",
1865
1902
  model,
1866
1903
  telemetry,
1867
1904
  headers,
@@ -1873,6 +1910,10 @@ async function generateText({
1873
1910
  attributes: selectTelemetryAttributes({
1874
1911
  telemetry,
1875
1912
  attributes: {
1913
+ ...assembleOperationName({
1914
+ operationName: "ai.generateText",
1915
+ telemetry
1916
+ }),
1876
1917
  ...baseTelemetryAttributes,
1877
1918
  // specific settings that only make sense on the outer level:
1878
1919
  "ai.prompt": {
@@ -1918,6 +1959,10 @@ async function generateText({
1918
1959
  attributes: selectTelemetryAttributes({
1919
1960
  telemetry,
1920
1961
  attributes: {
1962
+ ...assembleOperationName({
1963
+ operationName: "ai.generateText.doGenerate",
1964
+ telemetry
1965
+ }),
1921
1966
  ...baseTelemetryAttributes,
1922
1967
  "ai.prompt.format": { input: () => currentInputFormat },
1923
1968
  "ai.prompt.messages": {
@@ -2057,6 +2102,10 @@ async function executeTools({
2057
2102
  attributes: selectTelemetryAttributes({
2058
2103
  telemetry,
2059
2104
  attributes: {
2105
+ ...assembleOperationName({
2106
+ operationName: "ai.toolCall",
2107
+ telemetry
2108
+ }),
2060
2109
  "ai.toolCall.name": toolCall.toolName,
2061
2110
  "ai.toolCall.id": toolCall.toolCallId,
2062
2111
  "ai.toolCall.args": {
@@ -2303,6 +2352,10 @@ function runToolsTransformation({
2303
2352
  attributes: selectTelemetryAttributes({
2304
2353
  telemetry,
2305
2354
  attributes: {
2355
+ ...assembleOperationName({
2356
+ operationName: "ai.toolCall",
2357
+ telemetry
2358
+ }),
2306
2359
  "ai.toolCall.name": toolCall.toolName,
2307
2360
  "ai.toolCall.id": toolCall.toolCallId,
2308
2361
  "ai.toolCall.args": {
@@ -2424,7 +2477,6 @@ async function streamText({
2424
2477
  }) {
2425
2478
  var _a;
2426
2479
  const baseTelemetryAttributes = getBaseTelemetryAttributes({
2427
- operationName: "ai.streamText",
2428
2480
  model,
2429
2481
  telemetry,
2430
2482
  headers,
@@ -2436,6 +2488,7 @@ async function streamText({
2436
2488
  attributes: selectTelemetryAttributes({
2437
2489
  telemetry,
2438
2490
  attributes: {
2491
+ ...assembleOperationName({ operationName: "ai.streamText", telemetry }),
2439
2492
  ...baseTelemetryAttributes,
2440
2493
  // specific settings that only make sense on the outer level:
2441
2494
  "ai.prompt": {
@@ -2461,6 +2514,10 @@ async function streamText({
2461
2514
  attributes: selectTelemetryAttributes({
2462
2515
  telemetry,
2463
2516
  attributes: {
2517
+ ...assembleOperationName({
2518
+ operationName: "ai.streamText.doStream",
2519
+ telemetry
2520
+ }),
2464
2521
  ...baseTelemetryAttributes,
2465
2522
  "ai.prompt.format": {
2466
2523
  input: () => validatedPrompt.type