@lmnr-ai/lmnr 0.4.34 → 0.4.35

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.
@@ -7,7 +7,7 @@ on:
7
7
  - main
8
8
 
9
9
  jobs:
10
- run-tests:
10
+ build:
11
11
  runs-on: ubuntu-latest
12
12
  steps:
13
13
  - uses: actions/checkout@v4
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.34",
39
+ version: "0.4.35",
40
40
  description: "TypeScript SDK for Laminar AI",
41
41
  main: "dist/index.js",
42
42
  types: "dist/index.d.ts",
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.34\",\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.33.1\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.716.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.2\",\n \"@langchain/core\": \"^0.3.26\",\n \"@pinecone-database/pinecone\": \"^4.0.0\",\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.2\",\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.8\",\n \"llamaindex\": \"^0.8.30\",\n \"openai\": \"^4.77.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.5\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.0\",\n \"@opentelemetry/instrumentation\": \"^0.57.0\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/sdk-node\": \"^0.57.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.6\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.6\",\n \"@traceloop/instrumentation-azure\": \"^0.11.6\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.6\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.6\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.6\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.6\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.6\",\n \"@traceloop/instrumentation-openai\": \"^0.11.6\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.6\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.6\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.6\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.2\",\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\";\nimport { context, trace, propagation } from \"@opentelemetry/api\";\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 // FIXME: Now every evaluation file creates a new tracer provider.\n // Attempt to re-initialize it in the same process breaks it.\n // For now, we disable all APIs after running each file, but ideally\n // we should keep a global tracer provider that is initialized once\n // here in the CLI.\n context.disable();\n trace.disable();\n propagation.disable();\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,O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nr-ai/lmnr\",\n \"version\": \"0.4.35\",\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.33.1\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.716.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.2\",\n \"@langchain/core\": \"^0.3.26\",\n \"@pinecone-database/pinecone\": \"^4.0.0\",\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.2\",\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.8\",\n \"llamaindex\": \"^0.8.30\",\n \"openai\": \"^4.77.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.5\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.0\",\n \"@opentelemetry/instrumentation\": \"^0.57.0\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/sdk-node\": \"^0.57.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.6\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.6\",\n \"@traceloop/instrumentation-azure\": \"^0.11.6\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.6\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.6\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.6\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.6\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.6\",\n \"@traceloop/instrumentation-openai\": \"^0.11.6\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.6\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.6\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.6\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.2\",\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\";\nimport { context, trace, propagation } from \"@opentelemetry/api\";\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 // FIXME: Now every evaluation file creates a new tracer provider.\n // Attempt to re-initialize it in the same process breaks it.\n // For now, we disable all APIs after running each file, but ideally\n // we should keep a global tracer provider that is initialized once\n // here in the CLI.\n context.disable();\n trace.disable();\n propagation.disable();\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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AO,YAAY,CAAC,EAAE;AAE7C,cAAM,aAAa,WAAW;AAAA,UAC5B,UAAUA,MAAK;AAAA,UACf,YAAY;AAAA,QACd,CAAC;AAGD,YAAI,CAAC,YAAY,KAAK;AACpB,kBAAQ,MAAM,cAAc,IAAI,oCAAoC;AACpE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAGA,cAAM,WAAW,IAAI;AAOrB,2BAAQ,QAAQ;AAChB,yBAAM,QAAQ;AACd,+BAAY,QAAQ;AAAA,MACtB;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.34",
18
+ version: "0.4.35",
19
19
  description: "TypeScript SDK for Laminar AI",
20
20
  main: "dist/index.js",
