From 2f3a0110826a42737214e5fcce22d40fd4a34c37 Mon Sep 17 00:00:00 2001 From: Nir Gazit Date: Tue, 2 Apr 2024 20:15:17 +0200 Subject: [PATCH] fix(sdk): clean and typed instrumentations --- 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); } };