ai 3.2.44 → 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.js +65 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
@@ -107,9 +107,18 @@ module.exports = __toCommonJS(streams_exports);
|
|
107
107
|
var import_ui_utils6 = require("@ai-sdk/ui-utils");
|
108
108
|
var import_provider_utils8 = require("@ai-sdk/provider-utils");
|
109
109
|
|
110
|
+
// core/telemetry/assemble-operation-name.ts
|
111
|
+
function assembleOperationName({
|
112
|
+
operationName,
|
113
|
+
telemetry
|
114
|
+
}) {
|
115
|
+
return {
|
116
|
+
"operation.name": `${operationName}${(telemetry == null ? void 0 : telemetry.functionId) != null ? ` ${telemetry.functionId}` : ""}`
|
117
|
+
};
|
118
|
+
}
|
119
|
+
|
110
120
|
// core/telemetry/get-base-telemetry-attributes.ts
|
111
121
|
function getBaseTelemetryAttributes({
|
112
|
-
operationName,
|
113
122
|
model,
|
114
123
|
settings,
|
115
124
|
telemetry,
|
@@ -125,7 +134,6 @@ function getBaseTelemetryAttributes({
|
|
125
134
|
return attributes;
|
126
135
|
}, {}),
|
127
136
|
// special telemetry information
|
128
|
-
"operation.name": operationName,
|
129
137
|
"resource.name": telemetry == null ? void 0 : telemetry.functionId,
|
130
138
|
"ai.telemetry.functionId": telemetry == null ? void 0 : telemetry.functionId,
|
131
139
|
// add metadata as attributes:
|
@@ -358,7 +366,6 @@ async function embed({
|
|
358
366
|
}) {
|
359
367
|
var _a;
|
360
368
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
361
|
-
operationName: "ai.embed",
|
362
369
|
model,
|
363
370
|
telemetry,
|
364
371
|
headers,
|
@@ -370,6 +377,7 @@ async function embed({
|
|
370
377
|
attributes: selectTelemetryAttributes({
|
371
378
|
telemetry,
|
372
379
|
attributes: {
|
380
|
+
...assembleOperationName({ operationName: "ai.embed", telemetry }),
|
373
381
|
...baseTelemetryAttributes,
|
374
382
|
"ai.value": { input: () => JSON.stringify(value) }
|
375
383
|
}
|
@@ -385,6 +393,10 @@ async function embed({
|
|
385
393
|
attributes: selectTelemetryAttributes({
|
386
394
|
telemetry,
|
387
395
|
attributes: {
|
396
|
+
...assembleOperationName({
|
397
|
+
operationName: "ai.embed.doEmbed",
|
398
|
+
telemetry
|
399
|
+
}),
|
388
400
|
...baseTelemetryAttributes,
|
389
401
|
// specific settings that only make sense on the outer level:
|
390
402
|
"ai.values": { input: () => [JSON.stringify(value)] }
|
@@ -467,7 +479,6 @@ async function embedMany({
|
|
467
479
|
}) {
|
468
480
|
var _a;
|
469
481
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
470
|
-
operationName: "ai.embedMany",
|
471
482
|
model,
|
472
483
|
telemetry,
|
473
484
|
headers,
|
@@ -479,6 +490,7 @@ async function embedMany({
|
|
479
490
|
attributes: selectTelemetryAttributes({
|
480
491
|
telemetry,
|
481
492
|
attributes: {
|
493
|
+
...assembleOperationName({ operationName: "ai.embedMany", telemetry }),
|
482
494
|
...baseTelemetryAttributes,
|
483
495
|
// specific settings that only make sense on the outer level:
|
484
496
|
"ai.values": {
|
@@ -497,6 +509,10 @@ async function embedMany({
|
|
497
509
|
attributes: selectTelemetryAttributes({
|
498
510
|
telemetry,
|
499
511
|
attributes: {
|
512
|
+
...assembleOperationName({
|
513
|
+
operationName: "ai.embedMany.doEmbed",
|
514
|
+
telemetry
|
515
|
+
}),
|
500
516
|
...baseTelemetryAttributes,
|
501
517
|
// specific settings that only make sense on the outer level:
|
502
518
|
"ai.values": {
|
@@ -552,6 +568,10 @@ async function embedMany({
|
|
552
568
|
attributes: selectTelemetryAttributes({
|
553
569
|
telemetry,
|
554
570
|
attributes: {
|
571
|
+
...assembleOperationName({
|
572
|
+
operationName: "ai.embedMany.doEmbed",
|
573
|
+
telemetry
|
574
|
+
}),
|
555
575
|
...baseTelemetryAttributes,
|
556
576
|
// specific settings that only make sense on the outer level:
|
557
577
|
"ai.values": {
|
@@ -1144,7 +1164,6 @@ async function generateObject({
|
|
1144
1164
|
}) {
|
1145
1165
|
var _a;
|
1146
1166
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
1147
|
-
operationName: "ai.generateObject",
|
1148
1167
|
model,
|
1149
1168
|
telemetry,
|
1150
1169
|
headers,
|
@@ -1157,6 +1176,10 @@ async function generateObject({
|
|
1157
1176
|
attributes: selectTelemetryAttributes({
|
1158
1177
|
telemetry,
|
1159
1178
|
attributes: {
|
1179
|
+
...assembleOperationName({
|
1180
|
+
operationName: "ai.generateObject",
|
1181
|
+
telemetry
|
1182
|
+
}),
|
1160
1183
|
...baseTelemetryAttributes,
|
1161
1184
|
// specific settings that only make sense on the outer level:
|
1162
1185
|
"ai.prompt": {
|
@@ -1201,6 +1224,10 @@ async function generateObject({
|
|
1201
1224
|
attributes: selectTelemetryAttributes({
|
1202
1225
|
telemetry,
|
1203
1226
|
attributes: {
|
1227
|
+
...assembleOperationName({
|
1228
|
+
operationName: "ai.generateObject.doGenerate",
|
1229
|
+
telemetry
|
1230
|
+
}),
|
1204
1231
|
...baseTelemetryAttributes,
|
1205
1232
|
"ai.prompt.format": {
|
1206
1233
|
input: () => inputFormat
|
@@ -1274,6 +1301,10 @@ async function generateObject({
|
|
1274
1301
|
attributes: selectTelemetryAttributes({
|
1275
1302
|
telemetry,
|
1276
1303
|
attributes: {
|
1304
|
+
...assembleOperationName({
|
1305
|
+
operationName: "ai.generateObject.doGenerate",
|
1306
|
+
telemetry
|
1307
|
+
}),
|
1277
1308
|
...baseTelemetryAttributes,
|
1278
1309
|
"ai.prompt.format": {
|
1279
1310
|
input: () => inputFormat
|
@@ -1475,7 +1506,6 @@ async function streamObject({
|
|
1475
1506
|
}) {
|
1476
1507
|
var _a;
|
1477
1508
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
1478
|
-
operationName: "ai.streamObject",
|
1479
1509
|
model,
|
1480
1510
|
telemetry,
|
1481
1511
|
headers,
|
@@ -1489,6 +1519,10 @@ async function streamObject({
|
|
1489
1519
|
attributes: selectTelemetryAttributes({
|
1490
1520
|
telemetry,
|
1491
1521
|
attributes: {
|
1522
|
+
...assembleOperationName({
|
1523
|
+
operationName: "ai.streamObject",
|
1524
|
+
telemetry
|
1525
|
+
}),
|
1492
1526
|
...baseTelemetryAttributes,
|
1493
1527
|
// specific settings that only make sense on the outer level:
|
1494
1528
|
"ai.prompt": {
|
@@ -1601,6 +1635,10 @@ async function streamObject({
|
|
1601
1635
|
attributes: selectTelemetryAttributes({
|
1602
1636
|
telemetry,
|
1603
1637
|
attributes: {
|
1638
|
+
...assembleOperationName({
|
1639
|
+
operationName: "ai.streamObject.doStream",
|
1640
|
+
telemetry
|
1641
|
+
}),
|
1604
1642
|
...baseTelemetryAttributes,
|
1605
1643
|
"ai.prompt.format": {
|
1606
1644
|
input: () => callOptions.inputFormat
|
@@ -1946,7 +1984,6 @@ async function generateText({
|
|
1946
1984
|
}) {
|
1947
1985
|
var _a;
|
1948
1986
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
1949
|
-
operationName: "ai.generateText",
|
1950
1987
|
model,
|
1951
1988
|
telemetry,
|
1952
1989
|
headers,
|
@@ -1958,6 +1995,10 @@ async function generateText({
|
|
1958
1995
|
attributes: selectTelemetryAttributes({
|
1959
1996
|
telemetry,
|
1960
1997
|
attributes: {
|
1998
|
+
...assembleOperationName({
|
1999
|
+
operationName: "ai.generateText",
|
2000
|
+
telemetry
|
2001
|
+
}),
|
1961
2002
|
...baseTelemetryAttributes,
|
1962
2003
|
// specific settings that only make sense on the outer level:
|
1963
2004
|
"ai.prompt": {
|
@@ -2003,6 +2044,10 @@ async function generateText({
|
|
2003
2044
|
attributes: selectTelemetryAttributes({
|
2004
2045
|
telemetry,
|
2005
2046
|
attributes: {
|
2047
|
+
...assembleOperationName({
|
2048
|
+
operationName: "ai.generateText.doGenerate",
|
2049
|
+
telemetry
|
2050
|
+
}),
|
2006
2051
|
...baseTelemetryAttributes,
|
2007
2052
|
"ai.prompt.format": { input: () => currentInputFormat },
|
2008
2053
|
"ai.prompt.messages": {
|
@@ -2142,6 +2187,10 @@ async function executeTools({
|
|
2142
2187
|
attributes: selectTelemetryAttributes({
|
2143
2188
|
telemetry,
|
2144
2189
|
attributes: {
|
2190
|
+
...assembleOperationName({
|
2191
|
+
operationName: "ai.toolCall",
|
2192
|
+
telemetry
|
2193
|
+
}),
|
2145
2194
|
"ai.toolCall.name": toolCall.toolName,
|
2146
2195
|
"ai.toolCall.id": toolCall.toolCallId,
|
2147
2196
|
"ai.toolCall.args": {
|
@@ -2388,6 +2437,10 @@ function runToolsTransformation({
|
|
2388
2437
|
attributes: selectTelemetryAttributes({
|
2389
2438
|
telemetry,
|
2390
2439
|
attributes: {
|
2440
|
+
...assembleOperationName({
|
2441
|
+
operationName: "ai.toolCall",
|
2442
|
+
telemetry
|
2443
|
+
}),
|
2391
2444
|
"ai.toolCall.name": toolCall.toolName,
|
2392
2445
|
"ai.toolCall.id": toolCall.toolCallId,
|
2393
2446
|
"ai.toolCall.args": {
|
@@ -2509,7 +2562,6 @@ async function streamText({
|
|
2509
2562
|
}) {
|
2510
2563
|
var _a;
|
2511
2564
|
const baseTelemetryAttributes = getBaseTelemetryAttributes({
|
2512
|
-
operationName: "ai.streamText",
|
2513
2565
|
model,
|
2514
2566
|
telemetry,
|
2515
2567
|
headers,
|
@@ -2521,6 +2573,7 @@ async function streamText({
|
|
2521
2573
|
attributes: selectTelemetryAttributes({
|
2522
2574
|
telemetry,
|
2523
2575
|
attributes: {
|
2576
|
+
...assembleOperationName({ operationName: "ai.streamText", telemetry }),
|
2524
2577
|
...baseTelemetryAttributes,
|
2525
2578
|
// specific settings that only make sense on the outer level:
|
2526
2579
|
"ai.prompt": {
|
@@ -2546,6 +2599,10 @@ async function streamText({
|
|
2546
2599
|
attributes: selectTelemetryAttributes({
|
2547
2600
|
telemetry,
|
2548
2601
|
attributes: {
|
2602
|
+
...assembleOperationName({
|
2603
|
+
operationName: "ai.streamText.doStream",
|
2604
|
+
telemetry
|
2605
|
+
}),
|
2549
2606
|
...baseTelemetryAttributes,
|
2550
2607
|
"ai.prompt.format": {
|
2551
2608
|
input: () => validatedPrompt.type
|