@arizeai/openinference-instrumentation-openai 3.2.4 → 4.0.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/README.md +1 -0
- package/dist/esm/instrumentation.d.ts.map +1 -1
- package/dist/esm/instrumentation.js +11 -3
- package/dist/esm/instrumentation.js.map +1 -1
- package/dist/esm/responsesAttributes.d.ts.map +1 -1
- package/dist/esm/responsesAttributes.js +10 -2
- package/dist/esm/responsesAttributes.js.map +1 -1
- package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/esm/version.d.ts +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esnext/instrumentation.d.ts.map +1 -1
- package/dist/esnext/instrumentation.js +11 -3
- package/dist/esnext/instrumentation.js.map +1 -1
- package/dist/esnext/responsesAttributes.d.ts.map +1 -1
- package/dist/esnext/responsesAttributes.js +10 -2
- package/dist/esnext/responsesAttributes.js.map +1 -1
- package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -1
- package/dist/esnext/version.d.ts +1 -1
- package/dist/esnext/version.js +1 -1
- package/dist/src/instrumentation.d.ts.map +1 -1
- package/dist/src/instrumentation.js +11 -3
- package/dist/src/instrumentation.js.map +1 -1
- package/dist/src/responsesAttributes.d.ts.map +1 -1
- package/dist/src/responsesAttributes.js +10 -2
- package/dist/src/responsesAttributes.js.map +1 -1
- package/dist/src/version.d.ts +1 -1
- package/dist/src/version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -4
- package/src/instrumentation.ts +8 -3
- package/src/responsesAttributes.ts +10 -2
- package/src/version.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arizeai/openinference-instrumentation-openai",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "OpenInference instrumentation for OpenAI",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/src/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"@opentelemetry/api": "^1.9.0",
|
|
22
22
|
"@opentelemetry/core": "^1.25.1",
|
|
23
23
|
"@opentelemetry/instrumentation": "^0.46.0",
|
|
24
|
-
"@arizeai/openinference-core": "
|
|
24
|
+
"@arizeai/openinference-core": "2.0.0",
|
|
25
25
|
"@arizeai/openinference-semantic-conventions": "2.1.2"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [],
|
|
@@ -37,9 +37,10 @@
|
|
|
37
37
|
"@opentelemetry/sdk-trace-base": "^1.25.1",
|
|
38
38
|
"@opentelemetry/sdk-trace-node": "^1.25.1",
|
|
39
39
|
"@opentelemetry/semantic-conventions": "^1.25.1",
|
|
40
|
+
"openai": "^6.7.0",
|
|
40
41
|
"vitest": "^2.1.8",
|
|
41
|
-
"
|
|
42
|
-
"
|
|
42
|
+
"zod": "^3.24.3",
|
|
43
|
+
"typescript": "^5.5.4"
|
|
43
44
|
},
|
|
44
45
|
"scripts": {
|
|
45
46
|
"prebuild": "rimraf dist && pnpm run version:update",
|
package/src/instrumentation.ts
CHANGED
|
@@ -208,7 +208,8 @@ export class OpenAIInstrumentation extends InstrumentationBase<typeof openai> {
|
|
|
208
208
|
protected init(): InstrumentationModuleDefinition<typeof openai> {
|
|
209
209
|
const module = new InstrumentationNodeModuleDefinition<typeof openai>(
|
|
210
210
|
"openai",
|
|
211
|
-
|
|
211
|
+
// 5.x is best effort
|
|
212
|
+
["^6.0.0", "^5.0.0"],
|
|
212
213
|
this.patch.bind(this),
|
|
213
214
|
this.unpatch.bind(this),
|
|
214
215
|
);
|
|
@@ -754,6 +755,9 @@ function getChatCompletionInputMessageAttributes(
|
|
|
754
755
|
attributes[
|
|
755
756
|
`${toolCallIndexPrefix}${SemanticConventions.TOOL_CALL_FUNCTION_ARGUMENTS_JSON}`
|
|
756
757
|
] = toolCall.function.arguments;
|
|
758
|
+
} else {
|
|
759
|
+
// TODO: add exhaustive checks
|
|
760
|
+
diag.warn(`Unsupported tool type: ${toolCall.type}`);
|
|
757
761
|
}
|
|
758
762
|
});
|
|
759
763
|
}
|
|
@@ -874,8 +878,6 @@ function getChatCompletionOutputMessageAttributes(
|
|
|
874
878
|
`${toolCallIndexPrefix}${SemanticConventions.TOOL_CALL_ID}`
|
|
875
879
|
] = toolCall.id;
|
|
876
880
|
}
|
|
877
|
-
// Double check that the tool call has a function
|
|
878
|
-
// NB: OpenAI only supports tool calls with functions right now but this may change
|
|
879
881
|
if (toolCall.type === "function") {
|
|
880
882
|
attributes[
|
|
881
883
|
toolCallIndexPrefix + SemanticConventions.TOOL_CALL_FUNCTION_NAME
|
|
@@ -884,6 +886,9 @@ function getChatCompletionOutputMessageAttributes(
|
|
|
884
886
|
toolCallIndexPrefix +
|
|
885
887
|
SemanticConventions.TOOL_CALL_FUNCTION_ARGUMENTS_JSON
|
|
886
888
|
] = toolCall.function.arguments;
|
|
889
|
+
} else {
|
|
890
|
+
// TODO: switch to exhaustive checks
|
|
891
|
+
diag.warn(`Unsupported tool type: ${toolCall.type}`);
|
|
887
892
|
}
|
|
888
893
|
});
|
|
889
894
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { safelyJSONStringify } from "@arizeai/openinference-core";
|
|
1
2
|
import { SemanticConventions } from "@arizeai/openinference-semantic-conventions";
|
|
2
3
|
|
|
3
4
|
import { Attributes } from "@opentelemetry/api";
|
|
@@ -44,8 +45,15 @@ function getResponseItemAttributes(
|
|
|
44
45
|
attributes[`${prefix}${SemanticConventions.MESSAGE_ROLE}`] = "tool";
|
|
45
46
|
attributes[`${prefix}${SemanticConventions.MESSAGE_TOOL_CALL_ID}`] =
|
|
46
47
|
item.call_id;
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
if (typeof item.output === "string") {
|
|
49
|
+
attributes[`${prefix}${SemanticConventions.MESSAGE_CONTENT}`] =
|
|
50
|
+
item.output;
|
|
51
|
+
} else {
|
|
52
|
+
// TODO(2410): figure out how to serialize the list of tools
|
|
53
|
+
attributes[`${prefix}${SemanticConventions.MESSAGE_CONTENT}`] =
|
|
54
|
+
safelyJSONStringify(item.output) || undefined;
|
|
55
|
+
}
|
|
56
|
+
|
|
49
57
|
break;
|
|
50
58
|
}
|
|
51
59
|
case "reasoning": {
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// this is an auto-generated file. see js/scripts/version-update.js
|
|
2
|
-
export const VERSION = "
|
|
2
|
+
export const VERSION = "4.0.0";
|