@arizeai/openinference-instrumentation-openai 3.2.3 → 3.2.5

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.
Files changed (34) hide show
  1. package/dist/esm/instrumentation.d.ts +3 -3
  2. package/dist/esm/instrumentation.d.ts.map +1 -1
  3. package/dist/esm/instrumentation.js +9 -9
  4. package/dist/esm/instrumentation.js.map +1 -1
  5. package/dist/esm/responsesAttributes.d.ts +1 -1
  6. package/dist/esm/responsesAttributes.d.ts.map +1 -1
  7. package/dist/esm/responsesAttributes.js.map +1 -1
  8. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -1
  9. package/dist/esm/version.d.ts +1 -1
  10. package/dist/esm/version.js +1 -1
  11. package/dist/esnext/instrumentation.d.ts +3 -3
  12. package/dist/esnext/instrumentation.d.ts.map +1 -1
  13. package/dist/esnext/instrumentation.js +9 -9
  14. package/dist/esnext/instrumentation.js.map +1 -1
  15. package/dist/esnext/responsesAttributes.d.ts +1 -1
  16. package/dist/esnext/responsesAttributes.d.ts.map +1 -1
  17. package/dist/esnext/responsesAttributes.js.map +1 -1
  18. package/dist/esnext/tsconfig.esnext.tsbuildinfo +1 -1
  19. package/dist/esnext/version.d.ts +1 -1
  20. package/dist/esnext/version.js +1 -1
  21. package/dist/src/instrumentation.d.ts +3 -3
  22. package/dist/src/instrumentation.d.ts.map +1 -1
  23. package/dist/src/instrumentation.js +8 -8
  24. package/dist/src/instrumentation.js.map +1 -1
  25. package/dist/src/responsesAttributes.d.ts +1 -1
  26. package/dist/src/responsesAttributes.d.ts.map +1 -1
  27. package/dist/src/responsesAttributes.js.map +1 -1
  28. package/dist/src/version.d.ts +1 -1
  29. package/dist/src/version.js +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +4 -3
  32. package/src/instrumentation.ts +42 -41
  33. package/src/responsesAttributes.ts +3 -1
  34. 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.2.3",
3
+ "version": "3.2.5",
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": "1.0.7",
24
+ "@arizeai/openinference-core": "2.0.0",
25
25
  "@arizeai/openinference-semantic-conventions": "2.1.2"
26
26
  },
27
27
  "keywords": [],
@@ -39,7 +39,8 @@
39
39
  "@opentelemetry/semantic-conventions": "^1.25.1",
40
40
  "vitest": "^2.1.8",
41
41
  "openai": "^5.7.0",
42
- "zod": "^3.24.3"
42
+ "zod": "^3.24.3",
43
+ "typescript": "^5.5.4"
43
44
  },