21
21
  types: "dist/index.d.ts",
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.34\",\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.33.1\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.716.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.2\",\n \"@langchain/core\": \"^0.3.26\",\n \"@pinecone-database/pinecone\": \"^4.0.0\",\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.2\",\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.8\",\n \"llamaindex\": \"^0.8.30\",\n \"openai\": \"^4.77.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.5\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.0\",\n \"@opentelemetry/instrumentation\": \"^0.57.0\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/sdk-node\": \"^0.57.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.6\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.6\",\n \"@traceloop/instrumentation-azure\": \"^0.11.6\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.6\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.6\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.6\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.6\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.6\",\n \"@traceloop/instrumentation-openai\": \"^0.11.6\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.6\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.6\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.6\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.2\",\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\";\nimport { context, trace, propagation } from \"@opentelemetry/api\";\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 // FIXME: Now every evaluation file creates a new tracer provider.\n // Attempt to re-initialize it in the same process breaks it.\n // For now, we disable all APIs after running each file, but ideally\n // we should keep a global tracer provider that is initialized once\n // here in the CLI.\n context.disable();\n trace.disable();\n propagation.disable();\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;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;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;AAAA,QACV,MAAQ;AAAA,QACR,KAAO;AAAA,QACP,YAAc;AAAA,MAChB;AAAA,MACA,cAAgB;AAAA,QACd,iBAAiB;AAAA,QACjB,sBAAsB;AAAA,QACtB,uBAAuB;AAAA,QACvB,2CAA2C;AAAA,QAC3C,4CAA4C;AAAA,QAC5C,k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;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":["args"]}
1
+ {"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.35\",\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.33.1\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.716.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@google-cloud/aiplatform\": \"^3.34.0\",\n \"@google-cloud/vertexai\": \"^1.9.2\",\n \"@langchain/core\": \"^0.3.26\",\n \"@pinecone-database/pinecone\": \"^4.0.0\",\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.2\",\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.8\",\n \"llamaindex\": \"^0.8.30\",\n \"openai\": \"^4.77.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.5\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.0\",\n \"@opentelemetry/instrumentation\": \"^0.57.0\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.0\",\n \"@opentelemetry/sdk-node\": \"^0.57.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.28.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.6\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.6\",\n \"@traceloop/instrumentation-azure\": \"^0.11.6\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.6\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.6\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.6\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.6\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.6\",\n \"@traceloop/instrumentation-openai\": \"^0.11.6\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.6\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.6\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.6\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.24.2\",\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\";\nimport { context, trace, propagation } from \"@opentelemetry/api\";\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 // FIXME: Now every evaluation file creates a new tracer provider.\n // Attempt to re-initialize it in the same process breaks it.\n // For now, we disable all APIs after running each file, but ideally\n // we should keep a global tracer provider that is initialized once\n // here in the CLI.\n context.disable();\n trace.disable();\n propagation.disable();\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;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;A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ACR,UAAU,CAAC,gBAAgB;AAAA,QAC7B;AAEA,cAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,YAAI,CAAC,OAAO,aAAa;AACvB,kBAAQ,MAAM,4CAA4C;AAC1D,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAEA,cAAM,iBAAiB,OAAO,YAAY,CAAC,EAAE;AAE7C,cAAM,aAAa,WAAW;AAAA,UAC5B,UAAUA,MAAK;AAAA,UACf,YAAY;AAAA,QACd,CAAC;AAGD,YAAI,CAAC,YAAY,KAAK;AACpB,kBAAQ,MAAM,cAAc,IAAI,oCAAoC;AACpE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAGA,cAAM,WAAW,IAAI;AAOrB,gBAAQ,QAAQ;AAChB,cAAM,QAAQ;AACd,oBAAY,QAAQ;AAAA,MACtB;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":["args"]}
package/dist/index.d.mts CHANGED
@@ -406,8 +406,6 @@ declare class Laminar {
406
406
  private static projectApiKey;
407
407
  private static env;
408
408
  private static isInitialized;
409
- private static disableBatch;
410
- private static spanIdsToPaths;
411
409
  /**
412
410
  * Initialize Laminar context across the application.
413
411
  * This method must be called before using any other Laminar methods or decorators.
package/dist/index.d.ts CHANGED
@@ -406,8 +406,6 @@ declare class Laminar {
406
406
  private static projectApiKey;
407
407
  private static env;
408
408
  private static isInitialized;
409
- private static disableBatch;
410
- private static spanIdsToPaths;
411
409
  /**
412
410
  * Initialize Laminar context across the application.
413
411
  * This method must be called before using any other Laminar methods or decorators.
package/dist/index.js CHANGED
@@ -262,7 +262,15 @@ var manuallyInitInstrumentations = (instrumentModules) => {
262
262
  qdrantInstrumentation.manuallyInstrument(instrumentModules.qdrant);
263
263
  }
264
264
  };
265
- var NEXT_JS_SPAN_ATTRIBUTES = ["next.span_name", "next.span_type", "next.clientComponentLoadCount", "next.page", "next.rsc", "next.route", "next.segment"];
265
+ var NEXT_JS_SPAN_ATTRIBUTES = [
266
+ "next.span_name",
267
+ "next.span_type",
268
+ "next.clientComponentLoadCount",
269
+ "next.page",
270
+ "next.rsc",
271
+ "next.route",
272
+ "next.segment"
273
+ ];
266
274
  var isNextJsSpan = (span) => {
267
275
  return NEXT_JS_SPAN_ATTRIBUTES.some((attr) => span.attributes[attr] !== void 0);
268
276
  };
@@ -316,9 +324,10 @@ var startTracing = (options) => {
316
324
  const originalOnStart = _spanProcessor.onStart.bind(_spanProcessor);
317
325
  _spanProcessor.onStart = (span, parentContext) => {
318
326
  const contextSpanPath = getSpanPath(parentContext ?? import_api2.context.active());
319
- const currentSpanPath = contextSpanPath ?? (span.parentSpanId !== void 0 ? _spanIdToPath.get(span.parentSpanId) : void 0);
320
- const spanPath = currentSpanPath ? `${currentSpanPath}.${span.name}` : span.name;
327
+ const parentSpanPath = contextSpanPath ?? (span.parentSpanId !== void 0 ? _spanIdToPath.get(span.parentSpanId) : void 0);
328
+ const spanPath = parentSpanPath ? [...parentSpanPath, span.name] : [span.name];
321
329
  span.setAttribute(SPAN_PATH, spanPath);
330
+ import_api2.context.active().setValue(SPAN_PATH_KEY, spanPath);
322
331
  const spanId = span.spanContext().spanId;
323
332
  _spanIdToPath.set(spanId, spanPath);
324
333
  span.setAttribute(SPAN_INSTRUMENTATION_SOURCE, "javascript");
@@ -708,7 +717,7 @@ var Laminar = class {
708
717
  const metadata = new import_grpc_js.Metadata();
709
718
  metadata.set("authorization", `Bearer ${this.projectApiKey}`);
710
719
  const exporter = new import_exporter_trace_otlp_grpc.OTLPTraceExporter({
711
- url: this.baseGrpcUrl,
720
+ url: `${this.baseGrpcUrl}`,
712
721
  metadata,
713
722
  // default is 10 seconds, increase to 30 seconds
714
723
  timeoutMillis: traceExportTimeoutMillis ?? 3e4
@@ -1164,8 +1173,6 @@ var Laminar = class {
1164
1173
  };
1165
1174
  Laminar.env = {};
1166
1175
  Laminar.isInitialized = false;
1167
- Laminar.disableBatch = false;
1168
- Laminar.spanIdsToPaths = /* @__PURE__ */ new Map();
1169
1176
 
1170
1177
  // src/evaluations.ts
1171
1178
  var import_cli_progress = __toESM(require("cli-progress"));