@lmnr-ai/lmnr 0.4.23 → 0.4.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +4 -4
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +4 -4
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +19 -2
- package/dist/index.d.ts +19 -2
- package/dist/index.js +56 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +74 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/evaluations.ts +1 -1
- package/src/laminar.ts +18 -2
- package/src/sdk/interfaces/initialize-options.interface.ts +7 -0
- package/src/sdk/tracing/decorators.ts +22 -1
- package/src/sdk/tracing/index.ts +25 -10
package/dist/cli.js
CHANGED
|
@@ -36,7 +36,7 @@ var require_package = __commonJS({
|
|
|
36
36
|
"package.json"(exports2, module2) {
|
|
37
37
|
module2.exports = {
|
|
38
38
|
name: "@lmnr-ai/lmnr",
|
|
39
|
-
version: "0.4.
|
|
39
|
+
version: "0.4.24",
|
|
40
40
|
description: "TypeScript SDK for Laminar AI",
|
|
41
41
|
main: "dist/index.js",
|
|
42
42
|
types: "dist/index.d.ts",
|
|
@@ -78,14 +78,14 @@ var require_package = __commonJS({
|
|
|
78
78
|
"@types/semver": "^7.5.8",
|
|
79
79
|
"@types/uuid": "^10.0.0",
|
|
80
80
|
bufferutil: "^4.0.8",
|
|
81
|
-
chromadb: "^1.9.
|
|
81
|
+
chromadb: "^1.9.4",
|
|
82
82
|
"cohere-ai": "^7.14.0",
|
|
83
83
|
langchain: "^0.3.2",
|
|
84
84
|
llamaindex: "^0.7.10",
|
|
85
85
|
openai: "^4.62.1",
|
|
86
86
|
runnables: "link:@langchain/core/runnables",
|
|
87
|
-
tsup: "^8.3.
|
|
88
|
-
typescript: "^5.
|
|
87
|
+
tsup: "^8.3.5",
|
|
88
|
+
typescript: "^5.7.2",
|
|
89
89
|
vectorstores: "link:@langchain/core/vectorstores"
|
|
90
90
|
},
|
|
91
91
|
dependencies: {
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.24\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.4\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AA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AAC;AAAA,MAChB;AAEA,YAAM,iBAAiB,OAAO,YAAY,CAAC,EAAE;AAE7C,YAAM,aAAa,WAAW;AAAA,QAC5B,UAAUA,MAAK;AAAA,QACf,YAAY;AAAA,MACd,CAAC;AAGD,YAAM,WAAW,IAAI;AAAA,IACvB;AAAA,EACF,CAAC;AAED,QAAM,SAAS,OAAO,WAAW,IAAI;AACrC,QAAM,OAAO,KAAK,MAAM;AAC1B;AAEA,IAAI;","names":["exports","module","args"]}
|
package/dist/cli.mjs
CHANGED
|
@@ -15,7 +15,7 @@ var require_package = __commonJS({
|
|
|
15
15
|
"package.json"(exports, module) {
|
|
16
16
|
module.exports = {
|
|
17
17
|
name: "@lmnr-ai/lmnr",
|
|
18
|
-
version: "0.4.
|
|
18
|
+
version: "0.4.24",
|
|
19
19
|
description: "TypeScript SDK for Laminar AI",
|
|
20
20
|
main: "dist/index.js",
|
|
21
21
|
types: "dist/index.d.ts",
|
|
@@ -57,14 +57,14 @@ var require_package = __commonJS({
|
|
|
57
57
|
"@types/semver": "^7.5.8",
|
|
58
58
|
"@types/uuid": "^10.0.0",
|
|
59
59
|
bufferutil: "^4.0.8",
|
|
60
|
-
chromadb: "^1.9.
|
|
60
|
+
chromadb: "^1.9.4",
|
|
61
61
|
"cohere-ai": "^7.14.0",
|
|
62
62
|
langchain: "^0.3.2",
|
|
63
63
|
llamaindex: "^0.7.10",
|
|
64
64
|
openai: "^4.62.1",
|
|
65
65
|
runnables: "link:@langchain/core/runnables",
|
|
66
|
-
tsup: "^8.3.
|
|
67
|
-
typescript: "^5.
|
|
66
|
+
tsup: "^8.3.5",
|
|
67
|
+
typescript: "^5.7.2",
|
|
68
68
|
vectorstores: "link:@langchain/core/vectorstores"
|
|
69
69
|
},
|
|
70
70
|
dependencies: {
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.24\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.4\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.5\",\n \"typescript\": \"^5.7.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,QACT,OAAS;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA,KAAO;AAAA,QACL,MAAQ;AAAA,MACV;AAAA,MACA,YAAc;AAAA,QACZ,MAAQ;AAAA,QACR,KAAO;AAAA,MACT;AAAA,MACA,UAA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K,MAAM;AAC1B;AAEA,IAAI;","names":["args"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -114,6 +114,12 @@ interface InitializeOptions {
|
|
|
114
114
|
* Defaults to false.
|
|
115
115
|
*/
|
|
116
116
|
silenceInitializationMessage?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to use an external tracer provider. Optional.
|
|
119
|
+
* Defaults to false. If true, the SDK will not initialize its own tracer provider.
|
|
120
|
+
* This is useful for advanced use cases where the user wants to manage the tracer provider themselves.
|
|
121
|
+
*/
|
|
122
|
+
useExternalTracerProvider?: boolean;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
declare global {
|
|
@@ -177,7 +183,7 @@ type EvaluatorFunctionReturn = number | Record<string, number>;
|
|
|
177
183
|
* of string keys and number values. The latter is useful for evaluating
|
|
178
184
|
* multiple criteria in one go instead of running multiple evaluators.
|
|
179
185
|
*/
|
|
180
|
-
type EvaluatorFunction<O, T> = (output: O, target
|
|
186
|
+
type EvaluatorFunction<O, T> = (output: O, target?: T, ...args: any[]) => EvaluatorFunctionReturn | Promise<EvaluatorFunctionReturn>;
|
|
181
187
|
/**
|
|
182
188
|
* HumanEvaluator is an object to register a human evaluator. For now, it only
|
|
183
189
|
* holds the queue name.
|
|
@@ -355,6 +361,7 @@ interface LaminarInitializeProps {
|
|
|
355
361
|
httpPort?: number;
|
|
356
362
|
grpcPort?: number;
|
|
357
363
|
instrumentModules?: InitializeOptions["instrumentModules"];
|
|
364
|
+
useExternalTracerProvider?: boolean;
|
|
358
365
|
}
|
|
359
366
|
declare class Laminar {
|
|
360
367
|
private static baseHttpUrl;
|
|
@@ -383,6 +390,16 @@ declare class Laminar {
|
|
|
383
390
|
* LLM calls (OpenAI, Anthropic, etc), Langchain, VectorDB calls (Pinecone, Qdrant, etc).
|
|
384
391
|
* Pass an empty object {} to disable any kind of automatic instrumentation.
|
|
385
392
|
* If you only want to auto-instrument specific modules, then pass them in the object.
|
|
393
|
+
* @param useExternalTracerProvider - [ADVANCED] Only use if you are using another
|
|
394
|
+
* node-based tracer provider. Defaults to false.
|
|
395
|
+
* If `true`, the SDK will not initialize its own tracer provider. Be very careful.
|
|
396
|
+
* If you set this to `true`, but the external provider does not extend/implement
|
|
397
|
+
* {@link BasicTracerProvider} or is not a {@link ProxyTracerProvider} that internally
|
|
398
|
+
* delegates to a {@link BasicTracerProvider}, the SDK will not function correctly.
|
|
399
|
+
* The only setting this has been tested with is `@opentelemetry/auto-instrumentations-node`.
|
|
400
|
+
* {@link https://opentelemetry.io/docs/zero-code/js/#configuring-the-module} - this
|
|
401
|
+
* initializes a {@link ProxyTracerProvider} internally which delegates to a
|
|
402
|
+
* {@link NodeTracerProvider}, which in turn, extends {@link BasicTracerProvider}.
|
|
386
403
|
*
|
|
387
404
|
* @example
|
|
388
405
|
* import { Laminar as L } from '@lmnr-ai/lmnr';
|
|
@@ -399,7 +416,7 @@ declare class Laminar {
|
|
|
399
416
|
*
|
|
400
417
|
* @throws {Error} - If project API key is not set
|
|
401
418
|
*/
|
|
402
|
-
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules }: LaminarInitializeProps): void;
|
|
419
|
+
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider, }: LaminarInitializeProps): void;
|
|
403
420
|
/**
|
|
404
421
|
* Check if Laminar has been initialized. Utility to make sure other methods
|
|
405
422
|
* are called after initialization.
|
package/dist/index.d.ts
CHANGED
|
@@ -114,6 +114,12 @@ interface InitializeOptions {
|
|
|
114
114
|
* Defaults to false.
|
|
115
115
|
*/
|
|
116
116
|
silenceInitializationMessage?: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Whether to use an external tracer provider. Optional.
|
|
119
|
+
* Defaults to false. If true, the SDK will not initialize its own tracer provider.
|
|
120
|
+
* This is useful for advanced use cases where the user wants to manage the tracer provider themselves.
|
|
121
|
+
*/
|
|
122
|
+
useExternalTracerProvider?: boolean;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
declare global {
|
|
@@ -177,7 +183,7 @@ type EvaluatorFunctionReturn = number | Record<string, number>;
|
|
|
177
183
|
* of string keys and number values. The latter is useful for evaluating
|
|
178
184
|
* multiple criteria in one go instead of running multiple evaluators.
|
|
179
185
|
*/
|
|
180
|
-
type EvaluatorFunction<O, T> = (output: O, target
|
|
186
|
+
type EvaluatorFunction<O, T> = (output: O, target?: T, ...args: any[]) => EvaluatorFunctionReturn | Promise<EvaluatorFunctionReturn>;
|
|
181
187
|
/**
|
|
182
188
|
* HumanEvaluator is an object to register a human evaluator. For now, it only
|
|
183
189
|
* holds the queue name.
|
|
@@ -355,6 +361,7 @@ interface LaminarInitializeProps {
|
|
|
355
361
|
httpPort?: number;
|
|
356
362
|
grpcPort?: number;
|
|
357
363
|
instrumentModules?: InitializeOptions["instrumentModules"];
|
|
364
|
+
useExternalTracerProvider?: boolean;
|
|
358
365
|
}
|
|
359
366
|
declare class Laminar {
|
|
360
367
|
private static baseHttpUrl;
|
|
@@ -383,6 +390,16 @@ declare class Laminar {
|
|
|
383
390
|
* LLM calls (OpenAI, Anthropic, etc), Langchain, VectorDB calls (Pinecone, Qdrant, etc).
|
|
384
391
|
* Pass an empty object {} to disable any kind of automatic instrumentation.
|
|
385
392
|
* If you only want to auto-instrument specific modules, then pass them in the object.
|
|
393
|
+
* @param useExternalTracerProvider - [ADVANCED] Only use if you are using another
|
|
394
|
+
* node-based tracer provider. Defaults to false.
|
|
395
|
+
* If `true`, the SDK will not initialize its own tracer provider. Be very careful.
|
|
396
|
+
* If you set this to `true`, but the external provider does not extend/implement
|
|
397
|
+
* {@link BasicTracerProvider} or is not a {@link ProxyTracerProvider} that internally
|
|
398
|
+
* delegates to a {@link BasicTracerProvider}, the SDK will not function correctly.
|
|
399
|
+
* The only setting this has been tested with is `@opentelemetry/auto-instrumentations-node`.
|
|
400
|
+
* {@link https://opentelemetry.io/docs/zero-code/js/#configuring-the-module} - this
|
|
401
|
+
* initializes a {@link ProxyTracerProvider} internally which delegates to a
|
|
402
|
+
* {@link NodeTracerProvider}, which in turn, extends {@link BasicTracerProvider}.
|
|
386
403
|
*
|
|
387
404
|
* @example
|
|
388
405
|
* import { Laminar as L } from '@lmnr-ai/lmnr';
|
|
@@ -399,7 +416,7 @@ declare class Laminar {
|
|
|
399
416
|
*
|
|
400
417
|
* @throws {Error} - If project API key is not set
|
|
401
418
|
*/
|
|
402
|
-
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules }: LaminarInitializeProps): void;
|
|
419
|
+
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider, }: LaminarInitializeProps): void;
|
|
403
420
|
/**
|
|
404
421
|
* Check if Laminar has been initialized. Utility to make sure other methods
|
|
405
422
|
* are called after initialization.
|
package/dist/index.js
CHANGED
|
@@ -305,13 +305,28 @@ var startTracing = (options) => {
|
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
308
|
+
if (options.useExternalTracerProvider) {
|
|
309
|
+
const globalProvider = import_api2.trace.getTracerProvider();
|
|
310
|
+
let provider;
|
|
311
|
+
if (globalProvider instanceof import_api2.ProxyTracerProvider) {
|
|
312
|
+
provider = globalProvider.getDelegate();
|
|
313
|
+
} else {
|
|
314
|
+
provider = globalProvider;
|
|
315
|
+
}
|
|
316
|
+
if (provider.addSpanProcessor) {
|
|
317
|
+
provider.addSpanProcessor(_spanProcessor);
|
|
318
|
+
} else {
|
|
319
|
+
throw new Error("The active tracer provider does not support adding a span processor");
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
const provider = new import_sdk_trace_node.NodeTracerProvider();
|
|
323
|
+
provider.addSpanProcessor(_spanProcessor);
|
|
324
|
+
provider.register();
|
|
325
|
+
(0, import_instrumentation.registerInstrumentations)({
|
|
326
|
+
instrumentations,
|
|
327
|
+
tracerProvider: provider
|
|
328
|
+
});
|
|
329
|
+
}
|
|
315
330
|
};
|
|
316
331
|
var shouldSendTraces = () => {
|
|
317
332
|
if (!_configuration) {
|
|
@@ -489,7 +504,14 @@ function withEntity({
|
|
|
489
504
|
ASSOCIATION_PROPERTIES_KEY,
|
|
490
505
|
{ ...currentAssociationProperties != null ? currentAssociationProperties : {}, ...rest }
|
|
491
506
|
);
|
|
492
|
-
|
|
507
|
+
let res;
|
|
508
|
+
try {
|
|
509
|
+
res = fn.apply(thisArg, args);
|
|
510
|
+
} catch (error) {
|
|
511
|
+
processException(error, span);
|
|
512
|
+
span.end();
|
|
513
|
+
throw error;
|
|
514
|
+
}
|
|
493
515
|
if (res instanceof Promise) {
|
|
494
516
|
return res.then((resolvedRes) => {
|
|
495
517
|
try {
|
|
@@ -505,6 +527,10 @@ function withEntity({
|
|
|
505
527
|
span.end();
|
|
506
528
|
}
|
|
507
529
|
return resolvedRes;
|
|
530
|
+
}).catch((error) => {
|
|
531
|
+
processException(error, span);
|
|
532
|
+
span.end();
|
|
533
|
+
throw error;
|
|
508
534
|
});
|
|
509
535
|
}
|
|
510
536
|
try {
|
|
@@ -543,6 +569,14 @@ function cleanInput(input) {
|
|
|
543
569
|
function serialize(input) {
|
|
544
570
|
return JSON.stringify(cleanInput(input));
|
|
545
571
|
}
|
|
572
|
+
function processException(error, span) {
|
|
573
|
+
span.addEvent("exception", {
|
|
574
|
+
"exception.type": error.name,
|
|
575
|
+
"exception.message": error.message,
|
|
576
|
+
"exception.stack": error.stack,
|
|
577
|
+
"exception.escaped": true
|
|
578
|
+
});
|
|
579
|
+
}
|
|
546
580
|
|
|
547
581
|
// src/laminar.ts
|
|
548
582
|
var import_exporter_trace_otlp_grpc = require("@opentelemetry/exporter-trace-otlp-grpc");
|
|
@@ -570,6 +604,16 @@ var Laminar = class {
|
|
|
570
604
|
* LLM calls (OpenAI, Anthropic, etc), Langchain, VectorDB calls (Pinecone, Qdrant, etc).
|
|
571
605
|
* Pass an empty object {} to disable any kind of automatic instrumentation.
|
|
572
606
|
* If you only want to auto-instrument specific modules, then pass them in the object.
|
|
607
|
+
* @param useExternalTracerProvider - [ADVANCED] Only use if you are using another
|
|
608
|
+
* node-based tracer provider. Defaults to false.
|
|
609
|
+
* If `true`, the SDK will not initialize its own tracer provider. Be very careful.
|
|
610
|
+
* If you set this to `true`, but the external provider does not extend/implement
|
|
611
|
+
* {@link BasicTracerProvider} or is not a {@link ProxyTracerProvider} that internally
|
|
612
|
+
* delegates to a {@link BasicTracerProvider}, the SDK will not function correctly.
|
|
613
|
+
* The only setting this has been tested with is `@opentelemetry/auto-instrumentations-node`.
|
|
614
|
+
* {@link https://opentelemetry.io/docs/zero-code/js/#configuring-the-module} - this
|
|
615
|
+
* initializes a {@link ProxyTracerProvider} internally which delegates to a
|
|
616
|
+
* {@link NodeTracerProvider}, which in turn, extends {@link BasicTracerProvider}.
|
|
573
617
|
*
|
|
574
618
|
* @example
|
|
575
619
|
* import { Laminar as L } from '@lmnr-ai/lmnr';
|
|
@@ -592,7 +636,8 @@ var Laminar = class {
|
|
|
592
636
|
baseUrl,
|
|
593
637
|
httpPort,
|
|
594
638
|
grpcPort,
|
|
595
|
-
instrumentModules
|
|
639
|
+
instrumentModules,
|
|
640
|
+
useExternalTracerProvider
|
|
596
641
|
}) {
|
|
597
642
|
let key = projectApiKey != null ? projectApiKey : process.env.LMNR_PROJECT_API_KEY;
|
|
598
643
|
if (key === void 0) {
|
|
@@ -620,7 +665,8 @@ var Laminar = class {
|
|
|
620
665
|
exporter,
|
|
621
666
|
silenceInitializationMessage: true,
|
|
622
667
|
instrumentModules,
|
|
623
|
-
disableBatch: false
|
|
668
|
+
disableBatch: false,
|
|
669
|
+
useExternalTracerProvider
|
|
624
670
|
});
|
|
625
671
|
}
|
|
626
672
|
/**
|