44
45
  "scripts": {
45
46
  "prebuild": "rimraf dist && pnpm run version:update",
@@ -1,4 +1,28 @@
1
- import openai, { APIPromise } from "openai";
1
+ import {
2
+ OITracer,
3
+ safelyJSONStringify,
4
+ TraceConfigOptions,
5
+ } from "@arizeai/openinference-core";
6
+ import {
7
+ LLMProvider,
8
+ LLMSystem,
9
+ MimeType,
10
+ OpenInferenceSpanKind,
11
+ SemanticConventions,
12
+ } from "@arizeai/openinference-semantic-conventions";
13
+
14
+ import {
15
+ Attributes,
16
+ context,
17
+ diag,
18
+ Span,
19
+ SpanKind,
20
+ SpanStatusCode,
21
+ trace,
22
+ Tracer,
23
+ TracerProvider,
24
+ } from "@opentelemetry/api";
25
+ import { isTracingSuppressed } from "@opentelemetry/core";
2
26
  import {
3
27
  InstrumentationBase,
4
28
  InstrumentationConfig,
@@ -6,25 +30,22 @@ import {
6
30
  InstrumentationNodeModuleDefinition,
7
31
  safeExecuteInTheMiddle,
8
32
  } from "@opentelemetry/instrumentation";
33
+
9
34
  import {
10
- diag,
11
- context,
12
- trace,
13
- SpanKind,
14
- Attributes,
15
- SpanStatusCode,
16
- Span,
17
- TracerProvider,
18
- Tracer,
19
- } from "@opentelemetry/api";
35
+ consumeResponseStreamEvents,
36
+ getResponsesInputMessagesAttributes,
37
+ getResponsesOutputMessagesAttributes,
38
+ getResponsesUsageAttributes,
39
+ } from "./responsesAttributes";
40
+ import { assertUnreachable, isString } from "./typeUtils";
20
41
  import { VERSION } from "./version";
42
+
43
+ import openai, { APIPromise } from "openai";
21
44
  import {
22
- SemanticConventions,
23
- OpenInferenceSpanKind,
24
- MimeType,
25
- LLMSystem,
26
- LLMProvider,
27
- } from "@arizeai/openinference-semantic-conventions";
45
+ Completion,
46
+ CreateEmbeddingResponse,
47
+ EmbeddingCreateParams,
48
+ } from "openai/resources";
28
49
  import {
29
50
  ChatCompletion,
30
51
  ChatCompletionChunk,
@@ -33,32 +54,12 @@ import {
33
54
  ChatCompletionMessageParam,
34
55
  } from "openai/resources/chat/completions";
35
56
  import { CompletionCreateParamsBase } from "openai/resources/completions";
36
- import { Stream } from "openai/streaming";
37
- import {
38
- Completion,
39
- CreateEmbeddingResponse,
40
- EmbeddingCreateParams,
41
- } from "openai/resources";
42
- import { assertUnreachable, isString } from "./typeUtils";
43
- import { isTracingSuppressed } from "@opentelemetry/core";
44
-
45
- import {
46
- OITracer,
47
- safelyJSONStringify,
48
- TraceConfigOptions,
49
- } from "@arizeai/openinference-core";
50
57
  import {
58
+ Response as ResponseType,
51
59
  ResponseCreateParamsBase,
52
60
  ResponseStreamEvent,
53
- Response as ResponseType,
54
61
  } from "openai/resources/responses/responses";
55
-
56
- import {
57
- consumeResponseStreamEvents,
58
- getResponsesInputMessagesAttributes,
59
- getResponsesOutputMessagesAttributes,
60
- getResponsesUsageAttributes,
61
- } from "./responsesAttributes";
62
+ import { Stream } from "openai/streaming";
62
63
 
63
64
  const MODULE_NAME = "openai";
64
65
 
@@ -746,7 +747,7 @@ function getChatCompletionInputMessageAttributes(
746
747
  ] = toolCall.id;
747
748
  }
748
749
  // Make sure the tool call has a function
749
- if (toolCall.function) {
750
+ if (toolCall.type === "function") {
750
751
  attributes[
751
752
  `${toolCallIndexPrefix}${SemanticConventions.TOOL_CALL_FUNCTION_NAME}`
752
753
  ] = toolCall.function.name;
@@ -875,7 +876,7 @@ function getChatCompletionOutputMessageAttributes(
875
876
  }
876
877
  // Double check that the tool call has a function
877
878
  // NB: OpenAI only supports tool calls with functions right now but this may change
878
- if (toolCall.function) {
879
+ if (toolCall.type === "function") {
879
880
  attributes[
880
881
  toolCallIndexPrefix + SemanticConventions.TOOL_CALL_FUNCTION_NAME
881
882
  ] = toolCall.function.name;
@@ -1,11 +1,13 @@
1
1
  import { SemanticConventions } from "@arizeai/openinference-semantic-conventions";
2
+
2
3
  import { Attributes } from "@opentelemetry/api";
4
+
3
5
  import {
6
+ Response as ResponseType,
4
7
  ResponseCreateParamsBase,
5
8
  ResponseInputItem,
6
9
  ResponseOutputItem,
7
10
  ResponseStreamEvent,
8
- Response as ResponseType,
9
11
  } from "openai/resources/responses/responses";
10
12
  import { Stream } from "openai/streaming";
11
13
 
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 = "3.2.3";
2
+ export const VERSION = "3.2.5";