@arizeai/openinference-instrumentation-openai 4.4.1 → 4.4.2
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/esm/instrumentation.d.ts.map +1 -1
- package/dist/esm/instrumentation.js +13 -0
- package/dist/esm/instrumentation.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 +13 -1
- package/dist/esnext/instrumentation.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 +13 -1
- package/dist/src/instrumentation.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 +3 -3
- package/src/instrumentation.ts +14 -0
- 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": "4.4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "OpenInference instrumentation for OpenAI",
|
|
6
6
|
"keywords": [],
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@opentelemetry/api": "^1.9.0",
|
|
29
29
|
"@opentelemetry/core": "^2.8.0",
|
|
30
30
|
"@opentelemetry/instrumentation": "^0.46.0",
|
|
31
|
-
"@arizeai/openinference-core": "2.8.
|
|
32
|
-
"@arizeai/openinference-semantic-conventions": "2.
|
|
31
|
+
"@arizeai/openinference-core": "2.8.1",
|
|
32
|
+
"@arizeai/openinference-semantic-conventions": "2.15.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@opentelemetry/exporter-trace-otlp-proto": "^0.50.0",
|
package/src/instrumentation.ts
CHANGED
|
@@ -485,6 +485,7 @@ export class OpenAIInstrumentation extends InstrumentationBase<typeof openai> {
|
|
|
485
485
|
span.setAttributes({
|
|
486
486
|
// Do not record the output data as it can be large
|
|
487
487
|
...getEmbeddingEmbeddingsAttributes(result),
|
|
488
|
+
...getEmbeddingUsageAttributes(result),
|
|
488
489
|
});
|
|
489
490
|
}
|
|
490
491
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
@@ -981,6 +982,19 @@ function getEmbeddingEmbeddingsAttributes(response: CreateEmbeddingResponse): At
|
|
|
981
982
|
}, {});
|
|
982
983
|
}
|
|
983
984
|
|
|
985
|
+
/**
|
|
986
|
+
* Get the token usage of an embedding response
|
|
987
|
+
*/
|
|
988
|
+
function getEmbeddingUsageAttributes(response: CreateEmbeddingResponse): Attributes {
|
|
989
|
+
if (!response.usage) {
|
|
990
|
+
return {};
|
|
991
|
+
}
|
|
992
|
+
return {
|
|
993
|
+
[SemanticConventions.LLM_TOKEN_COUNT_PROMPT]: response.usage.prompt_tokens,
|
|
994
|
+
[SemanticConventions.LLM_TOKEN_COUNT_TOTAL]: response.usage.total_tokens,
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
|
|
984
998
|
/**
|
|
985
999
|
* Consumes the stream chunks and adds them to the span
|
|
986
1000
|
*/
|
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 = "4.4.
|
|
2
|
+
export const VERSION = "4.4.2";
|