ai 6.0.208 → 6.0.209
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 +8 -0
- package/dist/index.js +34 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +34 -4
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +2 -2
- package/src/telemetry/sanitize-attribute-value.ts +39 -0
- package/src/telemetry/select-telemetry-attributes.ts +7 -3
package/dist/internal/index.js
CHANGED
|
@@ -152,7 +152,7 @@ function detectMediaType({
|
|
|
152
152
|
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
153
153
|
|
|
154
154
|
// src/version.ts
|
|
155
|
-
var VERSION = true ? "6.0.
|
|
155
|
+
var VERSION = true ? "6.0.209" : "0.0.0-test";
|
|
156
156
|
|
|
157
157
|
// src/util/download/download.ts
|
|
158
158
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ai",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.209",
|
|
4
4
|
"description": "AI SDK by Vercel - build apps like ChatGPT, Claude, Gemini, and more with a single interface for any model using the Vercel AI Gateway or go direct to OpenAI, Anthropic, Google, or any other model provider.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@opentelemetry/api": "^1.9.0",
|
|
48
|
-
"@ai-sdk/gateway": "3.0.
|
|
48
|
+
"@ai-sdk/gateway": "3.0.134",
|
|
49
49
|
"@ai-sdk/provider": "3.0.10",
|
|
50
50
|
"@ai-sdk/provider-utils": "4.0.30"
|
|
51
51
|
},
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AttributeValue } from '@opentelemetry/api';
|
|
2
|
+
|
|
3
|
+
function isPrimitiveAttributeValue(
|
|
4
|
+
value: unknown,
|
|
5
|
+
): value is string | number | boolean {
|
|
6
|
+
return (
|
|
7
|
+
typeof value === 'string' ||
|
|
8
|
+
typeof value === 'number' ||
|
|
9
|
+
typeof value === 'boolean'
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function sanitizeAttributeValue(
|
|
14
|
+
value: AttributeValue,
|
|
15
|
+
): AttributeValue | undefined {
|
|
16
|
+
if (!Array.isArray(value)) {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const primitiveTypes = new Set(
|
|
21
|
+
value.filter(isPrimitiveAttributeValue).map(item => typeof item),
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
if (primitiveTypes.size !== 1) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const [primitiveType] = primitiveTypes;
|
|
29
|
+
|
|
30
|
+
if (primitiveType === 'string') {
|
|
31
|
+
return value.filter((item): item is string => typeof item === 'string');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (primitiveType === 'number') {
|
|
35
|
+
return value.filter((item): item is number => typeof item === 'number');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return value.filter((item): item is boolean => typeof item === 'boolean');
|
|
39
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Attributes, AttributeValue } from '@opentelemetry/api';
|
|
2
|
+
import { sanitizeAttributeValue } from './sanitize-attribute-value';
|
|
2
3
|
import type { TelemetrySettings } from './telemetry-settings';
|
|
3
4
|
|
|
4
5
|
type ResolvableAttributeValue = () =>
|
|
@@ -45,7 +46,8 @@ export async function selectTelemetryAttributes({
|
|
|
45
46
|
const result = await value.input();
|
|
46
47
|
|
|
47
48
|
if (result != null) {
|
|
48
|
-
|
|
49
|
+
const sanitized = sanitizeAttributeValue(result);
|
|
50
|
+
if (sanitized != null) resultAttributes[key] = sanitized;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
continue;
|
|
@@ -65,13 +67,15 @@ export async function selectTelemetryAttributes({
|
|
|
65
67
|
const result = await value.output();
|
|
66
68
|
|
|
67
69
|
if (result != null) {
|
|
68
|
-
|
|
70
|
+
const sanitized = sanitizeAttributeValue(result);
|
|
71
|
+
if (sanitized != null) resultAttributes[key] = sanitized;
|
|
69
72
|
}
|
|
70
73
|
continue;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
// value is an attribute value already:
|
|
74
|
-
|
|
77
|
+
const sanitized = sanitizeAttributeValue(value as AttributeValue);
|
|
78
|
+
if (sanitized != null) resultAttributes[key] = sanitized;
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
return resultAttributes;
|