@arizeai/openinference-genai 0.1.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.
Files changed (34) hide show
  1. package/README.md +137 -0
  2. package/dist/esm/__generated__/opentelemetryInputMessages.d.ts +103 -0
  3. package/dist/esm/__generated__/opentelemetryInputMessages.d.ts.map +1 -0
  4. package/dist/esm/__generated__/opentelemetryInputMessages.js +7 -0
  5. package/dist/esm/__generated__/opentelemetryInputMessages.js.map +1 -0
  6. package/dist/esm/__generated__/opentelemetryOutputMessages.d.ts +116 -0
  7. package/dist/esm/__generated__/opentelemetryOutputMessages.d.ts.map +1 -0
  8. package/dist/esm/__generated__/opentelemetryOutputMessages.js +7 -0
  9. package/dist/esm/__generated__/opentelemetryOutputMessages.js.map +1 -0
  10. package/dist/esm/attributes.d.ts +79 -0
  11. package/dist/esm/attributes.d.ts.map +1 -0
  12. package/dist/esm/attributes.js +306 -0
  13. package/dist/esm/attributes.js.map +1 -0
  14. package/dist/esm/index.d.ts +2 -0
  15. package/dist/esm/index.d.ts.map +1 -0
  16. package/dist/esm/index.js +10 -0
  17. package/dist/esm/index.js.map +1 -0
  18. package/dist/esm/package.json +1 -0
  19. package/dist/esm/tsconfig.esm.tsbuildinfo +1 -0
  20. package/dist/esm/types.d.ts +9 -0
  21. package/dist/esm/types.d.ts.map +1 -0
  22. package/dist/esm/types.js +2 -0
  23. package/dist/esm/types.js.map +1 -0
  24. package/dist/esm/utils.d.ts +42 -0
  25. package/dist/esm/utils.d.ts.map +1 -0
  26. package/dist/esm/utils.js +94 -0
  27. package/dist/esm/utils.js.map +1 -0
  28. package/package.json +68 -0
  29. package/src/__generated__/opentelemetryInputMessages.ts +104 -0
  30. package/src/__generated__/opentelemetryOutputMessages.ts +122 -0
  31. package/src/attributes.ts +467 -0
  32. package/src/index.ts +14 -0
  33. package/src/types.ts +14 -0
  34. package/src/utils.ts +106 -0
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # OpenInference GenAI
2
+
3
+ [![npm version](https://badge.fury.io/js/@arizeai%2Fopeninference-genai.svg)](https://badge.fury.io/js/@arizeai%2Fopeninference-genai)
4
+
5
+ This package provides a set of utilities to convert [OpenTelemetry GenAI](https://github.com/open-telemetry/opentelemetry-js-contrib/tree/main/packages/instrumentation/opentelemetry-instrumentation-genai) span attributes to OpenInference span attributes.
6
+
7
+ > [!WARNING]
8
+ > The OpenTelemetry GenAI conventions are still incubating, and may include breaking changes at any time.
9
+ > This package will attempt best effort conversions of a subset of the OpenTelemetry GenAI attributes to OpenInference attributes.
10
+ > Currently, attributes reflect their definition as of October 2025.
11
+
12
+ ## Installation
13
+
14
+ ```shell
15
+ npm install --save @arizeai/openinference-genai
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ `@arizeai/openinference-genai` can be used as a standalone set of helper functions,
21
+ or in conjunction with a SpanProcessor in order to automatically convert OpenTelemetry GenAI spans to OpenInference spans.
22
+
23
+ ### Standalone
24
+
25
+ You can mutate the span attributes in place by using the standalone helper functions.
26
+
27
+ > [!IMPORTANT]
28
+ > Span mutation is not supported by the OpenTelemetry SDK, so ensure that you are
29
+ > performing mutations in the last-mile of the span's lifetime (i.e. just before exporting the span in a SpanProcessor).
30
+
31
+ ```ts
32
+ import { convertGenAISpanAttributesToOpenInferenceSpanAttributes } from `@arizeai/openinference-genai`
33
+
34
+ // obtain a span with OpenTelemetry GenAI attributes from your tracing system
35
+ const span: ReadableSpan = {/* ... */}
36
+
37
+ // convert the span attributes to OpenInference attributes
38
+ const openinferenceAttributes = convertGenAISpanAttributesToOpenInferenceSpanAttributes(span.attributes)
39
+
40
+ // add the OpenInference attributes to the span
41
+ span.attributes = {...span.attributes, ...openinferenceAttributes}
42
+ ```
43
+
44
+ ### SpanProcessor
45
+
46
+ You can use the a custom TraceExporter to automatically convert OpenTelemetry GenAI spans to OpenInference spans.
47
+
48
+ See [examples/export-spans.ts](./examples/export-spans.ts) for a runnable version of the following sample code.
49
+
50
+ Start by installing packages
51
+
52
+ ```shell
53
+ pnpm add @opentelemetry/api @opentelemetry/core @opentelemetry/exporter-trace-otlp-proto @opentelemetry/sdk-trace-base @opentelemetry/sdk-trace-node @opentelemetry/semantic-conventions @opentelemetry/resources @arizeai/openinference-genai
54
+ ```
55
+
56
+ Create a custom TraceExporter that converts the OpenTelemetry GenAI attributes to OpenInference attributes.
57
+
58
+ ```ts
59
+ // openinferenceOTLPTraceExporter.ts
60
+ import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-proto";
61
+ import type { ReadableSpan } from "@opentelemetry/sdk-trace-base";
62
+ import type { ExportResult } from "@opentelemetry/core";
63
+
64
+ import { convertGenAISpanAttributesToOpenInferenceSpanAttributes } from "@arizeai/openinference-genai";
65
+ import type { Mutable } from "@arizeai/openinference-genai/types";
66
+
67
+ class OpenInferenceOTLPTraceExporter extends OTLPTraceExporter {
68
+ export(
69
+ spans: ReadableSpan[],
70
+ resultCallback: (result: ExportResult) => void,
71
+ ) {
72
+ const processedSpans = spans.map((span) => {
73
+ const processedAttributes =
74
+ convertGenAISpanAttributesToOpenInferenceSpanAttributes(
75
+ span.attributes,
76
+ );
77
+ // optionally you can replace the entire attributes object with the
78
+ // processed attributes if you want _only_ the OpenInference attributes
79
+ (span as Mutable<ReadableSpan>).attributes = {
80
+ ...span.attributes,
81
+ ...processedAttributes,
82
+ };
83
+ return span;
84
+ });
85
+
86
+ super.export(processedSpans, resultCallback);
87
+ }
88
+ }
89
+ ```
90
+
91
+ And then use it in the SpanProcessor of your choice.
92
+
93
+ ```ts
94
+ // instrumentation.ts
95
+ import { resourceFromAttributes } from "@opentelemetry/resources";
96
+ import {
97
+ NodeTracerProvider,
98
+ BatchSpanProcessor,
99
+ } from "@opentelemetry/sdk-trace-node";
100
+ import { ATTR_SERVICE_NAME } from "@opentelemetry/semantic-conventions";
101
+
102
+ import { SEMRESATTRS_PROJECT_NAME } from "@arizeai/openinference-semantic-conventions";
103
+
104
+ import { OpenInferenceOTLPTraceExporter } from "./openinferenceOTLPTraceExporter";
105
+
106
+ const COLLECTOR_ENDPOINT = process.env.COLLECTOR_ENDPOINT;
107
+ const SERVICE_NAME = "openinference-genai-app";
108
+
109
+ export const provider = new NodeTracerProvider({
110
+ resource: resourceFromAttributes({
111
+ [ATTR_SERVICE_NAME]: SERVICE_NAME,
112
+ [SEMRESATTRS_PROJECT_NAME]: SERVICE_NAME,
113
+ }),
114
+ spanProcessors: [
115
+ new BatchSpanProcessor(
116
+ new OpenInferenceOTLPTraceExporter({
117
+ url: `${COLLECTOR_ENDPOINT}/v1/traces`,
118
+ }),
119
+ ),
120
+ ],
121
+ });
122
+
123
+ provider.register();
124
+ ```
125
+
126
+ ## Examples
127
+
128
+ See the [examples](./examples) directory in this package for more executable examples.
129
+
130
+ To execute an example, run the following commands:
131
+
132
+ ```shell
133
+ cd js/packages/openinference-genai
134
+ pnpm install
135
+ pnpm -r build
136
+ pnpx tsx examples/export-spans.ts
137
+ ```
@@ -0,0 +1,103 @@
1
+ /**
2
+ * OpenTelemetry input messages schema
3
+ * As of 10/14/2025, this schema is still in draft status.
4
+ * https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
5
+ */
6
+ /**
7
+ * Role of the entity that created the message.
8
+ */
9
+ export type Role = Role1 | string;
10
+ export type Role1 = "system" | "user" | "assistant" | "tool";
11
+ /**
12
+ * The type of the content captured in this part.
13
+ */
14
+ export type Type = "text";
15
+ /**
16
+ * Text content sent to or received from the model.
17
+ */
18
+ export type Content = string;
19
+ /**
20
+ * The type of the content captured in this part.
21
+ */
22
+ export type Type1 = "tool_call";
23
+ /**
24
+ * Unique identifier for the tool call.
25
+ */
26
+ export type Id = string | null;
27
+ /**
28
+ * Name of the tool.
29
+ */
30
+ export type Name = string;
31
+ /**
32
+ * The type of the content captured in this part.
33
+ */
34
+ export type Type2 = "tool_call_response";
35
+ /**
36
+ * Unique tool call identifier.
37
+ */
38
+ export type Id1 = string | null;
39
+ /**
40
+ * The type of the content captured in this part.
41
+ */
42
+ export type Type3 = string;
43
+ /**
44
+ * List of message parts that make up the message content.
45
+ */
46
+ export type Parts = (TextPart | ToolCallRequestPart | ToolCallResponsePart)[];
47
+ /**
48
+ * Represents the list of input messages sent to the model.
49
+ */
50
+ export type InputMessages = ChatMessage[];
51
+ export interface ChatMessage {
52
+ role: Role;
53
+ parts: Parts;
54
+ [k: string]: unknown;
55
+ }
56
+ /**
57
+ * Represents text content sent to or received from the model.
58
+ */
59
+ export interface TextPart {
60
+ type: Type;
61
+ content: Content;
62
+ [k: string]: unknown;
63
+ }
64
+ /**
65
+ * Represents a tool call requested by the model.
66
+ */
67
+ export interface ToolCallRequestPart {
68
+ type: Type1;
69
+ id?: Id;
70
+ name: Name;
71
+ arguments?: Arguments;
72
+ [k: string]: unknown;
73
+ }
74
+ /**
75
+ * Arguments for the tool call.
76
+ */
77
+ export interface Arguments {
78
+ [k: string]: unknown;
79
+ }
80
+ /**
81
+ * Represents a tool call result sent to the model or a built-in tool call outcome and details.
82
+ */
83
+ export interface ToolCallResponsePart {
84
+ type: Type2;
85
+ id?: Id1;
86
+ response: Response;
87
+ [k: string]: unknown;
88
+ }
89
+ /**
90
+ * Tool call response.
91
+ */
92
+ export interface Response {
93
+ [k: string]: unknown;
94
+ }
95
+ /**
96
+ * Represents an arbitrary message part with any type and properties.
97
+ * This allows for extensibility with custom message part types.
98
+ */
99
+ export interface GenericPart {
100
+ type: Type3;
101
+ [k: string]: unknown;
102
+ }
103
+ //# sourceMappingURL=opentelemetryInputMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetryInputMessages.d.ts","sourceRoot":"","sources":["../../../src/__generated__/opentelemetryInputMessages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAC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AEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * OpenTelemetry input messages schema
3
+ * As of 10/14/2025, this schema is still in draft status.
4
+ * https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-input-messages.json
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=opentelemetryInputMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetryInputMessages.js","sourceRoot":"","sources":["../../../src/__generated__/opentelemetryInputMessages.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,116 @@
1
+ /**
2
+ * OpenTelemetry output messages schema
3
+ * As of 10/14/2025, this schema is still in draft status.
4
+ * https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json
5
+ */
6
+ /**
7
+ * Role of the entity that created the message.
8
+ */
9
+ export type Role = Role1 | string;
10
+ export type Role1 = "system" | "user" | "assistant" | "tool";
11
+ /**
12
+ * The type of the content captured in this part.
13
+ */
14
+ export type Type = "text";
15
+ /**
16
+ * Text content sent to or received from the model.
17
+ */
18
+ export type Content = string;
19
+ /**
20
+ * The type of the content captured in this part.
21
+ */
22
+ export type Type1 = "tool_call";
23
+ /**
24
+ * Unique identifier for the tool call.
25
+ */
26
+ export type Id = string | null;
27
+ /**
28
+ * Name of the tool.
29
+ */
30
+ export type Name = string;
31
+ /**
32
+ * The type of the content captured in this part.
33
+ */
34
+ export type Type2 = "tool_call_response";
35
+ /**
36
+ * Unique tool call identifier.
37
+ */
38
+ export type Id1 = string | null;
39
+ /**
40
+ * The type of the content captured in this part.
41
+ */
42
+ export type Type3 = string;
43
+ /**
44
+ * List of message parts that make up the message content.
45
+ */
46
+ export type Parts = (TextPart | ToolCallRequestPart | ToolCallResponsePart)[];
47
+ /**
48
+ * Reason for finishing the generation.
49
+ */
50
+ export type FinishReason = FinishReason1 | string;
51
+ /**
52
+ * Represents the reason for finishing the generation.
53
+ */
54
+ export type FinishReason1 = "stop" | "length" | "content_filter" | "tool_call" | "error";
55
+ /**
56
+ * Represents the list of output messages generated by the model or agent.
57
+ */
58
+ export type OutputMessages = OutputMessage[];
59
+ /**
60
+ * Represents an output message generated by the model or agent. The output message captures
61
+ * specific response (choice, candidate).
62
+ */
63
+ export interface OutputMessage {
64
+ role: Role;
65
+ parts: Parts;
66
+ finish_reason: FinishReason;
67
+ [k: string]: unknown;
68
+ }
69
+ /**
70
+ * Represents text content sent to or received from the model.
71
+ */
72
+ export interface TextPart {
73
+ type: Type;
74
+ content: Content;
75
+ [k: string]: unknown;
76
+ }
77
+ /**
78
+ * Represents a tool call requested by the model.
79
+ */
80
+ export interface ToolCallRequestPart {
81
+ type: Type1;
82
+ id?: Id;
83
+ name: Name;
84
+ arguments?: Arguments;
85
+ [k: string]: unknown;
86
+ }
87
+ /**
88
+ * Arguments for the tool call.
89
+ */
90
+ export interface Arguments {
91
+ [k: string]: unknown;
92
+ }
93
+ /**
94
+ * Represents a tool call result sent to the model or a built-in tool call outcome and details.
95
+ */
96
+ export interface ToolCallResponsePart {
97
+ type: Type2;
98
+ id?: Id1;
99
+ response: Response;
100
+ [k: string]: unknown;
101
+ }
102
+ /**
103
+ * Tool call response.
104
+ */
105
+ export interface Response {
106
+ [k: string]: unknown;
107
+ }
108
+ /**
109
+ * Represents an arbitrary message part with any type and properties.
110
+ * This allows for extensibility with custom message part types.
111
+ */
112
+ export interface GenericPart {
113
+ type: Type3;
114
+ [k: string]: unknown;
115
+ }
116
+ //# sourceMappingURL=opentelemetryOutputMessages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetryOutputMessages.d.ts","sourceRoot":"","sources":["../../../src/__generated__/opentelemetryOutputMessages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,KAAK,GAAG,MAAM,CAAC;AAClC,MAAM,MAAM,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,CAAC;AAC7D;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,WAAW,CAAC;AAChC;;GAEG;AACH,MAAM,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAAC;AAC/B;;GAEG;AACH,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAC1B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,oBAAoB,CAAC;AACzC;;GAEG;AACH,MAAM,MAAM,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC;AAChC;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B;;GAEG;AACH,MAAM,MAAM,KAAK,GAAG,CAAC,QAAQ,GAAG,mBAAmB,GAAG,oBAAoB,CAAC,EAAE,CAAC;AAC9E;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;AAClD;;GAEG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,QAAQ,GACR,gBAAgB,GAChB,WAAW,GACX,OAAO,CAAC;AACZ;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,aAAa,EAAE,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,KAAK,EAAE,KAAK,CAAC;IACb,aAAa,EAAE,YAAY,CAAC;IAC5B,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,IAAI,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,CAAC,EAAE,EAAE,CAAC;IACR,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,KAAK,CAAC;IACZ,EAAE,CAAC,EAAE,GAAG,CAAC;IACT,QAAQ,EAAE,QAAQ,CAAC;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AACD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,KAAK,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * OpenTelemetry output messages schema
3
+ * As of 10/14/2025, this schema is still in draft status.
4
+ * https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-output-messages.json
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=opentelemetryOutputMessages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opentelemetryOutputMessages.js","sourceRoot":"","sources":["../../../src/__generated__/opentelemetryOutputMessages.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,79 @@
1
+ import type { Attributes } from "@opentelemetry/api";
2
+ import type { ChatMessage } from "./__generated__/opentelemetryInputMessages.js";
3
+ import type { OutputMessage } from "./__generated__/opentelemetryOutputMessages.js";
4
+ export type GenAIInputMessage = ChatMessage;
5
+ export type GenAIInputMessagePart = ChatMessage["parts"][number];
6
+ export type GenAIOutputMessage = OutputMessage & {
7
+ /** @deprecated use parts instead */
8
+ text?: string;
9
+ };
10
+ export type GenAIOutputMessagePart = OutputMessage["parts"][number];
11
+ /**
12
+ * Convert GenAI span attributes to OpenInference span attributes
13
+ * @param spanAttributes - The span attributes containing GenAI span attributes to convert
14
+ * @returns The converted OpenInference span attributes
15
+ */
16
+ export declare const convertGenAISpanAttributesToOpenInferenceSpanAttributes: (spanAttributes: Attributes) => Attributes;
17
+ /**
18
+ * Map provider and system to openinference attributes
19
+ * @todo add some heuristics that can map incoming provider names to the correct OpenInference provider name
20
+ * @param spanAttributes - The span attributes containing provider and system to map
21
+ * @returns The mapped provider and system attributes
22
+ */
23
+ export declare const mapProviderAndSystem: (spanAttributes: Attributes) => Attributes;
24
+ /**
25
+ * Map model name to openinference attributes
26
+ * @param spanAttributes - The span attributes containing model name to map
27
+ * @returns The mapped model name attributes
28
+ */
29
+ export declare const mapModels: (spanAttributes: Attributes) => Attributes;
30
+ /**
31
+ * Map span kind to openinference attributes
32
+ * @param spanAttributes - The span attributes containing span kind to map
33
+ * @returns The mapped span kind attributes
34
+ */
35
+ export declare const mapSpanKind: (spanAttributes: Attributes) => Attributes;
36
+ /**
37
+ * Map invocation parameters to openinference attributes
38
+ * @param spanAttributes - The span attributes containing invocation parameters to map
39
+ * @returns The mapped invocation parameters attributes
40
+ */
41
+ export declare const mapInvocationParameters: (spanAttributes: Attributes) => Attributes;
42
+ /**
43
+ * Map input value to openinference attributes
44
+ * @param spanAttributes - The span attributes containing input value to map
45
+ * @returns The mapped input value attributes
46
+ */
47
+ export declare const mapInputValue: (spanAttributes: Attributes) => Attributes;
48
+ /**
49
+ * Map output value to openinference attributes
50
+ * @param spanAttributes - The span attributes containing output value to map
51
+ * @returns The mapped output value attributes
52
+ */
53
+ export declare const mapOutputValue: (spanAttributes: Attributes) => Attributes;
54
+ /**
55
+ * Map input messages to openinference attributes
56
+ * @param spanAttributes - The span attributes containing input messages to map
57
+ * @returns The mapped input messages attributes
58
+ */
59
+ export declare const mapInputMessages: (spanAttributes: Attributes) => Attributes;
60
+ /**
61
+ * Map output messages to openinference attributes
62
+ * @param spanAttributes - The span attributes containing output messages to map
63
+ * @returns The mapped output messages attributes
64
+ */
65
+ export declare const mapOutputMessages: (spanAttributes: Attributes) => Attributes;
66
+ /**
67
+ * Map usage token counts to openinference attributes
68
+ * @param spanAttributes - The span attributes containing usage token counts to map
69
+ * @returns The mapped usage token counts attributes
70
+ */
71
+ export declare const mapTokenCounts: (spanAttributes: Attributes) => Attributes;
72
+ /**
73
+ * Map tool execution to openinference attributes
74
+ * @see https://opentelemetry.io/docs/specs/semconv/gen-ai/gen-ai-spans/#execute-tool-span
75
+ * @param spanAttributes - The span attributes containing tool execution to map
76
+ * @returns The mapped tool execution attributes
77
+ */
78
+ export declare const mapToolExecution: (spanAttributes: Attributes) => Attributes;
79
+ //# sourceMappingURL=attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../src/attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AA2CrD,OAAO,KAAK,EACV,WAAW,EAEZ,MAAM,+CAA+C,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gDAAgD,CAAC;AAEpF,MAAM,MAAM,iBAAiB,GAAG,WAAW,CAAC;AAC5C,MAAM,MAAM,qBAAqB,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CA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