From 83737ee5291a68c59f255ab91216048824d7406b Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Wed, 3 Apr 2024 20:31:54 +0200 Subject: [PATCH 1/3] fix(sdk): clean and typed instrumentations (#182) --- package-lock.json | 702 ++++++++---------- packages/ai-semantic-conventions/src/index.ts | 5 - packages/instrumentation-azure/package.json | 1 - packages/traceloop-sdk/package.json | 12 +- .../initialize-options.interface.ts | 36 +- .../traceloop-sdk/src/lib/tracing/index.ts | 239 ++---- 6 files changed, 406 insertions(+), 589 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4227fe42..973c4841 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4485,19 +4485,12 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/@llamaindex/cloud": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/@llamaindex/cloud/-/cloud-0.0.1.tgz", - "integrity": "sha512-7FrLAbY459B4rcG4NaqANatDT5zKvZxIRyrY+nnTSXqu9ZMzkm1Co8IIRYx2/9feps/OLOhXsv7VKGGUr7scNQ==" - }, "node_modules/@mistralai/mistralai": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-0.0.7.tgz", - "integrity": "sha512-47FiV/GBnt6gug99ZfDBcBofYuYvqT5AyhUDdtktUbCN+gq52tmiAbtwc88k7hlyUWHzJ28VpHRDfNTRfaWKxA==", - "dev": true, + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/@mistralai/mistralai/-/mistralai-0.0.10.tgz", + "integrity": "sha512-fZOt7A32DcPSff58wTa44pKUBoJBH5toAuzNI9yoM7s5NjTupa1IYcSqqk2LigO8M5EtOEkFsD/XzdyWPnhaRA==", "dependencies": { - "axios": "^1.6.2", - "axios-retry": "^4.0.0" + "node-fetch": "^2.6.7" } }, "node_modules/@mongodb-js/saslprep": { @@ -7665,6 +7658,11 @@ "node": ">=12" } }, + "node_modules/@types/qs": { + "version": "6.9.14", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.14.tgz", + "integrity": "sha512-5khscbd3SwWMhFqylJBLQ0zIu7c1K6Vz0uBIt915BI3zV0q1nfjRQD3RqSBcPaO6PHEF4ov/t9y89fSiyThlPA==" + }, "node_modules/@types/request": { "version": "2.48.12", "resolved": "https://registry.npmjs.org/@types/request/-/request-2.48.12.tgz", @@ -8336,18 +8334,6 @@ "proxy-from-env": "^1.1.0" } }, - "node_modules/axios-retry": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/axios-retry/-/axios-retry-4.0.0.tgz", - "integrity": "sha512-F6P4HVGITD/v4z9Lw2mIA24IabTajvpDZmKa6zq/gGwn57wN5j1P3uWrAV0+diqnW6kTM2fTqmWNfgYWGmMuiA==", - "dev": true, - "dependencies": { - "is-retry-allowed": "^2.2.0" - }, - "peerDependencies": { - "axios": "0.x || 1.x" - } - }, "node_modules/b4a": { "version": "1.6.6", "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.6.tgz", @@ -10046,12 +10032,6 @@ "node": "*" } }, - "node_modules/crypto-js": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", - "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==", - "dev": true - }, "node_modules/cz-conventional-changelog": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/cz-conventional-changelog/-/cz-conventional-changelog-3.3.0.tgz", @@ -10152,6 +10132,16 @@ "node": ">=8" } }, + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", + "optional": true, + "peer": true, + "engines": { + "node": ">= 12" + } + }, "node_modules/dateformat": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-3.0.3.tgz", @@ -11351,6 +11341,30 @@ "resolved": "https://registry.npmjs.org/fecha/-/fecha-4.2.3.tgz", "integrity": "sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==" }, + "node_modules/fetch-blob": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", + "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/jimmywarting" + }, + { + "type": "paypal", + "url": "https://paypal.me/jimmywarting" + } + ], + "optional": true, + "peer": true, + "dependencies": { + "node-domexception": "^1.0.0", + "web-streams-polyfill": "^3.0.3" + }, + "engines": { + "node": "^12.20 || >= 14.13" + } + }, "node_modules/fetch-retry": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/fetch-retry/-/fetch-retry-5.0.6.tgz", @@ -11650,6 +11664,19 @@ "node": ">= 14" } }, + "node_modules/formdata-polyfill": { + "version": "4.0.10", + "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", + "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", + "optional": true, + "peer": true, + "dependencies": { + "fetch-blob": "^3.1.2" + }, + "engines": { + "node": ">=12.20.0" + } + }, "node_modules/forwarded": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", @@ -13160,18 +13187,6 @@ "node": ">=0.10.0" } }, - "node_modules/is-retry-allowed": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/is-retry-allowed/-/is-retry-allowed-2.2.0.tgz", - "integrity": "sha512-XVm7LOeLpTW4jV19QSH38vkswxoLud8sQ57YwJVTPWdiaI9I8keEhGFpBlslyVsgdQy4Opg8QOLb8YRgsyZiQg==", - "dev": true, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/sponsors/sindresorhus" - } - }, "node_modules/is-ssh": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/is-ssh/-/is-ssh-1.4.0.tgz", @@ -14876,41 +14891,181 @@ } }, "node_modules/llamaindex": { - "version": "0.0.40", - "resolved": "https://registry.npmjs.org/llamaindex/-/llamaindex-0.0.40.tgz", - "integrity": "sha512-uDMlylvGJgy5Ope9XLhfzpSUAvau6qJ4PpOerrtJxqGb/gF3JigqhPHGHWCIgB3GLXmogUWCtblkioG09WvH0g==", - "dev": true, + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/llamaindex/-/llamaindex-0.1.21.tgz", + "integrity": "sha512-tFERGfsYY3GxwrcDugwa74u9i6v27sZsJgmnIi8PWXAiox2GbFVaSJqQxkXDcDtshatBwp/cOnuDmWXlO5Rugw==", "dependencies": { - "@anthropic-ai/sdk": "^0.9.1", - "@datastax/astra-db-ts": "^0.1.2", - "@mistralai/mistralai": "^0.0.7", + "@anthropic-ai/sdk": "^0.15.0", + "@aws-crypto/sha256-js": "^5.2.0", + "@datastax/astra-db-ts": "^0.1.4", + "@llamaindex/cloud": "0.0.4", + "@llamaindex/env": "0.0.5", + "@mistralai/mistralai": "^0.0.10", "@notionhq/client": "^2.2.14", - "@xenova/transformers": "^2.10.0", - "assemblyai": "^4.0.0", - "crypto-js": "^4.2.0", + "@pinecone-database/pinecone": "^2.0.1", + "@qdrant/js-client-rest": "^1.7.0", + "@types/lodash": "^4.14.202", + "@types/node": "^18.19.14", + "@types/papaparse": "^5.3.14", + "@types/pg": "^8.11.0", + "@xenova/transformers": "^2.15.0", + "assemblyai": "^4.2.2", + "chromadb": "~1.7.3", + "cohere-ai": "^7.7.5", "file-type": "^18.7.0", - "js-tiktoken": "^1.0.8", + "js-tiktoken": "^1.0.10", "lodash": "^4.17.21", "mammoth": "^1.6.0", "md-utils-ts": "^2.0.0", "mongodb": "^6.3.0", "notion-md-crawler": "^0.0.2", - "openai": "^4.20.1", + "openai": "^4.26.1", "papaparse": "^5.4.1", - "pdf-parse": "^1.1.1", + "pathe": "^1.1.2", + "pdf2json": "^3.0.5", "pg": "^8.11.3", - "pgvector": "^0.1.5", + "pgvector": "^0.1.7", "portkey-ai": "^0.1.16", "rake-modified": "^1.0.8", - "replicate": "^0.21.1", - "string-strip-html": "^13.4.3", - "uuid": "^9.0.1", + "replicate": "^0.25.2", + "string-strip-html": "^13.4.6", "wink-nlp": "^1.14.3" }, "engines": { "node": ">=18.0.0" } }, + "node_modules/llamaindex/node_modules/@anthropic-ai/sdk": { + "version": "0.15.0", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.15.0.tgz", + "integrity": "sha512-QMNEFcwGGB64oEIL+U9b+mxSbat5TCdNxvQVV0qCNGQvg/nlnbOmq2/x/0mKhuKD0n5bioL75oCkTbQaAgyYtw==", + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "digest-fetch": "^1.3.0", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7", + "web-streams-polyfill": "^3.2.1" + } + }, + "node_modules/llamaindex/node_modules/@anthropic-ai/sdk/node_modules/node-fetch": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", + "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/llamaindex/node_modules/@aws-crypto/sha256-js": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", + "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", + "dependencies": { + "@aws-crypto/util": "^5.2.0", + "@aws-sdk/types": "^3.222.0", + "tslib": "^2.6.2" + }, + "engines": { + "node": ">=16.0.0" + } + }, + "node_modules/llamaindex/node_modules/@aws-crypto/util": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", + "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", + "dependencies": { + "@aws-sdk/types": "^3.222.0", + "@smithy/util-utf8": "^2.0.0", + "tslib": "^2.6.2" + } + }, + "node_modules/llamaindex/node_modules/@llamaindex/cloud": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/@llamaindex/cloud/-/cloud-0.0.4.tgz", + "integrity": "sha512-ufu8sASmttGQZBrDVt5XHF+Lf7ZFImMe/bCwqfoGiywJUchc88igxhP0xF5iUpthyQr2/0nAhH117owj5+GF3A==", + "dependencies": { + "@types/qs": "^6.9.12", + "form-data": "^4.0.0", + "js-base64": "^3.7.6", + "qs": "^6.11.2" + }, + "peerDependencies": { + "node-fetch": "^3.3.2" + }, + "peerDependenciesMeta": { + "node-fetch": { + "optional": true + } + } + }, + "node_modules/llamaindex/node_modules/@llamaindex/env": { + "version": "0.0.5", + "resolved": "https://registry.npmjs.org/@llamaindex/env/-/env-0.0.5.tgz", + "integrity": "sha512-+Eepyl2o0ykyo5alryUwuXriLtrtkTIUKlemK5kPbzZ/RV1VD6WMd8gykrAQZgYeRT3jK7sNm/7PVi/u+3zw3Q==", + "dependencies": { + "@types/lodash": "^4.14.202", + "@types/node": "^20.11.20", + "lodash": "^4.17.21" + }, + "peerDependencies": { + "@aws-crypto/sha256-js": "^5.2.0", + "pathe": "^1.1.2" + } + }, + "node_modules/llamaindex/node_modules/@llamaindex/env/node_modules/@types/node": { + "version": "20.12.2", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.2.tgz", + "integrity": "sha512-zQ0NYO87hyN6Xrclcqp7f8ZbXNbRfoGWNcMvHTPQp9UUrwI0mI7XBz+cu7/W6/VClYo2g63B0cjull/srU7LgQ==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/llamaindex/node_modules/@types/node": { + "version": "18.19.28", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.28.tgz", + "integrity": "sha512-J5cOGD9n4x3YGgVuaND6khm5x07MMdAKkRyXnjVR6KFhLMNh2yONGiP7Z+4+tBOt5mK+GvDTiacTOVGGpqiecw==", + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "node_modules/llamaindex/node_modules/js-base64": { + "version": "3.7.7", + "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-3.7.7.tgz", + "integrity": "sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==" + }, + "node_modules/llamaindex/node_modules/node-fetch": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", + "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", + "optional": true, + "peer": true, + "dependencies": { + "data-uri-to-buffer": "^4.0.0", + "fetch-blob": "^3.1.4", + "formdata-polyfill": "^4.0.10" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-fetch" + } + }, "node_modules/load-json-file": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-6.2.0.tgz", @@ -16283,7 +16438,8 @@ "version": "0.0.0", "resolved": "https://registry.npmjs.org/node-ensure/-/node-ensure-0.0.0.tgz", "integrity": "sha512-DRI60hzo2oKN1ma0ckc6nQWlHU69RH6xN0sjQTjMpChPfTYvKZdcQFfdYK2RWbJcKyUizSIy/l8OTGxMAM1QDw==", - "devOptional": true + "optional": true, + "peer": true }, "node_modules/node-fetch": { "version": "2.6.7", @@ -17825,7 +17981,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/pdf-parse/-/pdf-parse-1.1.1.tgz", "integrity": "sha512-v6ZJ/efsBpGrGGknjtq9J/oC8tZWq0KWL5vQrk2GlzLEQPUDB1ex+13Rmidl1neNN358Jn9EHZw5y07FFtaC7A==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "debug": "^3.1.0", "node-ensure": "^0.0.0" @@ -17838,7 +17995,8 @@ "version": "3.2.7", "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", - "devOptional": true, + "optional": true, + "peer": true, "dependencies": { "ms": "^2.1.1" } @@ -19031,15 +19189,57 @@ } }, "node_modules/replicate": { - "version": "0.21.1", - "resolved": "https://registry.npmjs.org/replicate/-/replicate-0.21.1.tgz", - "integrity": "sha512-ftR416+tuD55u6Rz0s5QsxoC2ZasslyFg9jxytirPhqFQwTQy9arU0vF29811t4iws8cMc+neL0IUzyq0pFlkQ==", - "dev": true, + "version": "0.25.2", + "resolved": "https://registry.npmjs.org/replicate/-/replicate-0.25.2.tgz", + "integrity": "sha512-c5otBJ5E66XLS0X196pBCsyy85b03ZBLeV/lbKfU8cqfkt3Qd6NGEiPwTtxtsQ4AznggMJNn2Qq68t/bV85M2w==", "engines": { "git": ">=2.11.0", "node": ">=18.0.0", "npm": ">=7.19.0", "yarn": ">=1.7.0" + }, + "optionalDependencies": { + "readable-stream": ">=4.0.0" + } + }, + "node_modules/replicate/node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "optional": true, + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } + }, + "node_modules/replicate/node_modules/readable-stream": { + "version": "4.5.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", + "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", + "optional": true, + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/require-directory": { @@ -21799,7 +21999,6 @@ "@pollyjs/core": "^6.0.6", "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", - "llamaindex": "^0.0.40", "ts-mocha": "^10.0.0" }, "engines": { @@ -22513,127 +22712,22 @@ "node": ">=14" } }, - "packages/instrumentation-llamaindex/node_modules/@anthropic-ai/sdk": { - "version": "0.13.1", - "dev": true, - "license": "MIT", + "packages/instrumentation-llamaindex/node_modules/@opentelemetry/instrumentation": { + "version": "0.49.1", + "license": "Apache-2.0", "dependencies": { - "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.4", - "abort-controller": "^3.0.0", - "agentkeepalive": "^4.2.1", - "digest-fetch": "^1.3.0", - "form-data-encoder": "1.7.2", - "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" - } - }, - "packages/instrumentation-llamaindex/node_modules/@aws-crypto/sha256-js": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", - "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", - "dev": true, - "dependencies": { - "@aws-crypto/util": "^5.2.0", - "@aws-sdk/types": "^3.222.0", - "tslib": "^2.6.2" - }, - "engines": { - "node": ">=16.0.0" - } - }, - "packages/instrumentation-llamaindex/node_modules/@aws-crypto/util": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", - "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", - "dev": true, - "dependencies": { - "@aws-sdk/types": "^3.222.0", - "@smithy/util-utf8": "^2.0.0", - "tslib": "^2.6.2" - } - }, - "packages/instrumentation-llamaindex/node_modules/@llamaindex/env": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@llamaindex/env/-/env-0.0.4.tgz", - "integrity": "sha512-tbdbpABVJiWBSvHF+4MdDfq+iuBO8OYESQs9u+rqO+zUJLRUvsjjd04YBBGjLyT/q0UmDGwlJntQteZmsSS9DQ==", - "dev": true, - "dependencies": { - "@types/lodash": "^4.14.202", - "@types/node": "^20.11.20", - "lodash": "^4.17.21" - }, - "peerDependencies": { - "@aws-crypto/sha256-js": "^5.2.0", - "pathe": "^1.1.2" - } - }, - "packages/instrumentation-llamaindex/node_modules/@llamaindex/env/node_modules/@types/node": { - "version": "20.11.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz", - "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==", - "dev": true, - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "packages/instrumentation-llamaindex/node_modules/@mistralai/mistralai": { - "version": "0.0.10", - "dev": true, - "license": "ISC", - "dependencies": { - "node-fetch": "^2.6.7" - } - }, - "packages/instrumentation-llamaindex/node_modules/@opentelemetry/instrumentation": { - "version": "0.49.1", - "license": "Apache-2.0", - "dependencies": { - "@opentelemetry/api-logs": "0.49.1", - "@types/shimmer": "^1.0.2", - "import-in-the-middle": "1.7.1", - "require-in-the-middle": "^7.1.1", - "semver": "^7.5.2", - "shimmer": "^1.2.1" - }, - "engines": { - "node": ">=14" - }, - "peerDependencies": { - "@opentelemetry/api": "^1.3.0" - } - }, - "packages/instrumentation-llamaindex/node_modules/@types/node": { - "version": "18.19.21", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "packages/instrumentation-llamaindex/node_modules/buffer": { - "version": "6.0.3", - "dev": true, - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "license": "MIT", - "optional": true, - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" + "@opentelemetry/api-logs": "0.49.1", + "@types/shimmer": "^1.0.2", + "import-in-the-middle": "1.7.1", + "require-in-the-middle": "^7.1.1", + "semver": "^7.5.2", + "shimmer": "^1.2.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.3.0" } }, "packages/instrumentation-llamaindex/node_modules/import-in-the-middle": { @@ -22646,81 +22740,6 @@ "module-details-from-path": "^1.0.3" } }, - "packages/instrumentation-llamaindex/node_modules/llamaindex": { - "version": "0.1.19", - "dev": true, - "license": "MIT", - "dependencies": { - "@anthropic-ai/sdk": "^0.13.0", - "@aws-crypto/sha256-js": "^5.2.0", - "@datastax/astra-db-ts": "^0.1.4", - "@llamaindex/cloud": "^0.0.1", - "@llamaindex/env": "0.0.4", - "@mistralai/mistralai": "^0.0.10", - "@notionhq/client": "^2.2.14", - "@pinecone-database/pinecone": "^2.0.1", - "@qdrant/js-client-rest": "^1.7.0", - "@types/lodash": "^4.14.202", - "@types/node": "^18.19.14", - "@types/papaparse": "^5.3.14", - "@types/pg": "^8.11.0", - "@xenova/transformers": "^2.15.0", - "assemblyai": "^4.2.2", - "chromadb": "~1.7.3", - "cohere-ai": "^7.7.5", - "file-type": "^18.7.0", - "js-tiktoken": "^1.0.10", - "lodash": "^4.17.21", - "mammoth": "^1.6.0", - "md-utils-ts": "^2.0.0", - "mongodb": "^6.3.0", - "notion-md-crawler": "^0.0.2", - "openai": "^4.26.1", - "papaparse": "^5.4.1", - "pathe": "^1.1.2", - "pdf2json": "^3.0.5", - "pg": "^8.11.3", - "pgvector": "^0.1.7", - "portkey-ai": "^0.1.16", - "rake-modified": "^1.0.8", - "replicate": "^0.25.2", - "string-strip-html": "^13.4.6", - "wink-nlp": "^1.14.3" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "packages/instrumentation-llamaindex/node_modules/readable-stream": { - "version": "4.5.2", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "packages/instrumentation-llamaindex/node_modules/replicate": { - "version": "0.25.2", - "dev": true, - "license": "Apache-2.0", - "engines": { - "git": ">=2.11.0", - "node": ">=18.0.0", - "npm": ">=7.19.0", - "yarn": ">=1.7.0" - }, - "optionalDependencies": { - "readable-stream": ">=4.0.0" - } - }, "packages/instrumentation-openai": { "name": "@traceloop/instrumentation-openai", "version": "0.5.28", @@ -22886,25 +22905,12 @@ "node": ">=14" } }, - "packages/sample-app/node_modules/@anthropic-ai/sdk": { - "version": "0.13.1", - "license": "MIT", - "dependencies": { - "@types/node": "^18.11.18", - "@types/node-fetch": "^2.6.4", - "abort-controller": "^3.0.0", - "agentkeepalive": "^4.2.1", - "digest-fetch": "^1.3.0", - "form-data-encoder": "1.7.2", - "formdata-node": "^4.3.2", - "node-fetch": "^2.6.7", - "web-streams-polyfill": "^3.2.1" - } - }, "packages/sample-app/node_modules/@aws-crypto/sha256-js": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-5.2.0.tgz", "integrity": "sha512-FFQQyu7edu4ufvIZ+OadFpHHOt+eSTBaYaki44c+akjg7qZg9oOQeLlk77F6tSYqjDAFClrHJk9tMf0HdVyOvA==", + "optional": true, + "peer": true, "dependencies": { "@aws-crypto/util": "^5.2.0", "@aws-sdk/types": "^3.222.0", @@ -22918,6 +22924,8 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-5.2.0.tgz", "integrity": "sha512-4RkU9EsI6ZpBve5fseQlGNUWKMa1RLPQ1dnjnQoe07ldfIzcsGb5hC5W0Dm7u423KWzawlrpbjXBrXCEv9zazQ==", + "optional": true, + "peer": true, "dependencies": { "@aws-sdk/types": "^3.222.0", "@smithy/util-utf8": "^2.0.0", @@ -23280,140 +23288,6 @@ } } }, - "packages/sample-app/node_modules/@llamaindex/env": { - "version": "0.0.4", - "resolved": "https://registry.npmjs.org/@llamaindex/env/-/env-0.0.4.tgz", - "integrity": "sha512-tbdbpABVJiWBSvHF+4MdDfq+iuBO8OYESQs9u+rqO+zUJLRUvsjjd04YBBGjLyT/q0UmDGwlJntQteZmsSS9DQ==", - "dependencies": { - "@types/lodash": "^4.14.202", - "@types/node": "^20.11.20", - "lodash": "^4.17.21" - }, - "peerDependencies": { - "@aws-crypto/sha256-js": "^5.2.0", - "pathe": "^1.1.2" - } - }, - "packages/sample-app/node_modules/@llamaindex/env/node_modules/@types/node": { - "version": "20.11.24", - "resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.24.tgz", - "integrity": "sha512-Kza43ewS3xoLgCEpQrsT+xRo/EJej1y0kVYGiLFE1NEODXGzTfwiC6tXTLMQskn1X4/Rjlh0MQUvx9W+L9long==", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "packages/sample-app/node_modules/@mistralai/mistralai": { - "version": "0.0.10", - "license": "ISC", - "dependencies": { - "node-fetch": "^2.6.7" - } - }, - "packages/sample-app/node_modules/@types/node": { - "version": "18.19.21", - "license": "MIT", - "dependencies": { - "undici-types": "~5.26.4" - } - }, - "packages/sample-app/node_modules/buffer": { - "version": "6.0.3", - "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", - "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/feross" - }, - { - "type": "patreon", - "url": "https://www.patreon.com/feross" - }, - { - "type": "consulting", - "url": "https://feross.org/support" - } - ], - "optional": true, - "dependencies": { - "base64-js": "^1.3.1", - "ieee754": "^1.2.1" - } - }, - "packages/sample-app/node_modules/llamaindex": { - "version": "0.1.19", - "license": "MIT", - "dependencies": { - "@anthropic-ai/sdk": "^0.13.0", - "@aws-crypto/sha256-js": "^5.2.0", - "@datastax/astra-db-ts": "^0.1.4", - "@llamaindex/cloud": "^0.0.1", - "@llamaindex/env": "0.0.4", - "@mistralai/mistralai": "^0.0.10", - "@notionhq/client": "^2.2.14", - "@pinecone-database/pinecone": "^2.0.1", - "@qdrant/js-client-rest": "^1.7.0", - "@types/lodash": "^4.14.202", - "@types/node": "^18.19.14", - "@types/papaparse": "^5.3.14", - "@types/pg": "^8.11.0", - "@xenova/transformers": "^2.15.0", - "assemblyai": "^4.2.2", - "chromadb": "~1.7.3", - "cohere-ai": "^7.7.5", - "file-type": "^18.7.0", - "js-tiktoken": "^1.0.10", - "lodash": "^4.17.21", - "mammoth": "^1.6.0", - "md-utils-ts": "^2.0.0", - "mongodb": "^6.3.0", - "notion-md-crawler": "^0.0.2", - "openai": "^4.26.1", - "papaparse": "^5.4.1", - "pathe": "^1.1.2", - "pdf2json": "^3.0.5", - "pg": "^8.11.3", - "pgvector": "^0.1.7", - "portkey-ai": "^0.1.16", - "rake-modified": "^1.0.8", - "replicate": "^0.25.2", - "string-strip-html": "^13.4.6", - "wink-nlp": "^1.14.3" - }, - "engines": { - "node": ">=18.0.0" - } - }, - "packages/sample-app/node_modules/llamaindex/node_modules/replicate": { - "version": "0.25.2", - "resolved": "https://registry.npmjs.org/replicate/-/replicate-0.25.2.tgz", - "integrity": "sha512-c5otBJ5E66XLS0X196pBCsyy85b03ZBLeV/lbKfU8cqfkt3Qd6NGEiPwTtxtsQ4AznggMJNn2Qq68t/bV85M2w==", - "engines": { - "git": ">=2.11.0", - "node": ">=18.0.0", - "npm": ">=7.19.0", - "yarn": ">=1.7.0" - }, - "optionalDependencies": { - "readable-stream": ">=4.0.0" - } - }, - "packages/sample-app/node_modules/readable-stream": { - "version": "4.5.2", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.5.2.tgz", - "integrity": "sha512-yjavECdqeZ3GLXNgRXgeQEdz9fvDDkNKyHnbHRFtOr7/LcfgBcmct7t/ET+HaCTqfh06OzoAxrkN/IfjJBVe+g==", - "optional": true, - "dependencies": { - "abort-controller": "^3.0.0", - "buffer": "^6.0.3", - "events": "^3.3.0", - "process": "^0.11.10", - "string_decoder": "^1.3.0" - }, - "engines": { - "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, "packages/sample-app/node_modules/replicate": { "version": "0.18.1", "resolved": "https://registry.npmjs.org/replicate/-/replicate-0.18.1.tgz", @@ -23452,13 +23326,21 @@ "uuid": "^9.0.1" }, "devDependencies": { + "@aws-sdk/client-bedrock-runtime": "^3.499.0", + "@azure/openai": "^1.0.0-beta.11", + "@google-cloud/aiplatform": "^3.10.0", + "@google-cloud/vertexai": "^0.2.1", + "@pinecone-database/pinecone": "^2.0.1", "@pollyjs/adapter-node-http": "^6.0.6", "@pollyjs/core": "^6.0.6", "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", "@types/node": "^20.9.0", "@types/uuid": "^9.0.7", + "cohere-ai": "^7.7.5", "esbuild": "^0.20.1", + "langchain": "^0.1.7", + "llamaindex": "^0.1.16", "openai": "^4.12.4", "ts-mocha": "^10.0.0" }, diff --git a/packages/ai-semantic-conventions/src/index.ts b/packages/ai-semantic-conventions/src/index.ts index eee475c1..0ee45407 100644 --- a/packages/ai-semantic-conventions/src/index.ts +++ b/packages/ai-semantic-conventions/src/index.ts @@ -17,11 +17,6 @@ import { createContextKey } from "@opentelemetry/api"; export * from "./SemanticAttributes"; -export interface AIInstrumentation { - setConfig: (config: { traceContent: boolean }) => void; - manuallyInstrument: (module: any) => void; -} - export const CONTEXT_KEY_ALLOW_TRACE_CONTENT = createContextKey( "allow_trace_content", ); diff --git a/packages/instrumentation-azure/package.json b/packages/instrumentation-azure/package.json index c9d32a01..226aa7d8 100644 --- a/packages/instrumentation-azure/package.json +++ b/packages/instrumentation-azure/package.json @@ -48,7 +48,6 @@ "@pollyjs/core": "^6.0.6", "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", - "llamaindex": "^0.0.40", "ts-mocha": "^10.0.0" }, "homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/instrumentation-azure" diff --git a/packages/traceloop-sdk/package.json b/packages/traceloop-sdk/package.json index 09a68e58..1e481edd 100644 --- a/packages/traceloop-sdk/package.json +++ b/packages/traceloop-sdk/package.json @@ -64,7 +64,15 @@ "@types/node": "^20.9.0", "@types/uuid": "^9.0.7", "esbuild": "^0.20.1", - "openai": "^4.12.4", - "ts-mocha": "^10.0.0" + "ts-mocha": "^10.0.0", + "@aws-sdk/client-bedrock-runtime": "^3.499.0", + "@azure/openai": "^1.0.0-beta.11", + "@google-cloud/aiplatform": "^3.10.0", + "@google-cloud/vertexai": "^0.2.1", + "@pinecone-database/pinecone": "^2.0.1", + "cohere-ai": "^7.7.5", + "langchain": "^0.1.7", + "llamaindex": "^0.1.16", + "openai": "^4.12.4" } } diff --git a/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts b/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts index afdae6c5..582eea9d 100644 --- a/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts +++ b/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts @@ -1,5 +1,17 @@ import { SpanExporter } from "@opentelemetry/sdk-trace-base"; +import type * as openai from "openai"; +import type * as azure from "@azure/openai"; +import type * as cohere from "cohere-ai"; +import type * as bedrock from "@aws-sdk/client-bedrock-runtime"; +import type * as aiplatform from "@google-cloud/aiplatform"; +import type * as vertexAI from "@google-cloud/vertexai"; +import type * as pinecone from "@pinecone-database/pinecone"; +import type * as ChainsModule from "langchain/chains"; +import type * as AgentsModule from "langchain/agents"; +import type * as ToolsModule from "langchain/tools"; +import type * as llamaindex from "llamaindex"; + /** * Options for initializing the Traceloop SDK. */ @@ -48,22 +60,22 @@ export interface InitializeOptions { /** * Explicitly specify modules to instrument. Optional. -xwxw * This is a workaround specific to Next.js, see https://www.traceloop.com/docs/openllmetry/getting-started-nextjs + * This is a workaround specific to Next.js, see https://www.traceloop.com/docs/openllmetry/getting-started-nextjs */ instrumentModules?: { - openAI?: any; + openAI?: typeof openai.OpenAI; + azureOpenAI?: typeof azure; + cohere?: typeof cohere; + bedrock?: typeof bedrock; + google_vertexai?: typeof vertexAI; + google_aiplatform?: typeof aiplatform; + pinecone?: typeof pinecone; langchain?: { - chainsModule?: any; - agentsModule?: any; - toolsModule?: any; + chainsModule?: typeof ChainsModule; + agentsModule?: typeof AgentsModule; + toolsModule?: typeof ToolsModule; }; - llamaIndex?: any; - pinecone?: any; - google_vertexai?: any; - google_aiplatform?: any; - bedrock?: any; - azureOpenAI?: any; - cohere?: any; + llamaIndex?: typeof llamaindex; }; /** diff --git a/packages/traceloop-sdk/src/lib/tracing/index.ts b/packages/traceloop-sdk/src/lib/tracing/index.ts index deb312c0..09750316 100644 --- a/packages/traceloop-sdk/src/lib/tracing/index.ts +++ b/packages/traceloop-sdk/src/lib/tracing/index.ts @@ -14,203 +14,124 @@ import { ASSOCATION_PROPERTIES_KEY, WORKFLOW_NAME_KEY } from "./tracing"; import { Telemetry } from "../telemetry/telemetry"; import { _configuration } from "../configuration"; import { - AIInstrumentation, CONTEXT_KEY_ALLOW_TRACE_CONTENT, SpanAttributes, } from "@traceloop/ai-semantic-conventions"; +import { OpenAIInstrumentation } from "@traceloop/instrumentation-openai"; +import { AzureOpenAIInstrumentation } from "@traceloop/instrumentation-azure"; +import { LlamaIndexInstrumentation } from "@traceloop/instrumentation-llamaindex"; +import { + AIPlatformInstrumentation, + VertexAIInstrumentation, +} from "@traceloop/instrumentation-vertexai"; +import { BedrockInstrumentation } from "@traceloop/instrumentation-bedrock"; +import { CohereInstrumentation } from "@traceloop/instrumentation-cohere"; +import { PineconeInstrumentation } from "@traceloop/instrumentation-pinecone"; +import { LangChainInstrumentation } from "@traceloop/instrumentation-langchain"; let _sdk: NodeSDK; let _spanProcessor: SimpleSpanProcessor | BatchSpanProcessor; -let openAIInstrumentation: AIInstrumentation | undefined; -let azureOpenAIInstrumentation: AIInstrumentation | undefined; -let llamaIndexInstrumentation: AIInstrumentation | undefined; -let vertexaiInstrumentation: AIInstrumentation | undefined; -let aiplatformInstrumentation: AIInstrumentation | undefined; -let bedrockInstrumentation: AIInstrumentation | undefined; -let cohereInstrumentation: AIInstrumentation | undefined; +let openAIInstrumentation: OpenAIInstrumentation | undefined; +let azureOpenAIInstrumentation: AzureOpenAIInstrumentation | undefined; +let cohereInstrumentation: CohereInstrumentation | undefined; +let vertexaiInstrumentation: VertexAIInstrumentation | undefined; +let aiplatformInstrumentation: AIPlatformInstrumentation | undefined; +let bedrockInstrumentation: BedrockInstrumentation | undefined; +let langchainInstrumentation: LangChainInstrumentation | undefined; +let llamaIndexInstrumentation: LlamaIndexInstrumentation | undefined; +let pineconeInstrumentation: PineconeInstrumentation | undefined; const instrumentations: Instrumentation[] = []; export const initInstrumentations = () => { - try { - const { - OpenAIInstrumentation, - } = require("@traceloop/instrumentation-openai"); - const instrumentation = new OpenAIInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - openAIInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } - try { - const { - AzureOpenAIInstrumentation, - } = require("@traceloop/instrumentation-azure"); - const instrumentation = new AzureOpenAIInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - azureOpenAIInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } - try { - const { - LlamaIndexInstrumentation, - } = require("@traceloop/instrumentation-llamaindex"); - const instrumentation = new LlamaIndexInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - llamaIndexInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } - try { - const { - PineconeInstrumentation, - } = require("@traceloop/instrumentation-pinecone"); - const instrumentation = new PineconeInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - } catch (e) { - /* empty */ - } - const { - VertexAIInstrumentation, - } = require("@traceloop/instrumentation-vertexai"); - const instrumentation = new VertexAIInstrumentation(); - instrumentations.push(instrumentation); - vertexaiInstrumentation = instrumentation; - - try { - const { - AIPlatformInstrumentation, - } = require("@traceloop/instrumentation-vertexai"); - const instrumentation = new AIPlatformInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - aiplatformInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } + openAIInstrumentation = new OpenAIInstrumentation(); + instrumentations.push(openAIInstrumentation); - try { - const { - LangChainInstrumentation, - } = require("@traceloop/instrumentation-langchain"); - const instrumentation = new LangChainInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - } catch (e) { - /* empty */ - } + azureOpenAIInstrumentation = new AzureOpenAIInstrumentation(); + instrumentations.push(azureOpenAIInstrumentation); - try { - const { - BedrockInstrumentation, - } = require("@traceloop/instrumentation-bedrock"); - const instrumentation = new BedrockInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - bedrockInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } + cohereInstrumentation = new CohereInstrumentation(); + instrumentations.push(cohereInstrumentation); - try { - const { - CohereInstrumentation, - } = require("@traceloop/instrumentation-cohere"); - const instrumentation = new CohereInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - cohereInstrumentation = instrumentation; - } catch (e) { - /* empty */ - } + vertexaiInstrumentation = new VertexAIInstrumentation(); + instrumentations.push(vertexaiInstrumentation); + + aiplatformInstrumentation = new AIPlatformInstrumentation(); + instrumentations.push(aiplatformInstrumentation); + + bedrockInstrumentation = new BedrockInstrumentation(); + instrumentations.push(bedrockInstrumentation); + + pineconeInstrumentation = new PineconeInstrumentation(); + instrumentations.push(pineconeInstrumentation); + + langchainInstrumentation = new LangChainInstrumentation(); + instrumentations.push(langchainInstrumentation); + + llamaIndexInstrumentation = new LlamaIndexInstrumentation(); + instrumentations.push(llamaIndexInstrumentation); }; export const manuallyInitInstrumentations = ( instrumentModules: InitializeOptions["instrumentModules"], ) => { if (instrumentModules?.openAI) { - const { - OpenAIInstrumentation, - } = require("@traceloop/instrumentation-openai"); - const instrumentation = new OpenAIInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - openAIInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.openAI); + openAIInstrumentation = new OpenAIInstrumentation(); + instrumentations.push(openAIInstrumentation); + openAIInstrumentation.manuallyInstrument(instrumentModules.openAI); } - if (instrumentModules?.llamaIndex) { - const { - LlamaIndexInstrumentation, - } = require("@traceloop/instrumentation-llamaindex"); - const instrumentation = new LlamaIndexInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - llamaIndexInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.llamaIndex); - } - - if (instrumentModules?.langchain) { - const { - LangChainInstrumentation, - } = require("@traceloop/instrumentation-langchain"); - const instrumentation = new LangChainInstrumentation(); + if (instrumentModules?.azureOpenAI) { + const instrumentation = new AzureOpenAIInstrumentation(); instrumentations.push(instrumentation as Instrumentation); - instrumentation.manuallyInstrument(instrumentModules.langchain); + azureOpenAIInstrumentation = instrumentation; + instrumentation.manuallyInstrument(instrumentModules.azureOpenAI); } - if (instrumentModules?.pinecone) { - const { - PineconeInstrumentation, - } = require("@traceloop/instrumentation-pinecone"); - const instrumentation = new PineconeInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - instrumentation.manuallyInstrument(instrumentModules.pinecone); + if (instrumentModules?.cohere) { + cohereInstrumentation = new CohereInstrumentation(); + instrumentations.push(cohereInstrumentation); + cohereInstrumentation.manuallyInstrument(instrumentModules.cohere); } if (instrumentModules?.google_vertexai) { - const { - VertexAIInstrumentation, - } = require("@traceloop/instrumentation-vertexai"); - const instrumentation = new VertexAIInstrumentation(); - instrumentations.push(instrumentation); - vertexaiInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.google_vertexai); + vertexaiInstrumentation = new VertexAIInstrumentation(); + instrumentations.push(vertexaiInstrumentation); + vertexaiInstrumentation.manuallyInstrument( + instrumentModules.google_vertexai, + ); } if (instrumentModules?.google_aiplatform) { - const { - AIPlatformInstrumentation, - } = require("@traceloop/instrumentation-vertexai"); - const instrumentation = new AIPlatformInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - aiplatformInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.google_aiplatform); + aiplatformInstrumentation = new AIPlatformInstrumentation(); + instrumentations.push(aiplatformInstrumentation); + aiplatformInstrumentation.manuallyInstrument( + instrumentModules.google_aiplatform, + ); } if (instrumentModules?.bedrock) { - const { - BedrockInstrumentation, - } = require("@traceloop/instrumentation-bedrock"); - const instrumentation = new BedrockInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - bedrockInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.bedrock); + bedrockInstrumentation = new BedrockInstrumentation(); + instrumentations.push(bedrockInstrumentation); + bedrockInstrumentation.manuallyInstrument(instrumentModules.bedrock); } - if (instrumentModules?.azureOpenAI) { - const { - AzureOpenAIInstrumentation, - } = require("@traceloop/instrumentation-azure"); - const instrumentation = new AzureOpenAIInstrumentation(); + if (instrumentModules?.pinecone) { + const instrumentation = new PineconeInstrumentation(); instrumentations.push(instrumentation as Instrumentation); - azureOpenAIInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.azureOpenAI); + instrumentation.manuallyInstrument(instrumentModules.pinecone); } - if (instrumentModules?.cohere) { - const { - CohereInstrumentation, - } = require("@traceloop/instrumentation-cohere"); - const instrumentation = new CohereInstrumentation(); - instrumentations.push(instrumentation as Instrumentation); - cohereInstrumentation = instrumentation; - instrumentation.manuallyInstrument(instrumentModules.cohere); + if (instrumentModules?.langchain) { + langchainInstrumentation = new LangChainInstrumentation(); + instrumentations.push(langchainInstrumentation); + langchainInstrumentation.manuallyInstrument(instrumentModules.langchain); + } + + if (instrumentModules?.llamaIndex) { + llamaIndexInstrumentation = new LlamaIndexInstrumentation(); + instrumentations.push(llamaIndexInstrumentation); + llamaIndexInstrumentation.manuallyInstrument(instrumentModules.llamaIndex); } }; From 2ef0c13f16b050d6f73ea9a5952abd0bbfe8a284 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Wed, 3 Apr 2024 22:37:13 +0200 Subject: [PATCH 2/3] fix(openai): enrich token metrics on streaming requests (#183) --- package-lock.json | 8 ++- packages/instrumentation-openai/package.json | 3 +- .../src/instrumentation.ts | 64 +++++++++++++++++++ packages/instrumentation-openai/src/types.ts | 6 ++ .../test/instrumentation.test.ts | 46 ++++++++++++- .../src/lib/configuration/index.ts | 4 ++ .../initialize-options.interface.ts | 6 ++ .../traceloop-sdk/src/lib/tracing/index.ts | 5 +- 8 files changed, 138 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 973c4841..260d9059 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20732,6 +20732,11 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/tiktoken": { + "version": "1.0.13", + "resolved": "https://registry.npmjs.org/tiktoken/-/tiktoken-1.0.13.tgz", + "integrity": "sha512-JaL9ZnvTbGFMDIBeGdVkLt4qWTeCPw+n7Ock+wceAGRenuHA6nOOvMJFliNDyXsjg2osGKJWsXtO2xc74VxyDw==" + }, "node_modules/tiny-invariant": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.3.3.tgz", @@ -22748,7 +22753,8 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.27", + "tiktoken": "^1.0.13" }, "devDependencies": { "@pollyjs/adapter-node-http": "^6.0.6", diff --git a/packages/instrumentation-openai/package.json b/packages/instrumentation-openai/package.json index acd9b22d..9a97622e 100644 --- a/packages/instrumentation-openai/package.json +++ b/packages/instrumentation-openai/package.json @@ -39,7 +39,8 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.27", + "tiktoken": "^1.0.13" }, "devDependencies": { "@pollyjs/adapter-node-http": "^6.0.6", diff --git a/packages/instrumentation-openai/src/instrumentation.ts b/packages/instrumentation-openai/src/instrumentation.ts index 11e86935..e8d99d51 100644 --- a/packages/instrumentation-openai/src/instrumentation.ts +++ b/packages/instrumentation-openai/src/instrumentation.ts @@ -45,6 +45,7 @@ import type { } from "openai/resources"; import type { Stream } from "openai/streaming"; import { version } from "../package.json"; +import { encoding_for_model, TiktokenModel, Tiktoken } from "tiktoken"; export class OpenAIInstrumentation extends InstrumentationBase { protected declare _config: OpenAIInstrumentationConfig; @@ -198,6 +199,7 @@ export class OpenAIInstrumentation extends InstrumentationBase { plugin._streamingWrapPromise({ span, type, + params: args[0] as any, promise: execPromise, }), ); @@ -296,15 +298,18 @@ export class OpenAIInstrumentation extends InstrumentationBase { private async *_streamingWrapPromise({ span, type, + params, promise, }: | { span: Span; type: "chat"; + params: ChatCompletionCreateParamsStreaming; promise: Promise>; } | { span: Span; + params: CompletionCreateParamsStreaming; type: "completion"; promise: Promise>; }) { @@ -356,6 +361,29 @@ export class OpenAIInstrumentation extends InstrumentationBase { this._addLogProbsEvent(span, result.choices[0].logprobs); } + if (this._config.enrichTokens) { + let promptTokens = 0; + for (const message of params.messages) { + promptTokens += + this.tokenCountFromString( + message.content as string, + result.model, + ) ?? 0; + } + + const completionTokens = this.tokenCountFromString( + result.choices[0].message.content ?? "", + result.model, + ); + if (completionTokens) { + result.usage = { + prompt_tokens: promptTokens, + completion_tokens: completionTokens, + total_tokens: promptTokens + completionTokens, + }; + } + } + this._endSpan({ span, type, result }); } else { const result: Completion = { @@ -394,6 +422,23 @@ export class OpenAIInstrumentation extends InstrumentationBase { this._addLogProbsEvent(span, result.choices[0].logprobs); } + if (this._config.enrichTokens) { + const promptTokens = + this.tokenCountFromString(params.prompt as string, result.model) ?? 0; + + const completionTokens = this.tokenCountFromString( + result.choices[0].text ?? "", + result.model, + ); + if (completionTokens) { + result.usage = { + prompt_tokens: promptTokens, + completion_tokens: completionTokens, + total_tokens: promptTokens + completionTokens, + }; + } + } + this._endSpan({ span, type, result }); } } @@ -588,4 +633,23 @@ export class OpenAIInstrumentation extends InstrumentationBase { span.addEvent("logprobs", { logprobs: JSON.stringify(result) }); } + + private _encodingCache = new Map(); + + private tokenCountFromString(text: string, model: string) { + if (!this._encodingCache.has(model)) { + try { + const encoding = encoding_for_model(model as TiktokenModel); + this._encodingCache.set(model, encoding); + } catch (e) { + this._diag.warn( + `Failed to get tiktoken encoding for model_name: ${model}, error: ${e}`, + ); + return; + } + } + + const encoding = this._encodingCache.get(model); + return encoding!.encode(text).length; + } } diff --git a/packages/instrumentation-openai/src/types.ts b/packages/instrumentation-openai/src/types.ts index c441d1c4..fa5ae747 100644 --- a/packages/instrumentation-openai/src/types.ts +++ b/packages/instrumentation-openai/src/types.ts @@ -6,4 +6,10 @@ export interface OpenAIInstrumentationConfig extends InstrumentationConfig { * @default true */ traceContent?: boolean; + + /** + * Whether to enrich token information if missing from the trace. + * @default false + */ + enrichTokens?: boolean; } diff --git a/packages/instrumentation-openai/test/instrumentation.test.ts b/packages/instrumentation-openai/test/instrumentation.test.ts index 97e565a6..5d6251f1 100644 --- a/packages/instrumentation-openai/test/instrumentation.test.ts +++ b/packages/instrumentation-openai/test/instrumentation.test.ts @@ -58,7 +58,7 @@ describe("Test OpenAI instrumentation", async function () { process.env.OPENAI_API_KEY = "test"; } provider.addSpanProcessor(new SimpleSpanProcessor(memoryExporter)); - instrumentation = new OpenAIInstrumentation(); + instrumentation = new OpenAIInstrumentation({ enrichTokens: true }); instrumentation.setTracerProvider(provider); const openAIModule: typeof OpenAIModule = await import("openai"); @@ -103,6 +103,18 @@ describe("Test OpenAI instrumentation", async function () { completionSpan.attributes[`${SpanAttributes.LLM_PROMPTS}.0.content`], "Tell me a joke about OpenTelemetry", ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.equal( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + "15", + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); }); it("should set attributes in span for streaming chat", async () => { @@ -136,6 +148,18 @@ describe("Test OpenAI instrumentation", async function () { completionSpan.attributes[`${SpanAttributes.LLM_COMPLETIONS}.0.content`], result, ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.equal( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + "8", + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); }); it("should set attributes in span for streaming chat with new API", async () => { @@ -169,6 +193,26 @@ describe("Test OpenAI instrumentation", async function () { completionSpan.attributes[`${SpanAttributes.LLM_COMPLETIONS}.0.content`], result, ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + ); + assert.ok( + completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ], + ); + assert.ok( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_TOTAL_TOKENS}`], + ); + assert.equal( + completionSpan.attributes[`${SpanAttributes.LLM_USAGE_PROMPT_TOKENS}`], + "8", + ); + assert.ok( + +completionSpan.attributes[ + `${SpanAttributes.LLM_USAGE_COMPLETION_TOKENS}` + ]! > 0, + ); }); it("should set attributes in span for completion", async () => { diff --git a/packages/traceloop-sdk/src/lib/configuration/index.ts b/packages/traceloop-sdk/src/lib/configuration/index.ts index f3227cb6..64c749a1 100644 --- a/packages/traceloop-sdk/src/lib/configuration/index.ts +++ b/packages/traceloop-sdk/src/lib/configuration/index.ts @@ -54,6 +54,10 @@ export const initialize = (options: InitializeOptions) => { options.traceloopSyncDevPollingInterval = Number(process.env.TRACELOOP_SYNC_DEV_POLLING_INTERVAL) || 5; } + + if (options.shouldEnrichMetrics === undefined) { + options.shouldEnrichMetrics = true; + } } validateConfiguration(options); diff --git a/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts b/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts index 582eea9d..f4a0cb77 100644 --- a/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts +++ b/packages/traceloop-sdk/src/lib/interfaces/initialize-options.interface.ts @@ -46,6 +46,12 @@ export interface InitializeOptions { */ logLevel?: "debug" | "info" | "warn" | "error"; + /** + * Whether to enrich metrics with additional data like OpenAI token usage for streaming requests. Optional. + * Defaults to true. + */ + shouldEnrichMetrics?: boolean; + /** * Whether to log prompts, completions and embeddings on traces. Optional. * Defaults to true. diff --git a/packages/traceloop-sdk/src/lib/tracing/index.ts b/packages/traceloop-sdk/src/lib/tracing/index.ts index 09750316..88440f16 100644 --- a/packages/traceloop-sdk/src/lib/tracing/index.ts +++ b/packages/traceloop-sdk/src/lib/tracing/index.ts @@ -76,7 +76,9 @@ export const manuallyInitInstrumentations = ( instrumentModules: InitializeOptions["instrumentModules"], ) => { if (instrumentModules?.openAI) { - openAIInstrumentation = new OpenAIInstrumentation(); + openAIInstrumentation = new OpenAIInstrumentation({ + enrichTokens: _configuration?.shouldEnrichMetrics, + }); instrumentations.push(openAIInstrumentation); openAIInstrumentation.manuallyInstrument(instrumentModules.openAI); } @@ -149,6 +151,7 @@ export const startTracing = (options: InitializeOptions) => { if (!shouldSendTraces()) { openAIInstrumentation?.setConfig({ traceContent: false, + enrichTokens: _configuration?.shouldEnrichMetrics, }); azureOpenAIInstrumentation?.setConfig({ traceContent: false, From ac68a9877fd6059cd485143b105883b689fa9608 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 3 Apr 2024 20:39:48 +0000 Subject: [PATCH 3/3] v0.5.29 --- CHANGELOG.md | 7 +++ lerna.json | 2 +- package-lock.json | 54 +++++++++---------- packages/ai-semantic-conventions/CHANGELOG.md | 6 +++ packages/ai-semantic-conventions/package.json | 2 +- packages/instrumentation-azure/CHANGELOG.md | 6 +++ packages/instrumentation-azure/package.json | 4 +- packages/instrumentation-bedrock/CHANGELOG.md | 4 ++ packages/instrumentation-bedrock/package.json | 4 +- packages/instrumentation-cohere/CHANGELOG.md | 4 ++ packages/instrumentation-cohere/package.json | 4 +- .../instrumentation-langchain/CHANGELOG.md | 4 ++ .../instrumentation-langchain/package.json | 4 +- .../instrumentation-llamaindex/CHANGELOG.md | 4 ++ .../instrumentation-llamaindex/package.json | 4 +- packages/instrumentation-openai/CHANGELOG.md | 6 +++ packages/instrumentation-openai/package.json | 4 +- .../instrumentation-pinecone/CHANGELOG.md | 4 ++ .../instrumentation-pinecone/package.json | 4 +- .../instrumentation-vertexai/CHANGELOG.md | 4 ++ .../instrumentation-vertexai/package.json | 4 +- packages/traceloop-sdk/CHANGELOG.md | 7 +++ packages/traceloop-sdk/package.json | 36 ++++++------- 23 files changed, 119 insertions(+), 63 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ec3fd36..7fa14471 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **openai:** enrich token metrics on streaming requests ([#183](https://github.com/traceloop/openllmetry-js/issues/183)) ([2ef0c13](https://github.com/traceloop/openllmetry-js/commit/2ef0c13f16b050d6f73ea9a5952abd0bbfe8a284)) +- **sdk:** clean and typed instrumentations ([#182](https://github.com/traceloop/openllmetry-js/issues/182)) ([83737ee](https://github.com/traceloop/openllmetry-js/commit/83737ee5291a68c59f255ab91216048824d7406b)) + ## [0.5.28](https://github.com/traceloop/openllmetry-js/compare/v0.5.27...v0.5.28) (2024-04-02) ### Bug Fixes diff --git a/lerna.json b/lerna.json index 12e9b19a..4da0e867 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,6 @@ { "$schema": "node_modules/lerna/schemas/lerna-schema.json", - "version": "0.5.28", + "version": "0.5.29", "packages": ["packages/*"], "useNx": true } diff --git a/package-lock.json b/package-lock.json index 260d9059..1750503d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21979,7 +21979,7 @@ }, "packages/ai-semantic-conventions": { "name": "@traceloop/ai-semantic-conventions", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/api": "^1.7.0" @@ -21990,13 +21990,13 @@ }, "packages/instrumentation-azure": { "name": "@traceloop/instrumentation-azure", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@azure/openai": "^1.0.0-beta.10", @@ -22040,13 +22040,13 @@ }, "packages/instrumentation-bedrock": { "name": "@traceloop/instrumentation-bedrock", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@aws-sdk/client-bedrock-runtime": "^3.499.0", @@ -22088,13 +22088,13 @@ }, "packages/instrumentation-cohere": { "name": "@traceloop/instrumentation-cohere", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.44.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@pollyjs/adapter-node-http": "^6.0.6", @@ -22108,13 +22108,13 @@ }, "packages/instrumentation-langchain": { "name": "@traceloop/instrumentation-langchain", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@langchain/community": "^0.0.34", @@ -22696,13 +22696,13 @@ }, "packages/instrumentation-llamaindex": { "name": "@traceloop/instrumentation-llamaindex", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", "lodash": "^4.17.21" }, "devDependencies": { @@ -22747,13 +22747,13 @@ }, "packages/instrumentation-openai": { "name": "@traceloop/instrumentation-openai", - "version": "0.5.28", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", "tiktoken": "^1.0.13" }, "devDependencies": { @@ -22799,13 +22799,13 @@ }, "packages/instrumentation-pinecone": { "name": "@traceloop/instrumentation-pinecone", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@pinecone-database/pinecone": "^2.0.1", @@ -22847,13 +22847,13 @@ }, "packages/instrumentation-vertexai": { "name": "@traceloop/instrumentation-vertexai", - "version": "0.5.27", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@google-cloud/aiplatform": "^3.10.0", @@ -23309,20 +23309,20 @@ }, "packages/traceloop-sdk": { "name": "@traceloop/node-server-sdk", - "version": "0.5.28", + "version": "0.5.29", "license": "Apache-2.0", "dependencies": { "@opentelemetry/exporter-trace-otlp-proto": "^0.49.1", "@opentelemetry/sdk-node": "^0.49.1", - "@traceloop/ai-semantic-conventions": "^0.5.27", - "@traceloop/instrumentation-azure": "^0.5.27", - "@traceloop/instrumentation-bedrock": "^0.5.27", - "@traceloop/instrumentation-cohere": "^0.5.27", - "@traceloop/instrumentation-langchain": "^0.5.27", - "@traceloop/instrumentation-llamaindex": "^0.5.27", - "@traceloop/instrumentation-openai": "^0.5.28", - "@traceloop/instrumentation-pinecone": "^0.5.27", - "@traceloop/instrumentation-vertexai": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", + "@traceloop/instrumentation-azure": "^0.5.29", + "@traceloop/instrumentation-bedrock": "^0.5.29", + "@traceloop/instrumentation-cohere": "^0.5.29", + "@traceloop/instrumentation-langchain": "^0.5.29", + "@traceloop/instrumentation-llamaindex": "^0.5.29", + "@traceloop/instrumentation-openai": "^0.5.29", + "@traceloop/instrumentation-pinecone": "^0.5.29", + "@traceloop/instrumentation-vertexai": "^0.5.29", "@types/nunjucks": "^3.2.5", "cross-fetch": "^4.0.0", "fetch-retry": "^5.0.6", diff --git a/packages/ai-semantic-conventions/CHANGELOG.md b/packages/ai-semantic-conventions/CHANGELOG.md index a57624f8..e029fea5 100644 --- a/packages/ai-semantic-conventions/CHANGELOG.md +++ b/packages/ai-semantic-conventions/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **sdk:** clean and typed instrumentations ([#182](https://github.com/traceloop/openllmetry-js/issues/182)) ([83737ee](https://github.com/traceloop/openllmetry-js/commit/83737ee5291a68c59f255ab91216048824d7406b)) + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) ### Bug Fixes diff --git a/packages/ai-semantic-conventions/package.json b/packages/ai-semantic-conventions/package.json index 9f17c51a..7df77f78 100644 --- a/packages/ai-semantic-conventions/package.json +++ b/packages/ai-semantic-conventions/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/ai-semantic-conventions", - "version": "0.5.27", + "version": "0.5.29", "description": "OpenTelemetry ai-specific semantic conventions", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/packages/instrumentation-azure/CHANGELOG.md b/packages/instrumentation-azure/CHANGELOG.md index b95c899c..7e311ec4 100644 --- a/packages/instrumentation-azure/CHANGELOG.md +++ b/packages/instrumentation-azure/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **sdk:** clean and typed instrumentations ([#182](https://github.com/traceloop/openllmetry-js/issues/182)) ([83737ee](https://github.com/traceloop/openllmetry-js/commit/83737ee5291a68c59f255ab91216048824d7406b)) + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-azure diff --git a/packages/instrumentation-azure/package.json b/packages/instrumentation-azure/package.json index 226aa7d8..4bbcd66c 100644 --- a/packages/instrumentation-azure/package.json +++ b/packages/instrumentation-azure/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-azure", - "version": "0.5.27", + "version": "0.5.29", "description": "Azure OpenAI Instrumentaion", "main": "dist/index.js", "module": "dist/index.mjs", @@ -40,7 +40,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@azure/openai": "^1.0.0-beta.10", diff --git a/packages/instrumentation-bedrock/CHANGELOG.md b/packages/instrumentation-bedrock/CHANGELOG.md index 95a67eb3..30a7bdf6 100644 --- a/packages/instrumentation-bedrock/CHANGELOG.md +++ b/packages/instrumentation-bedrock/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-bedrock + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-bedrock diff --git a/packages/instrumentation-bedrock/package.json b/packages/instrumentation-bedrock/package.json index 9f26c93a..1da127d4 100644 --- a/packages/instrumentation-bedrock/package.json +++ b/packages/instrumentation-bedrock/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-bedrock", - "version": "0.5.27", + "version": "0.5.29", "description": "Amazon Bedrock Instrumentation", "main": "dist/index.js", "module": "dist/index.mjs", @@ -40,7 +40,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@aws-sdk/client-bedrock-runtime": "^3.499.0", diff --git a/packages/instrumentation-cohere/CHANGELOG.md b/packages/instrumentation-cohere/CHANGELOG.md index 37ef5ed8..5bdf9fb1 100644 --- a/packages/instrumentation-cohere/CHANGELOG.md +++ b/packages/instrumentation-cohere/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-cohere + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-cohere diff --git a/packages/instrumentation-cohere/package.json b/packages/instrumentation-cohere/package.json index 6e5e358b..2bcf9cb3 100644 --- a/packages/instrumentation-cohere/package.json +++ b/packages/instrumentation-cohere/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-cohere", - "version": "0.5.27", + "version": "0.5.29", "description": "Cohere Instrumentation", "main": "dist/index.js", "module": "dist/index.mjs", @@ -40,7 +40,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.44.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@pollyjs/adapter-node-http": "^6.0.6", diff --git a/packages/instrumentation-langchain/CHANGELOG.md b/packages/instrumentation-langchain/CHANGELOG.md index 5cfd9ad8..ad4f7dd5 100644 --- a/packages/instrumentation-langchain/CHANGELOG.md +++ b/packages/instrumentation-langchain/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-langchain + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-langchain diff --git a/packages/instrumentation-langchain/package.json b/packages/instrumentation-langchain/package.json index e197d088..3f55d6c5 100644 --- a/packages/instrumentation-langchain/package.json +++ b/packages/instrumentation-langchain/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-langchain", - "version": "0.5.27", + "version": "0.5.29", "description": "OpenTelemetry instrumentation for LangchainJS", "main": "dist/index.js", "module": "dist/index.mjs", @@ -40,7 +40,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@langchain/community": "^0.0.34", diff --git a/packages/instrumentation-llamaindex/CHANGELOG.md b/packages/instrumentation-llamaindex/CHANGELOG.md index 434df9af..ee42bced 100644 --- a/packages/instrumentation-llamaindex/CHANGELOG.md +++ b/packages/instrumentation-llamaindex/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-llamaindex + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-llamaindex diff --git a/packages/instrumentation-llamaindex/package.json b/packages/instrumentation-llamaindex/package.json index d744a9d8..7f6989ce 100644 --- a/packages/instrumentation-llamaindex/package.json +++ b/packages/instrumentation-llamaindex/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-llamaindex", - "version": "0.5.27", + "version": "0.5.29", "description": "Llamaindex Instrumentation", "main": "dist/index.js", "module": "dist/index.mjs", @@ -39,7 +39,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", "lodash": "^4.17.21" }, "devDependencies": { diff --git a/packages/instrumentation-openai/CHANGELOG.md b/packages/instrumentation-openai/CHANGELOG.md index c68f06f6..0801fa15 100644 --- a/packages/instrumentation-openai/CHANGELOG.md +++ b/packages/instrumentation-openai/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **openai:** enrich token metrics on streaming requests ([#183](https://github.com/traceloop/openllmetry-js/issues/183)) ([2ef0c13](https://github.com/traceloop/openllmetry-js/commit/2ef0c13f16b050d6f73ea9a5952abd0bbfe8a284)) + ## [0.5.28](https://github.com/traceloop/openllmetry-js/compare/v0.5.27...v0.5.28) (2024-04-02) ### Bug Fixes diff --git a/packages/instrumentation-openai/package.json b/packages/instrumentation-openai/package.json index 9a97622e..e814e13d 100644 --- a/packages/instrumentation-openai/package.json +++ b/packages/instrumentation-openai/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-openai", - "version": "0.5.28", + "version": "0.5.29", "description": "OpenAI Instrumentaion", "main": "dist/index.js", "module": "dist/index.mjs", @@ -39,7 +39,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", "tiktoken": "^1.0.13" }, "devDependencies": { diff --git a/packages/instrumentation-pinecone/CHANGELOG.md b/packages/instrumentation-pinecone/CHANGELOG.md index 281c88d5..49e8ab2d 100644 --- a/packages/instrumentation-pinecone/CHANGELOG.md +++ b/packages/instrumentation-pinecone/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-pinecone + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-pinecone diff --git a/packages/instrumentation-pinecone/package.json b/packages/instrumentation-pinecone/package.json index bdf4620e..1557623b 100644 --- a/packages/instrumentation-pinecone/package.json +++ b/packages/instrumentation-pinecone/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-pinecone", - "version": "0.5.27", + "version": "0.5.29", "description": "OpenTelemetry instrumentation for pinecone vector DB", "main": "dist/index.js", "module": "dist/index.mjs", @@ -40,7 +40,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@pinecone-database/pinecone": "^2.0.1", diff --git a/packages/instrumentation-vertexai/CHANGELOG.md b/packages/instrumentation-vertexai/CHANGELOG.md index 26fdef6a..0af2fbd1 100644 --- a/packages/instrumentation-vertexai/CHANGELOG.md +++ b/packages/instrumentation-vertexai/CHANGELOG.md @@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +**Note:** Version bump only for package @traceloop/instrumentation-vertexai + ## [0.5.27](https://github.com/traceloop/openllmetry-js/compare/v0.5.26...v0.5.27) (2024-03-26) **Note:** Version bump only for package @traceloop/instrumentation-vertexai diff --git a/packages/instrumentation-vertexai/package.json b/packages/instrumentation-vertexai/package.json index adc62f39..516d0875 100644 --- a/packages/instrumentation-vertexai/package.json +++ b/packages/instrumentation-vertexai/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/instrumentation-vertexai", - "version": "0.5.27", + "version": "0.5.29", "description": "Google's VertexAI Instrumentation", "main": "dist/index.js", "module": "dist/index.mjs", @@ -39,7 +39,7 @@ "@opentelemetry/core": "^1.22.0", "@opentelemetry/instrumentation": "^0.49.0", "@opentelemetry/semantic-conventions": "^1.22.0", - "@traceloop/ai-semantic-conventions": "^0.5.27" + "@traceloop/ai-semantic-conventions": "^0.5.29" }, "devDependencies": { "@google-cloud/aiplatform": "^3.10.0", diff --git a/packages/traceloop-sdk/CHANGELOG.md b/packages/traceloop-sdk/CHANGELOG.md index cb8b1451..4d981738 100644 --- a/packages/traceloop-sdk/CHANGELOG.md +++ b/packages/traceloop-sdk/CHANGELOG.md @@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [0.5.29](https://github.com/traceloop/openllmetry-js/compare/v0.5.28...v0.5.29) (2024-04-03) + +### Bug Fixes + +- **openai:** enrich token metrics on streaming requests ([#183](https://github.com/traceloop/openllmetry-js/issues/183)) ([2ef0c13](https://github.com/traceloop/openllmetry-js/commit/2ef0c13f16b050d6f73ea9a5952abd0bbfe8a284)) +- **sdk:** clean and typed instrumentations ([#182](https://github.com/traceloop/openllmetry-js/issues/182)) ([83737ee](https://github.com/traceloop/openllmetry-js/commit/83737ee5291a68c59f255ab91216048824d7406b)) + ## [0.5.28](https://github.com/traceloop/openllmetry-js/compare/v0.5.27...v0.5.28) (2024-04-02) ### Bug Fixes diff --git a/packages/traceloop-sdk/package.json b/packages/traceloop-sdk/package.json index 1e481edd..ef3c6536 100644 --- a/packages/traceloop-sdk/package.json +++ b/packages/traceloop-sdk/package.json @@ -1,6 +1,6 @@ { "name": "@traceloop/node-server-sdk", - "version": "0.5.28", + "version": "0.5.29", "description": "Traceloop Software Development Kit (SDK) for Node.js", "main": "dist/index.js", "module": "dist/index.mjs", @@ -37,15 +37,15 @@ "dependencies": { "@opentelemetry/exporter-trace-otlp-proto": "^0.49.1", "@opentelemetry/sdk-node": "^0.49.1", - "@traceloop/ai-semantic-conventions": "^0.5.27", - "@traceloop/instrumentation-azure": "^0.5.27", - "@traceloop/instrumentation-bedrock": "^0.5.27", - "@traceloop/instrumentation-cohere": "^0.5.27", - "@traceloop/instrumentation-langchain": "^0.5.27", - "@traceloop/instrumentation-llamaindex": "^0.5.27", - "@traceloop/instrumentation-openai": "^0.5.28", - "@traceloop/instrumentation-pinecone": "^0.5.27", - "@traceloop/instrumentation-vertexai": "^0.5.27", + "@traceloop/ai-semantic-conventions": "^0.5.29", + "@traceloop/instrumentation-azure": "^0.5.29", + "@traceloop/instrumentation-bedrock": "^0.5.29", + "@traceloop/instrumentation-cohere": "^0.5.29", + "@traceloop/instrumentation-langchain": "^0.5.29", + "@traceloop/instrumentation-llamaindex": "^0.5.29", + "@traceloop/instrumentation-openai": "^0.5.29", + "@traceloop/instrumentation-pinecone": "^0.5.29", + "@traceloop/instrumentation-vertexai": "^0.5.29", "@types/nunjucks": "^3.2.5", "cross-fetch": "^4.0.0", "fetch-retry": "^5.0.6", @@ -57,22 +57,22 @@ "homepage": "https://github.com/traceloop/openllmetry-js/tree/main/packages/traceloop-sdk", "gitHead": "ef1e70d6037f7b5c061056ef2be16e3f55f02ed5", "devDependencies": { + "@aws-sdk/client-bedrock-runtime": "^3.499.0", + "@azure/openai": "^1.0.0-beta.11", + "@google-cloud/aiplatform": "^3.10.0", + "@google-cloud/vertexai": "^0.2.1", + "@pinecone-database/pinecone": "^2.0.1", "@pollyjs/adapter-node-http": "^6.0.6", "@pollyjs/core": "^6.0.6", "@pollyjs/persister-fs": "^6.0.6", "@types/mocha": "^10.0.6", "@types/node": "^20.9.0", "@types/uuid": "^9.0.7", - "esbuild": "^0.20.1", - "ts-mocha": "^10.0.0", - "@aws-sdk/client-bedrock-runtime": "^3.499.0", - "@azure/openai": "^1.0.0-beta.11", - "@google-cloud/aiplatform": "^3.10.0", - "@google-cloud/vertexai": "^0.2.1", - "@pinecone-database/pinecone": "^2.0.1", "cohere-ai": "^7.7.5", + "esbuild": "^0.20.1", "langchain": "^0.1.7", "llamaindex": "^0.1.16", - "openai": "^4.12.4" + "openai": "^4.12.4", + "ts-mocha": "^10.0.0" } }