@lmnr-ai/lmnr 0.4.26 → 0.4.27
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 +61 -25
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +61 -25
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -1
- package/src/cli.ts +73 -26
- package/src/laminar.ts +2 -10
- package/src/sdk/configuration/index.ts +1 -1
- package/src/sdk/node-server-sdk.ts +1 -1
- package/test/tracing.test.ts +26 -11
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.27",
|
|
40
40
|
description: "TypeScript SDK for Laminar AI",
|
|
41
41
|
main: "dist/index.js",
|
|
42
42
|
types: "dist/index.d.ts",
|
|
@@ -113,6 +113,7 @@ var require_package = __commonJS({
|
|
|
113
113
|
argparse: "^2.0.1",
|
|
114
114
|
"cli-progress": "^3.12.0",
|
|
115
115
|
esbuild: "^0.24.0",
|
|
116
|
+
glob: "^11.0.0",
|
|
116
117
|
uuid: "^11.0.3"
|
|
117
118
|
}
|
|
118
119
|
};
|
|
@@ -127,6 +128,7 @@ __export(cli_exports, {
|
|
|
127
128
|
module.exports = __toCommonJS(cli_exports);
|
|
128
129
|
var import_argparse = require("argparse");
|
|
129
130
|
var esbuild = __toESM(require("esbuild"));
|
|
131
|
+
var glob = __toESM(require("glob"));
|
|
130
132
|
var pjson = require_package();
|
|
131
133
|
function loadModule({
|
|
132
134
|
filename,
|
|
@@ -141,41 +143,75 @@ async function cli() {
|
|
|
141
143
|
const [, , ...args] = process.argv;
|
|
142
144
|
const parser = new import_argparse.ArgumentParser({
|
|
143
145
|
prog: "lmnr",
|
|
144
|
-
description: "CLI for Laminar"
|
|
146
|
+
description: "CLI for Laminar. Use `lmnr <subcommand> --help` for more information."
|
|
145
147
|
});
|
|
146
148
|
parser.add_argument("-v", "--version", { action: "version", version: pjson.version });
|
|
147
149
|
const subparsers = parser.add_subparsers({
|
|
148
150
|
title: "subcommands",
|
|
149
151
|
dest: "subcommand"
|
|
150
152
|
});
|
|
151
|
-
const
|
|
152
|
-
description: "Run an evaluation"
|
|
153
|
+
const parserEval = subparsers.add_parser("eval", {
|
|
154
|
+
description: "Run an evaluation",
|
|
155
|
+
help: "Run an evaluation"
|
|
153
156
|
});
|
|
154
|
-
|
|
155
|
-
help: "A file containing the evaluation to run"
|
|
157
|
+
parserEval.add_argument("file", {
|
|
158
|
+
help: "A file containing the evaluation to run. If no file is provided, the evaluation will run all `*.eval.ts|js` files in the `evals` directory.",
|
|
159
|
+
nargs: "?"
|
|
156
160
|
});
|
|
157
|
-
|
|
161
|
+
parserEval.add_argument("--fail-on-error", {
|
|
162
|
+
help: "Fail on error. If specified, will fail if encounters a file that cannot be run",
|
|
163
|
+
action: "store_true"
|
|
164
|
+
});
|
|
165
|
+
parserEval.set_defaults({
|
|
158
166
|
func: async (args2) => {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
// will be loaded in memory as a temp file
|
|
164
|
-
platform: "node",
|
|
165
|
-
bundle: true,
|
|
166
|
-
external: ["node_modules/*"]
|
|
167
|
-
};
|
|
168
|
-
const result = await esbuild.build(buildOptions);
|
|
169
|
-
if (!result.outputFiles) {
|
|
170
|
-
console.error("Error when building: No output files found");
|
|
167
|
+
const files = args2.file ? [args2.file] : glob.sync("evals/**/*.eval.{ts,js}");
|
|
168
|
+
files.sort();
|
|
169
|
+
if (files.length === 0) {
|
|
170
|
+
console.error("No evaluation files found. Please provide a file or ensure there are files in the `evals` directory.");
|
|
171
171
|
process.exit(1);
|
|
172
172
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
173
|
+
if (!args2.file) {
|
|
174
|
+
console.log(`Located ${files.length} evaluation files in evals/`);
|
|
175
|
+
}
|
|
176
|
+
for (const file of files) {
|
|
177
|
+
console.log(`Loading ${file}...`);
|
|
178
|
+
const buildOptions = {
|
|
179
|
+
entryPoints: [file],
|
|
180
|
+
outfile: `tmp_out_${file}.js`,
|
|
181
|
+
write: false,
|
|
182
|
+
// will be loaded in memory as a temp file
|
|
183
|
+
platform: "node",
|
|
184
|
+
bundle: true,
|
|
185
|
+
external: ["node_modules/*"]
|
|
186
|
+
};
|
|
187
|
+
const result = await esbuild.build(buildOptions);
|
|
188
|
+
if (!result.outputFiles) {
|
|
189
|
+
console.error("Error when building: No output files found");
|
|
190
|
+
if (args2.fail_on_error) {
|
|
191
|
+
process.exit(1);
|
|
192
|
+
}
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
const outputFileText = result.outputFiles[0].text;
|
|
196
|
+
const evaluation = loadModule({
|
|
197
|
+
filename: args2.file,
|
|
198
|
+
moduleText: outputFileText
|
|
199
|
+
});
|
|
200
|
+
if (!evaluation?.run) {
|
|
201
|
+
console.error(`Evaluation ${file} does not properly call evaluate()`);
|
|
202
|
+
if (args2.fail_on_error) {
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
await evaluation.run();
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
parser.set_defaults({
|
|
212
|
+
func: async (args2) => {
|
|
213
|
+
parser.print_help();
|
|
214
|
+
process.exit(0);
|
|
179
215
|
}
|
|
180
216
|
});
|
|
181
217
|
const parsed = parser.parse_args(args);
|
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.26\",\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\": \"tsx --test test/*.test.ts\"\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.705.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.0\",\n \"@langchain/core\": \"^0.3.20\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.12.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.10.1\",\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.15.0\",\n \"langchain\": \"^0.3.6\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.75.0\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.2\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.12.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.28.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.28.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.28.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.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.4\",\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.4\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.0\",\n \"uuid\": \"^11.0.3\"\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;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,UAAY;AAAA,QACV;AAAA,QACA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A,IAAI;","names":["exports","module","args"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.27\",\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\": \"tsx --test test/*.test.ts\"\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.705.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.0\",\n \"@langchain/core\": \"^0.3.20\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.12.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.10.1\",\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.15.0\",\n \"langchain\": \"^0.3.6\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.75.0\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.2\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.12.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.28.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.28.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.28.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.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.4\",\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.4\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.0\",\n \"glob\": \"^11.0.0\",\n \"uuid\": \"^11.0.3\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\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. Use `lmnr <subcommand> --help` for more information.\",\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 parserEval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n help: \"Run an evaluation\",\n });\n\n parserEval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory.\",\n nargs: \"?\",\n });\n\n parserEval.add_argument(\"--fail-on-error\", {\n help: \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n action: \"store_true\",\n });\n\n parserEval.set_defaults({\n func: async (args: any) => {\n const files = args.file\n ? [args.file]\n : glob.sync('evals/**/*.eval.{ts,js}')\n\n files.sort();\n\n if (files.length === 0) {\n console.error(\"No evaluation files found. Please provide a file or \" +\n \"ensure there are files in the `evals` directory.\");\n process.exit(1);\n }\n\n if (!args.file) {\n console.log(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n console.log(`Loading ${file}...`);\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [file],\n outfile: `tmp_out_${file}.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 if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\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 if (!evaluation?.run) {\n console.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\n // @ts-ignore\n await evaluation.run();\n }\n }\n });\n\n parser.set_defaults({\n func: async (args: any) => {\n parser.print_help();\n process.exit(0);\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;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,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAU;AAAA,MACV,SAAW;AAAA,MACX,MAAQ;AAAA,QACN,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,MACZ,iBAAmB;AAAA,QACjB,qBAAqB;AAAA,QACrB,mCAAmC;AAAA,QACnC,iBAAiB;AAAA,QACjB,4BAA4B;AAAA,QAC5B,0BAA0B;AAAA,QAC1B,mBAAmB;AAAA,QACnB,+BAA+B;AAAA,QAC/B,0BAA0B;AAAA,QAC1B,mBAAmB;AAAA,QACnB,uBAAuB;AAAA,QACvB,eAAe;AAAA,QACf,iBAAiB;AAAA,QACjB,eAAe;AAAA,QACf,YAAc;AAAA,QACd,UAAY;AAAA,QACZ,aAAa;AAAA,QACb,WAAa;AAAA,QACb,YAAc;AAAA,QACd,QAAU;AAA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;AAAA,UAChB;AACA;AAAA,QACF;AAGA,cAAM,WAAW,IAAI;AAAA,MACvB;AAAA,IACF;AAAA,EACF,CAAC;AAED,SAAO,aAAa;AAAA,IAClB,MAAM,OAAOA,UAAc;AACzB,aAAO,WAAW;AAClB,cAAQ,KAAK,CAAC;AAAA,IAChB;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.27",
|
|
19
19
|
description: "TypeScript SDK for Laminar AI",
|
|
20
20
|
main: "dist/index.js",
|
|
21
21
|
types: "dist/index.d.ts",
|
|
@@ -92,6 +92,7 @@ var require_package = __commonJS({
|
|
|
92
92
|
argparse: "^2.0.1",
|
|
93
93
|
"cli-progress": "^3.12.0",
|
|
94
94
|
esbuild: "^0.24.0",
|
|
95
|
+
glob: "^11.0.0",
|
|
95
96
|
uuid: "^11.0.3"
|
|
96
97
|
}
|
|
97
98
|
};
|
|
@@ -101,6 +102,7 @@ var require_package = __commonJS({
|
|
|
101
102
|
// src/cli.ts
|
|
102
103
|
import { ArgumentParser } from "argparse";
|
|
103
104
|
import * as esbuild from "esbuild";
|
|
105
|
+
import * as glob from "glob";
|
|
104
106
|
var pjson = require_package();
|
|
105
107
|
function loadModule({
|
|
106
108
|
filename,
|
|
@@ -115,41 +117,75 @@ async function cli() {
|
|
|
115
117
|
const [, , ...args] = process.argv;
|
|
116
118
|
const parser = new ArgumentParser({
|
|
117
119
|
prog: "lmnr",
|
|
118
|
-
description: "CLI for Laminar"
|
|
120
|
+
description: "CLI for Laminar. Use `lmnr <subcommand> --help` for more information."
|
|
119
121
|
});
|
|
120
122
|
parser.add_argument("-v", "--version", { action: "version", version: pjson.version });
|
|
121
123
|
const subparsers = parser.add_subparsers({
|
|
122
124
|
title: "subcommands",
|
|
123
125
|
dest: "subcommand"
|
|
124
126
|
});
|
|
125
|
-
const
|
|
126
|
-
description: "Run an evaluation"
|
|
127
|
+
const parserEval = subparsers.add_parser("eval", {
|
|
128
|
+
description: "Run an evaluation",
|
|
129
|
+
help: "Run an evaluation"
|
|
127
130
|
});
|
|
128
|
-
|
|
129
|
-
help: "A file containing the evaluation to run"
|
|
131
|
+
parserEval.add_argument("file", {
|
|
132
|
+
help: "A file containing the evaluation to run. If no file is provided, the evaluation will run all `*.eval.ts|js` files in the `evals` directory.",
|
|
133
|
+
nargs: "?"
|
|
130
134
|
});
|
|
131
|
-
|
|
135
|
+
parserEval.add_argument("--fail-on-error", {
|
|
136
|
+
help: "Fail on error. If specified, will fail if encounters a file that cannot be run",
|
|
137
|
+
action: "store_true"
|
|
138
|
+
});
|
|
139
|
+
parserEval.set_defaults({
|
|
132
140
|
func: async (args2) => {
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
// will be loaded in memory as a temp file
|
|
138
|
-
platform: "node",
|
|
139
|
-
bundle: true,
|
|
140
|
-
external: ["node_modules/*"]
|
|
141
|
-
};
|
|
142
|
-
const result = await esbuild.build(buildOptions);
|
|
143
|
-
if (!result.outputFiles) {
|
|
144
|
-
console.error("Error when building: No output files found");
|
|
141
|
+
const files = args2.file ? [args2.file] : glob.sync("evals/**/*.eval.{ts,js}");
|
|
142
|
+
files.sort();
|
|
143
|
+
if (files.length === 0) {
|
|
144
|
+
console.error("No evaluation files found. Please provide a file or ensure there are files in the `evals` directory.");
|
|
145
145
|
process.exit(1);
|
|
146
146
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
147
|
+
if (!args2.file) {
|
|
148
|
+
console.log(`Located ${files.length} evaluation files in evals/`);
|
|
149
|
+
}
|
|
150
|
+
for (const file of files) {
|
|
151
|
+
console.log(`Loading ${file}...`);
|
|
152
|
+
const buildOptions = {
|
|
153
|
+
entryPoints: [file],
|
|
154
|
+
outfile: `tmp_out_${file}.js`,
|
|
155
|
+
write: false,
|
|
156
|
+
// will be loaded in memory as a temp file
|
|
157
|
+
platform: "node",
|
|
158
|
+
bundle: true,
|
|
159
|
+
external: ["node_modules/*"]
|
|
160
|
+
};
|
|
161
|
+
const result = await esbuild.build(buildOptions);
|
|
162
|
+
if (!result.outputFiles) {
|
|
163
|
+
console.error("Error when building: No output files found");
|
|
164
|
+
if (args2.fail_on_error) {
|
|
165
|
+
process.exit(1);
|
|
166
|
+
}
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
const outputFileText = result.outputFiles[0].text;
|
|
170
|
+
const evaluation = loadModule({
|
|
171
|
+
filename: args2.file,
|
|
172
|
+
moduleText: outputFileText
|
|
173
|
+
});
|
|
174
|
+
if (!evaluation?.run) {
|
|
175
|
+
console.error(`Evaluation ${file} does not properly call evaluate()`);
|
|
176
|
+
if (args2.fail_on_error) {
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
await evaluation.run();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
parser.set_defaults({
|
|
186
|
+
func: async (args2) => {
|
|
187
|
+
parser.print_help();
|
|
188
|
+
process.exit(0);
|
|
153
189
|
}
|
|
154
190
|
});
|
|
155
191
|
const parsed = parser.parse_args(args);
|
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.26\",\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\": \"tsx --test test/*.test.ts\"\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.705.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.0\",\n \"@langchain/core\": \"^0.3.20\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.12.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.10.1\",\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.15.0\",\n \"langchain\": \"^0.3.6\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.75.0\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.2\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.12.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.28.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.28.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.28.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.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.4\",\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.4\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.0\",\n \"uuid\": \"^11.0.3\"\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,UAAY;AAAA,QACV;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACA,QAAU;AAAA,MACV,SAAW;AAAA,MACX,MAAQ;AAAA,QACN,KAAO;AAAA,MACT;AAAA,MACA,UAAY;AAAA,MACZ,iBAAmB;AAAA,QACjB,qBAAqB;AAAA,QACrB,mCAAmC;AAAA,QACnC,iBAAiB;AAAA,QACjB,4BAA4B;A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M,SAAS,IAAI,eAAe;AAAA,IAChC,MAAM;AAAA,IACN,aAAa;AAAA,EACf,CAAC;AAED,SAAO,aAAa,MAAM,aAAa,EAAE,QAAQ,WAAW,SAAS,MAAM,QAAQ,CAAC;AAEpF,QAAM,aAAa,OAAO,eAAe;AAAA,IACvC,OAAO;AAAA,IACP,MAAM;AAAA,EACR,CAAC;AAED,QAAM,cAAc,WAAW,WAAW,QAAQ;AAAA,IAChD,aAAa;AAAA,EACf,CAAC;AAED,cAAY,aAAa,QAAQ;AAAA,IAC/B,MAAM;AAAA,EACR,CAAC;AAED,cAAY,aAAa;AAAA,IACvB,MAAM,OAAOA,UAAc;AAEzB,YAAM,eAAe;AAAA,QACnB,aAAa,CAACA,MAAK,IAAI;AAAA,QACvB,SAAS;AAAA,QACT,OAAO;AAAA;AAAA,QACP,UAAU;AAAA,QACV,QAAQ;AAAA,QACR,UAAU,CAAC,gBAAgB;AAAA,MAC7B;AAEA,YAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,UAAI,CAAC,OAAO,aAAa;AACvB,gBAAQ,MAAM,4CAA4C;AAC1D,gBAAQ,KAAK,CAAC;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":["args"]}
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.27\",\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\": \"tsx --test test/*.test.ts\"\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.705.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.0\",\n \"@langchain/core\": \"^0.3.20\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.12.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.10.1\",\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.15.0\",\n \"langchain\": \"^0.3.6\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.75.0\",\n \"tsup\": \"^8.3.5\",\n \"tsx\": \"^4.19.2\",\n \"typescript\": \"^5.7.2\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.12.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.28.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.28.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.28.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.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.4\",\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.4\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.0\",\n \"glob\": \"^11.0.0\",\n \"uuid\": \"^11.0.3\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\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. Use `lmnr <subcommand> --help` for more information.\",\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 parserEval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n help: \"Run an evaluation\",\n });\n\n parserEval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run. If no file is provided, \" +\n \"the evaluation will run all `*.eval.ts|js` files in the `evals` directory.\",\n nargs: \"?\",\n });\n\n parserEval.add_argument(\"--fail-on-error\", {\n help: \"Fail on error. If specified, will fail if encounters a file that cannot be run\",\n action: \"store_true\",\n });\n\n parserEval.set_defaults({\n func: async (args: any) => {\n const files = args.file\n ? [args.file]\n : glob.sync('evals/**/*.eval.{ts,js}')\n\n files.sort();\n\n if (files.length === 0) {\n console.error(\"No evaluation files found. Please provide a file or \" +\n \"ensure there are files in the `evals` directory.\");\n process.exit(1);\n }\n\n if (!args.file) {\n console.log(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n console.log(`Loading ${file}...`);\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [file],\n outfile: `tmp_out_${file}.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 if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\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 if (!evaluation?.run) {\n console.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\n // @ts-ignore\n await evaluation.run();\n }\n }\n });\n\n parser.set_defaults({\n func: async (args: any) => {\n parser.print_help();\n process.exit(0);\n }\n });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@ -420,7 +420,7 @@ declare class Laminar {
|
|
|
420
420
|
*
|
|
421
421
|
* @throws {Error} - If project API key is not set
|
|
422
422
|
*/
|
|
423
|
-
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider,
|
|
423
|
+
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider, }: LaminarInitializeProps): void;
|
|
424
424
|
/**
|
|
425
425
|
* Check if Laminar has been initialized. Utility to make sure other methods
|
|
426
426
|
* are called after initialization.
|
package/dist/index.d.ts
CHANGED
|
@@ -420,7 +420,7 @@ declare class Laminar {
|
|
|
420
420
|
*
|
|
421
421
|
* @throws {Error} - If project API key is not set
|
|
422
422
|
*/
|
|
423
|
-
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider,
|
|
423
|
+
static initialize({ projectApiKey, env, baseUrl, httpPort, grpcPort, instrumentModules, useExternalTracerProvider, }: LaminarInitializeProps): void;
|
|
424
424
|
/**
|
|
425
425
|
* Check if Laminar has been initialized. Utility to make sure other methods
|
|
426
426
|
* are called after initialization.
|
package/dist/index.js
CHANGED
|
@@ -356,7 +356,7 @@ var forceFlush = async () => {
|
|
|
356
356
|
// src/sdk/configuration/index.ts
|
|
357
357
|
var import_api3 = require("@opentelemetry/api");
|
|
358
358
|
var _configuration;
|
|
359
|
-
var
|
|
359
|
+
var initializeTracing = (options) => {
|
|
360
360
|
if (_configuration) {
|
|
361
361
|
return;
|
|
362
362
|
}
|
|
@@ -641,8 +641,7 @@ var Laminar = class {
|
|
|
641
641
|
httpPort,
|
|
642
642
|
grpcPort,
|
|
643
643
|
instrumentModules,
|
|
644
|
-
useExternalTracerProvider
|
|
645
|
-
_spanProcessor: _spanProcessor2
|
|
644
|
+
useExternalTracerProvider
|
|
646
645
|
}) {
|
|
647
646
|
let key = projectApiKey ?? process.env.LMNR_PROJECT_API_KEY;
|
|
648
647
|
if (key === void 0) {
|
|
@@ -666,18 +665,12 @@ var Laminar = class {
|
|
|
666
665
|
url: this.baseGrpcUrl,
|
|
667
666
|
metadata
|
|
668
667
|
});
|
|
669
|
-
|
|
670
|
-
console.warn(
|
|
671
|
-
"Laminar using a custom span processor. This feature is added for tests only. Any use of this feature outside of tests is not supported and advised against."
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
initialize({
|
|
668
|
+
initializeTracing({
|
|
675
669
|
exporter,
|
|
676
670
|
silenceInitializationMessage: true,
|
|
677
671
|
instrumentModules,
|
|
678
672
|
disableBatch: false,
|
|
679
|
-
useExternalTracerProvider
|
|
680
|
-
processor: _spanProcessor2
|
|
673
|
+
useExternalTracerProvider
|
|
681
674
|
});
|
|
682
675
|
}
|
|
683
676
|
/**
|