@lmnr-ai/lmnr 0.5.1 → 0.5.2
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/README.md +0 -47
- package/dist/cli.d.mts +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/{evaluations-D6I5jWO6.d.mts → evaluations-Bu7nHmvf.d.mts} +113 -65
- package/dist/{evaluations-D6I5jWO6.d.ts → evaluations-Bu7nHmvf.d.ts} +113 -65
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +129 -172
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +88 -131
- package/dist/index.mjs.map +1 -1
- package/package.json +17 -17
package/README.md
CHANGED
|
@@ -142,53 +142,6 @@ You can run evaluations locally by providing executor (part of the logic used in
|
|
|
142
142
|
|
|
143
143
|
[Read docs](https://docs.lmnr.ai/evaluations/introduction) to learn more about evaluations.
|
|
144
144
|
|
|
145
|
-
## Laminar pipelines as prompt chain managers
|
|
146
|
-
|
|
147
|
-
You can create Laminar pipelines in the UI and manage chains of LLM calls there.
|
|
148
|
-
|
|
149
|
-
After you are ready to use your pipeline in your code, deploy it in Laminar by selecting the target version for the pipeline.
|
|
150
|
-
|
|
151
|
-
Once your pipeline target is set, you can call it from Python in just a few lines.
|
|
152
|
-
Example use:
|
|
153
|
-
|
|
154
|
-
```typescript
|
|
155
|
-
import { Laminar } from '@lmnr-ai/lmnr';
|
|
156
|
-
|
|
157
|
-
const l = new Laminar('<YOUR_PROJECT_API_KEY>');
|
|
158
|
-
const result = await l.run({
|
|
159
|
-
pipeline: 'my_pipeline_name',
|
|
160
|
-
inputs: {'input': [{'role': 'user', 'content': 'hello'}]},
|
|
161
|
-
env: {'OPENAI_API_KEY': 'sk-some-key'}, // optional
|
|
162
|
-
metadata: {'metadata_key': 'metadata_value'}, // optional
|
|
163
|
-
});
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Resulting in:
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
> console.log(result)
|
|
170
|
-
{
|
|
171
|
-
outputs: { output: { value: { role: 'user', content: 'hello' } } },
|
|
172
|
-
runId: '05383a95-d316-4091-a64b-06c54d12982a'
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
## Semantic search
|
|
177
|
-
|
|
178
|
-
You can perform a semantic search on a dataset using the `semanticSearch` method.
|
|
179
|
-
|
|
180
|
-
```typescript
|
|
181
|
-
import { Laminar } from '@lmnr-ai/lmnr';
|
|
182
|
-
|
|
183
|
-
const l = new Laminar('<YOUR_PROJECT_API_KEY>');
|
|
184
|
-
const result = await l.semanticSearch({
|
|
185
|
-
query: 'hello',
|
|
186
|
-
datasetId: 'my_dataset_id',
|
|
187
|
-
});
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
[Read docs](https://docs.lmnr.ai/datasets/indexing#searching) to learn more about semantic search.
|
|
191
|
-
|
|
192
145
|
## Client for HTTP operations
|
|
193
146
|
|
|
194
147
|
Various interactions with Laminar [API](https://docs.lmnr.ai/api-reference/) are available in `LaminarClient`
|
package/dist/cli.d.mts
CHANGED
package/dist/cli.d.ts
CHANGED
package/dist/cli.js
CHANGED
|
@@ -42,7 +42,7 @@ var import_pino = __toESM(require("pino"));
|
|
|
42
42
|
var import_pino_pretty = __toESM(require("pino-pretty"));
|
|
43
43
|
|
|
44
44
|
// package.json
|
|
45
|
-
var version = "0.5.
|
|
45
|
+
var version = "0.5.2";
|
|
46
46
|
|
|
47
47
|
// src/cli.ts
|
|
48
48
|
var logger = (0, import_pino.default)((0, import_pino_pretty.default)({
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\n\nimport { context, propagation, trace } from \"@opentelemetry/api\";\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\nimport pino from \"pino\";\nimport pinoPretty from \"pino-pretty\";\n\nimport { version } from \"../package.json\";\nimport { Evaluation } from \"./evaluations\";\n\nconst logger = pino(pinoPretty({\n colorize: true,\n minimumLevel: \"info\",\n}));\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _evaluation: Evaluation<any, any, any> | undefined;\n // eslint-disable-next-line no-var\n var _set_global_evaluation: boolean;\n}\n\nexport function loadModule({\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any> {\n globalThis._evaluation = undefined;\n globalThis._set_global_evaluation = true;\n\n // it needs \"require\" to be passed in\n // eslint-disable-next-line\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\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 });\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 logger.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 logger.info(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n logger.info(`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 logger.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 if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\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: () => {\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().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n","{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.5.1\",\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 --external puppeteer --external puppeteer-core --external playwright\",\n \"test\": \"tsx --test test/*.test.ts\",\n \"lint\": \"eslint\",\n \"lint:fix\": \"eslint --fix\"\n },\n \"files\": [\n \"dist\",\n \"assets\"\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.39.0\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.785.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@browserbasehq/stagehand\": \"^1.14.0\",\n \"@eslint/eslintrc\": \"^3.3.1\",\n \"@eslint/js\": \"^9.24.0\",\n \"@google-cloud/aiplatform\": \"^4.1.0\",\n \"@google-cloud/vertexai\": \"^1.9.3\",\n \"@langchain/core\": \"^0.3.44\",\n \"@pinecone-database/pinecone\": \"^5.1.1\",\n \"@playwright/test\": \"^1.51.1\",\n \"@qdrant/js-client-rest\": \"^1.13.0\",\n \"@stylistic/eslint-plugin-js\": \"^4.2.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.14.0\",\n \"@types/semver\": \"^7.7.0\",\n \"@types/uuid\": \"^10.0.0\",\n \"chromadb\": \"^2.2.0\",\n \"cohere-ai\": \"^7.16.0\",\n \"eslint-plugin-simple-import-sort\": \"^12.1.1\",\n \"eslint-plugin-unused-imports\": \"^4.1.4\",\n \"langchain\": \"^0.3.21\",\n \"llamaindex\": \"^0.9.17\",\n \"openai\": \"^4.93.0\",\n \"playwright\": \"^1.51.1\",\n \"puppeteer\": \"^24.6.0\",\n \"puppeteer-core\": \"^24.6.0\",\n \"together-ai\": \"^0.14.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"typescript-eslint\": \"^8.29.1\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.13.2\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.1\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.2\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.2\",\n \"@opentelemetry/instrumentation\": \"^0.57.2\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/sdk-node\": \"^0.57.2\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.1\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.30.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.12.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.12.0\",\n \"@traceloop/instrumentation-azure\": \"^0.12.0\",\n \"@traceloop/instrumentation-bedrock\": \"^0.12.0\",\n \"@traceloop/instrumentation-chromadb\": \"^0.12.0\",\n \"@traceloop/instrumentation-cohere\": \"^0.12.0\",\n \"@traceloop/instrumentation-langchain\": \"^0.12.0\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.12.0\",\n \"@traceloop/instrumentation-openai\": \"^0.12.0\",\n \"@traceloop/instrumentation-pinecone\": \"^0.12.0\",\n \"@traceloop/instrumentation-qdrant\": \"^0.12.0\",\n \"@traceloop/instrumentation-together\": \"^0.12.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.12.0\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.25.2\",\n \"glob\": \"^11.0.1\",\n \"pino\": \"^9.6.0\",\n \"pino-pretty\": \"^13.0.0\",\n \"uuid\": \"^11.1.0\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA4C;AAC5C,sBAA+B;AAC/B,cAAyB;AAC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EhC,cAAM,eAAe;AAAA,UACnB,aAAa,CAAC,IAAI;AAAA,UAClB,SAAS,WAAW,IAAI;AAAA,UACxB,OAAO;AAAA;AAAA,UACP,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,UAAU,CAAC,gBAAgB;AAAA,QAC7B;AAEA,cAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,YAAI,CAAC,OAAO,aAAa;AACvB,iBAAO,MAAM,4CAA4C;AACzD,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;AAED,YAAI,CAAC,YAAY,KAAK;AACpB,iBAAO,MAAM,cAAc,IAAI,oCAAoC;AACnE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAEA,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,MAAM;AACV,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,EAAE,MAAM,CAAC,QAAQ;AACnB,SAAO,MAAM,GAAG;AAChB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["pino","pinoPretty","args"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\n\nimport { context, propagation, trace } from \"@opentelemetry/api\";\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\nimport pino from \"pino\";\nimport pinoPretty from \"pino-pretty\";\n\nimport { version } from \"../package.json\";\nimport { Evaluation } from \"./evaluations\";\n\nconst logger = pino(pinoPretty({\n colorize: true,\n minimumLevel: \"info\",\n}));\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _evaluation: Evaluation<any, any, any> | undefined;\n // eslint-disable-next-line no-var\n var _set_global_evaluation: boolean;\n}\n\nexport function loadModule({\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any> {\n globalThis._evaluation = undefined;\n globalThis._set_global_evaluation = true;\n\n // it needs \"require\" to be passed in\n // eslint-disable-next-line\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\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 });\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 logger.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 logger.info(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n logger.info(`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 logger.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 if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\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: () => {\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().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n","{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.5.2\",\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 --external puppeteer --external puppeteer-core --external playwright\",\n \"test\": \"tsx --test test/*.test.ts\",\n \"lint\": \"eslint\",\n \"lint:fix\": \"eslint --fix\"\n },\n \"files\": [\n \"dist\",\n \"assets\"\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.39.0\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.787.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@browserbasehq/stagehand\": \"^1.14.0\",\n \"@eslint/eslintrc\": \"^3.3.1\",\n \"@eslint/js\": \"^9.25.0\",\n \"@google-cloud/aiplatform\": \"^4.1.0\",\n \"@google-cloud/vertexai\": \"^1.9.3\",\n \"@langchain/core\": \"^0.3.45\",\n \"@pinecone-database/pinecone\": \"^5.1.1\",\n \"@playwright/test\": \"^1.52.0\",\n \"@qdrant/js-client-rest\": \"^1.13.0\",\n \"@stylistic/eslint-plugin-js\": \"^4.2.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.14.1\",\n \"@types/semver\": \"^7.7.0\",\n \"@types/uuid\": \"^10.0.0\",\n \"chromadb\": \"^2.2.1\",\n \"cohere-ai\": \"^7.17.1\",\n \"eslint-plugin-simple-import-sort\": \"^12.1.1\",\n \"eslint-plugin-unused-imports\": \"^4.1.4\",\n \"langchain\": \"^0.3.23\",\n \"llamaindex\": \"^0.9.19\",\n \"openai\": \"^4.95.1\",\n \"playwright\": \"^1.52.0\",\n \"puppeteer\": \"^24.6.1\",\n \"puppeteer-core\": \"^24.6.1\",\n \"together-ai\": \"^0.14.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"typescript-eslint\": \"^8.30.1\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.13.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.1\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.2\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.2\",\n \"@opentelemetry/instrumentation\": \"^0.57.2\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/sdk-node\": \"^0.57.2\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.1\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.32.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.12.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.12.0\",\n \"@traceloop/instrumentation-azure\": \"^0.12.0\",\n \"@traceloop/instrumentation-bedrock\": \"^0.12.0\",\n \"@traceloop/instrumentation-chromadb\": \"^0.12.0\",\n \"@traceloop/instrumentation-cohere\": \"^0.12.0\",\n \"@traceloop/instrumentation-langchain\": \"^0.12.0\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.12.0\",\n \"@traceloop/instrumentation-openai\": \"^0.12.0\",\n \"@traceloop/instrumentation-pinecone\": \"^0.12.0\",\n \"@traceloop/instrumentation-qdrant\": \"^0.12.0\",\n \"@traceloop/instrumentation-together\": \"^0.12.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.12.0\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.25.2\",\n \"glob\": \"^11.0.1\",\n \"pino\": \"^9.6.0\",\n \"pino-pretty\": \"^13.0.0\",\n \"uuid\": \"^11.1.0\"\n }\n}"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAA4C;AAC5C,sBAA+B;AAC/B,cAAyB;AACzB,WAAsB;AACtB,kBAAiB;AACjB,yBAAuB;;;ACLrB,cAAW;;;ADUb,IAA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AW,IAAI;AAAA,UACxB,OAAO;AAAA;AAAA,UACP,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,UAAU,CAAC,gBAAgB;AAAA,QAC7B;AAEA,cAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,YAAI,CAAC,OAAO,aAAa;AACvB,iBAAO,MAAM,4CAA4C;AACzD,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;AAED,YAAI,CAAC,YAAY,KAAK;AACpB,iBAAO,MAAM,cAAc,IAAI,oCAAoC;AACnE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAEA,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,MAAM;AACV,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,EAAE,MAAM,CAAC,QAAQ;AACnB,SAAO,MAAM,GAAG;AAChB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["pino","pinoPretty","args"]}
|
package/dist/cli.mjs
CHANGED
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\n\nimport { context, propagation, trace } from \"@opentelemetry/api\";\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\nimport pino from \"pino\";\nimport pinoPretty from \"pino-pretty\";\n\nimport { version } from \"../package.json\";\nimport { Evaluation } from \"./evaluations\";\n\nconst logger = pino(pinoPretty({\n colorize: true,\n minimumLevel: \"info\",\n}));\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _evaluation: Evaluation<any, any, any> | undefined;\n // eslint-disable-next-line no-var\n var _set_global_evaluation: boolean;\n}\n\nexport function loadModule({\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any> {\n globalThis._evaluation = undefined;\n globalThis._set_global_evaluation = true;\n\n // it needs \"require\" to be passed in\n // eslint-disable-next-line\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\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 });\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 logger.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 logger.info(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n logger.info(`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 logger.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 if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\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: () => {\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().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n","{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.5.1\",\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 --external puppeteer --external puppeteer-core --external playwright\",\n \"test\": \"tsx --test test/*.test.ts\",\n \"lint\": \"eslint\",\n \"lint:fix\": \"eslint --fix\"\n },\n \"files\": [\n \"dist\",\n \"assets\"\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.39.0\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.785.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@browserbasehq/stagehand\": \"^1.14.0\",\n \"@eslint/eslintrc\": \"^3.3.1\",\n \"@eslint/js\": \"^9.24.0\",\n \"@google-cloud/aiplatform\": \"^4.1.0\",\n \"@google-cloud/vertexai\": \"^1.9.3\",\n \"@langchain/core\": \"^0.3.44\",\n \"@pinecone-database/pinecone\": \"^5.1.1\",\n \"@playwright/test\": \"^1.51.1\",\n \"@qdrant/js-client-rest\": \"^1.13.0\",\n \"@stylistic/eslint-plugin-js\": \"^4.2.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.14.0\",\n \"@types/semver\": \"^7.7.0\",\n \"@types/uuid\": \"^10.0.0\",\n \"chromadb\": \"^2.2.0\",\n \"cohere-ai\": \"^7.16.0\",\n \"eslint-plugin-simple-import-sort\": \"^12.1.1\",\n \"eslint-plugin-unused-imports\": \"^4.1.4\",\n \"langchain\": \"^0.3.21\",\n \"llamaindex\": \"^0.9.17\",\n \"openai\": \"^4.93.0\",\n \"playwright\": \"^1.51.1\",\n \"puppeteer\": \"^24.6.0\",\n \"puppeteer-core\": \"^24.6.0\",\n \"together-ai\": \"^0.14.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"typescript-eslint\": \"^8.29.1\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.13.2\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.1\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.2\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.2\",\n \"@opentelemetry/instrumentation\": \"^0.57.2\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/sdk-node\": \"^0.57.2\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.1\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.30.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.12.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.12.0\",\n \"@traceloop/instrumentation-azure\": \"^0.12.0\",\n \"@traceloop/instrumentation-bedrock\": \"^0.12.0\",\n \"@traceloop/instrumentation-chromadb\": \"^0.12.0\",\n \"@traceloop/instrumentation-cohere\": \"^0.12.0\",\n \"@traceloop/instrumentation-langchain\": \"^0.12.0\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.12.0\",\n \"@traceloop/instrumentation-openai\": \"^0.12.0\",\n \"@traceloop/instrumentation-pinecone\": \"^0.12.0\",\n \"@traceloop/instrumentation-qdrant\": \"^0.12.0\",\n \"@traceloop/instrumentation-together\": \"^0.12.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.12.0\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.25.2\",\n \"glob\": \"^11.0.1\",\n \"pino\": \"^9.6.0\",\n \"pino-pretty\": \"^13.0.0\",\n \"uuid\": \"^11.1.0\"\n }\n}"],"mappings":";;;;;;;;;AAEA,SAAS,SAAS,aAAa,aAAa;AAC5C,SAAS,sBAAsB;AAC/B,YAAY,aAAa;AACzB,YAAY,UAAU;AACtB,OAAO,UAAU;AACjB,OAAO,gBAAgB;;;ACLrB,cAAW;;;ADUb,IAAM,SAAS,KAAK,W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;AAAA,UACP,UAAU;AAAA,UACV,QAAQ;AAAA,UACR,UAAU,CAAC,gBAAgB;AAAA,QAC7B;AAEA,cAAM,SAAS,MAAc,cAAM,YAAY;AAE/C,YAAI,CAAC,OAAO,aAAa;AACvB,iBAAO,MAAM,4CAA4C;AACzD,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;AAED,YAAI,CAAC,YAAY,KAAK;AACpB,iBAAO,MAAM,cAAc,IAAI,oCAAoC;AACnE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAEA,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,MAAM;AACV,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,EAAE,MAAM,CAAC,QAAQ;AACnB,SAAO,MAAM,GAAG;AAChB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["args"]}
|
|
1
|
+
{"version":3,"sources":["../src/cli.ts","../package.json"],"sourcesContent":["#!/usr/bin/env node\n\nimport { context, propagation, trace } from \"@opentelemetry/api\";\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\nimport * as glob from \"glob\";\nimport pino from \"pino\";\nimport pinoPretty from \"pino-pretty\";\n\nimport { version } from \"../package.json\";\nimport { Evaluation } from \"./evaluations\";\n\nconst logger = pino(pinoPretty({\n colorize: true,\n minimumLevel: \"info\",\n}));\n\ndeclare global {\n // eslint-disable-next-line no-var\n var _evaluation: Evaluation<any, any, any> | undefined;\n // eslint-disable-next-line no-var\n var _set_global_evaluation: boolean;\n}\n\nexport function loadModule({\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}): Evaluation<any, any, any> {\n globalThis._evaluation = undefined;\n globalThis._set_global_evaluation = true;\n\n // it needs \"require\" to be passed in\n // eslint-disable-next-line\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\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 });\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 logger.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 logger.info(`Located ${files.length} evaluation files in evals/`);\n }\n\n for (const file of files) {\n logger.info(`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 logger.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 if (!evaluation?.run) {\n logger.error(`Evaluation ${file} does not properly call evaluate()`);\n if (args.fail_on_error) {\n process.exit(1);\n }\n continue;\n }\n\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: () => {\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().catch((err) => {\n logger.error(err);\n process.exit(1);\n});\n","{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.5.2\",\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 --external puppeteer --external puppeteer-core --external playwright\",\n \"test\": \"tsx --test test/*.test.ts\",\n \"lint\": \"eslint\",\n \"lint:fix\": \"eslint --fix\"\n },\n \"files\": [\n \"dist\",\n \"assets\"\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.39.0\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.787.0\",\n \"@azure/openai\": \"^2.0.0\",\n \"@browserbasehq/stagehand\": \"^1.14.0\",\n \"@eslint/eslintrc\": \"^3.3.1\",\n \"@eslint/js\": \"^9.25.0\",\n \"@google-cloud/aiplatform\": \"^4.1.0\",\n \"@google-cloud/vertexai\": \"^1.9.3\",\n \"@langchain/core\": \"^0.3.45\",\n \"@pinecone-database/pinecone\": \"^5.1.1\",\n \"@playwright/test\": \"^1.52.0\",\n \"@qdrant/js-client-rest\": \"^1.13.0\",\n \"@stylistic/eslint-plugin-js\": \"^4.2.0\",\n \"@types/argparse\": \"^2.0.17\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.14.1\",\n \"@types/semver\": \"^7.7.0\",\n \"@types/uuid\": \"^10.0.0\",\n \"chromadb\": \"^2.2.1\",\n \"cohere-ai\": \"^7.17.1\",\n \"eslint-plugin-simple-import-sort\": \"^12.1.1\",\n \"eslint-plugin-unused-imports\": \"^4.1.4\",\n \"langchain\": \"^0.3.23\",\n \"llamaindex\": \"^0.9.19\",\n \"openai\": \"^4.95.1\",\n \"playwright\": \"^1.52.0\",\n \"puppeteer\": \"^24.6.1\",\n \"puppeteer-core\": \"^24.6.1\",\n \"together-ai\": \"^0.14.0\",\n \"tsup\": \"^8.4.0\",\n \"tsx\": \"^4.19.3\",\n \"typescript\": \"^5.8.3\",\n \"typescript-eslint\": \"^8.30.1\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.13.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.30.1\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.57.2\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.57.2\",\n \"@opentelemetry/instrumentation\": \"^0.57.2\",\n \"@opentelemetry/otlp-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/otlp-grpc-exporter-base\": \"^0.57.2\",\n \"@opentelemetry/sdk-node\": \"^0.57.2\",\n \"@opentelemetry/sdk-trace-base\": \"^1.30.1\",\n \"@opentelemetry/sdk-trace-node\": \"^1.30.1\",\n \"@opentelemetry/semantic-conventions\": \"^1.32.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.12.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.12.0\",\n \"@traceloop/instrumentation-azure\": \"^0.12.0\",\n \"@traceloop/instrumentation-bedrock\": \"^0.12.0\",\n \"@traceloop/instrumentation-chromadb\": \"^0.12.0\",\n \"@traceloop/instrumentation-cohere\": \"^0.12.0\",\n \"@traceloop/instrumentation-langchain\": \"^0.12.0\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.12.0\",\n \"@traceloop/instrumentation-openai\": \"^0.12.0\",\n \"@traceloop/instrumentation-pinecone\": \"^0.12.0\",\n \"@traceloop/instrumentation-qdrant\": \"^0.12.0\",\n \"@traceloop/instrumentation-together\": \"^0.12.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.12.0\",\n \"argparse\": \"^2.0.1\",\n \"cli-progress\": \"^3.12.0\",\n \"esbuild\": \"^0.25.2\",\n \"glob\": \"^11.0.1\",\n \"pino\": \"^9.6.0\",\n \"pino-pretty\": \"^13.0.0\",\n \"uuid\": \"^11.1.0\"\n }\n}"],"mappings":";;;;;;;;;AAEA,SAAS,SAAS,aAAa,aAAa;AAC5C,SAAS,sBAAsB;AAC/B,YAAY,aAAa;AACzB,YAAY,UAAU;AACtB,OAAO,UAAU;AACjB,OAAO,gBAAgB;;;ACLrB,cAAW;;;ADUb,IAAM,SAAS,KAAK,WAAW;AAAA,EAC7B,UAAU;AAAA,EACV,cAAc;AAChB,CAAC,CAAC;AASK,SAAS,WAAW;AAAA,EACzB;AACF,GAG8B;AAC5B,aAAW,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AY;AAE/C,YAAI,CAAC,OAAO,aAAa;AACvB,iBAAO,MAAM,4CAA4C;AACzD,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;AAED,YAAI,CAAC,YAAY,KAAK;AACpB,iBAAO,MAAM,cAAc,IAAI,oCAAoC;AACnE,cAAIA,MAAK,eAAe;AACtB,oBAAQ,KAAK,CAAC;AAAA,UAChB;AACA;AAAA,QACF;AAEA,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,MAAM;AACV,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,EAAE,MAAM,CAAC,QAAQ;AACnB,SAAO,MAAM,GAAG;AAChB,UAAQ,KAAK,CAAC;AAChB,CAAC;","names":["args"]}
|
|
@@ -68,15 +68,6 @@ type GetDatapointsResponse<D, T> = {
|
|
|
68
68
|
totalCount: number;
|
|
69
69
|
anyInProject: boolean;
|
|
70
70
|
};
|
|
71
|
-
type SemanticSearchResult = {
|
|
72
|
-
datasetId: StringUUID;
|
|
73
|
-
data: Record<string, any>;
|
|
74
|
-
content: string;
|
|
75
|
-
score: number;
|
|
76
|
-
};
|
|
77
|
-
type SemanticSearchResponse = {
|
|
78
|
-
results: SemanticSearchResult[];
|
|
79
|
-
};
|
|
80
71
|
/**
|
|
81
72
|
* Trace types to categorize traces.
|
|
82
73
|
* They are used as association properties passed to all spans in a trace.
|
|
@@ -129,7 +120,7 @@ declare class BaseResource {
|
|
|
129
120
|
/**
|
|
130
121
|
* Model provider options
|
|
131
122
|
*/
|
|
132
|
-
type ModelProvider =
|
|
123
|
+
type ModelProvider = 'anthropic' | 'bedrock' | 'openai' | 'gemini';
|
|
133
124
|
type ActionResult = {
|
|
134
125
|
isDone: boolean;
|
|
135
126
|
content?: string | null;
|
|
@@ -138,34 +129,63 @@ type ActionResult = {
|
|
|
138
129
|
/**
|
|
139
130
|
* Agent output type
|
|
140
131
|
*
|
|
141
|
-
* @property {string}
|
|
132
|
+
* @property {string} agentState - The state of the agent. Can be used in subsequent runs
|
|
133
|
+
* to resume the agent. Only set if returnAgentState is true. Is a very large
|
|
134
|
+
* stringified JSON object.
|
|
135
|
+
* @property {string} storageState - The storage state of the browser, including auth, cookies, etc.
|
|
136
|
+
* Only set if returnStorageState is true. Is a relatively large stringified JSON object.
|
|
142
137
|
* @property {ActionResult} result - The result of the agent run.
|
|
143
138
|
*/
|
|
144
139
|
type AgentOutput = {
|
|
145
|
-
result
|
|
140
|
+
result: ActionResult;
|
|
141
|
+
agentState?: string | null;
|
|
142
|
+
storageState?: string | null;
|
|
146
143
|
};
|
|
147
144
|
type RunAgentStepChunk = {
|
|
148
145
|
chunkType: "step";
|
|
149
146
|
messageId: StringUUID;
|
|
150
147
|
actionResult: ActionResult;
|
|
151
148
|
summary: string;
|
|
149
|
+
screenshot?: string | null;
|
|
150
|
+
};
|
|
151
|
+
type RunAgentTimeoutChunk = {
|
|
152
|
+
chunkType: "timeout";
|
|
153
|
+
messageId: StringUUID;
|
|
154
|
+
actionResult: ActionResult;
|
|
155
|
+
summary: string;
|
|
156
|
+
screenshot?: string | null;
|
|
152
157
|
};
|
|
153
158
|
type RunAgentFinalChunk = {
|
|
154
159
|
chunkType: "finalOutput";
|
|
155
160
|
messageId: StringUUID;
|
|
156
161
|
content: AgentOutput;
|
|
157
162
|
};
|
|
163
|
+
type RunAgentErrorChunk = {
|
|
164
|
+
chunkType: "error";
|
|
165
|
+
messageId: StringUUID;
|
|
166
|
+
error: string;
|
|
167
|
+
};
|
|
158
168
|
/**
|
|
159
169
|
* Chunk type for streaming responses
|
|
160
170
|
*/
|
|
161
|
-
type RunAgentResponseChunk = RunAgentStepChunk | RunAgentFinalChunk;
|
|
171
|
+
type RunAgentResponseChunk = RunAgentStepChunk | RunAgentFinalChunk | RunAgentErrorChunk | RunAgentTimeoutChunk;
|
|
162
172
|
type RunAgentOptions = {
|
|
163
173
|
prompt: string;
|
|
164
174
|
parentSpanContext?: string;
|
|
165
175
|
modelProvider?: ModelProvider;
|
|
176
|
+
agentState?: string;
|
|
177
|
+
storageState?: string;
|
|
166
178
|
model?: string;
|
|
167
179
|
stream?: boolean;
|
|
168
180
|
enableThinking?: boolean;
|
|
181
|
+
timeout?: number;
|
|
182
|
+
cdpUrl?: string;
|
|
183
|
+
maxSteps?: number;
|
|
184
|
+
thinkingTokenBudget?: number;
|
|
185
|
+
startUrl?: string;
|
|
186
|
+
returnScreenshots?: boolean;
|
|
187
|
+
returnAgentState?: boolean;
|
|
188
|
+
returnStorageState?: boolean;
|
|
169
189
|
};
|
|
170
190
|
/**
|
|
171
191
|
* Resource for interacting with Laminar agents
|
|
@@ -178,9 +198,33 @@ declare class AgentResource extends BaseResource {
|
|
|
178
198
|
* @param { RunAgentOptions } options - The options for running the agent
|
|
179
199
|
* @param { string } options.prompt - The prompt for the agent
|
|
180
200
|
* @param { string } [options.parentSpanContext] - The parent span context for tracing
|
|
181
|
-
* @param {
|
|
201
|
+
* @param { ModelProvider } [options.modelProvider] - LLM provider to use
|
|
182
202
|
* @param { string } [options.model] - The model name as specified in the provider API
|
|
183
|
-
* @param {
|
|
203
|
+
* @param { string } [options.agentState] - The agent state to resume the agent from as returned
|
|
204
|
+
* by a previous run.
|
|
205
|
+
* @param { string } [options.storageState] - The browser storage state as returned by a
|
|
206
|
+
* previous run.
|
|
207
|
+
* @param { boolean } [options.enableThinking] - Whether to enable thinking in the underlying
|
|
208
|
+
* LLM. Defaults to true.
|
|
209
|
+
* @param { number } [options.timeout] - The timeout in seconds for the agent. Note: This is a
|
|
210
|
+
* soft timeout. The agent will finish a step even after the timeout has been reached.
|
|
211
|
+
* @param { string } [options.cdpUrl] - The URL of an existing Chrome DevTools Protocol (CDP)
|
|
212
|
+
* browser instance.
|
|
213
|
+
* @param { number } [options.maxSteps] - The maximum number of steps the agent can take.
|
|
214
|
+
* Defaults to 100.
|
|
215
|
+
* @param { number } [options.thinkingTokenBudget] - The maximum number of tokens the underlying
|
|
216
|
+
* LLM can spend on thinking per step, if supported by the LLM provider.
|
|
217
|
+
* @param { string } [options.startUrl] - The URL to start the agent on. Make sure it's a
|
|
218
|
+
* valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto
|
|
219
|
+
* If not specified, the agent will infer this from the prompt.
|
|
220
|
+
* @param { boolean } [options.returnScreenshots] - IGNORED in non-streaming mode.
|
|
221
|
+
* Defaults to false. Set stream to true for doc comments.
|
|
222
|
+
* @param { boolean } [options.returnAgentState] - Whether to return the agent state.
|
|
223
|
+
* Agent state can be used to resume the agent in subsequent runs.
|
|
224
|
+
* CAUTION: Agent state is a very large object. Defaults to false.
|
|
225
|
+
* @param { boolean } [options.returnStorageState] - Whether to return the storage state.
|
|
226
|
+
* Storage state includes browser cookies, auth, etc.
|
|
227
|
+
* CAUTION: Storage state is a relatively large object. Defaults to false.
|
|
184
228
|
* @returns { Promise<AgentOutput> } The agent output
|
|
185
229
|
*/
|
|
186
230
|
run(options: Omit<RunAgentOptions, 'stream'>): Promise<AgentOutput>;
|
|
@@ -190,9 +234,34 @@ declare class AgentResource extends BaseResource {
|
|
|
190
234
|
* @param { RunAgentOptions } options - The options for running the agent
|
|
191
235
|
* @param { string } options.prompt - The prompt for the agent
|
|
192
236
|
* @param { string } [options.parentSpanContext] - The parent span context for tracing
|
|
193
|
-
* @param {
|
|
237
|
+
* @param { ModelProvider } [options.modelProvider] - LLM provider to use
|
|
194
238
|
* @param { string } [options.model] - The model name as specified in the provider API
|
|
195
|
-
* @param {
|
|
239
|
+
* @param { string } [options.agentState] - The agent state to resume the agent from as
|
|
240
|
+
* returned by a previous run.
|
|
241
|
+
* @param { string } [options.storageState] - The browser storage state as returned by a
|
|
242
|
+
* previous run.
|
|
243
|
+
* @param { boolean } [options.enableThinking] - Whether to enable thinking in the
|
|
244
|
+
* underlying LLM. Defaults to true.
|
|
245
|
+
* @param { number } [options.timeout] - The timeout in seconds for the agent.
|
|
246
|
+
* Note: This is a soft timeout. The agent will finish a step even after the timeout has
|
|
247
|
+
* been reached.
|
|
248
|
+
* @param { string } [options.cdpUrl] - The URL of an existing Chrome DevTools Protocol
|
|
249
|
+
* (CDP) browser instance.
|
|
250
|
+
* @param { number } [options.maxSteps] - The maximum number of steps the agent can take.
|
|
251
|
+
* Defaults to 100.
|
|
252
|
+
* @param { number } [options.thinkingTokenBudget] - The maximum number of tokens the
|
|
253
|
+
* underlying LLM can spend on thinking per step, if supported by the LLM provider.
|
|
254
|
+
* @param { string } [options.startUrl] - The URL to start the agent on. Make sure it's
|
|
255
|
+
* a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto
|
|
256
|
+
* If not specified, the agent will infer this from the prompt.
|
|
257
|
+
* @param { boolean } [options.returnScreenshots] - IGNORED in non-streaming mode.
|
|
258
|
+
* Defaults to false. Set stream to true for doc comments.
|
|
259
|
+
* @param { boolean } [options.returnAgentState] - Whether to return the agent state.
|
|
260
|
+
* Agent state can be used to resume the agent in subsequent runs.
|
|
261
|
+
* CAUTION: Agent state is a very large object. Defaults to false.
|
|
262
|
+
* @param { boolean } [options.returnStorageState] - Whether to return the storage state.
|
|
263
|
+
* Storage state includes browser cookies, auth, etc.
|
|
264
|
+
* CAUTION: Storage state is a relatively large object. Defaults to false.
|
|
196
265
|
* @returns { Promise<AgentOutput> } The agent output
|
|
197
266
|
*/
|
|
198
267
|
run(options: Omit<RunAgentOptions, 'stream'> & {
|
|
@@ -204,9 +273,34 @@ declare class AgentResource extends BaseResource {
|
|
|
204
273
|
* @param { RunAgentOptions } options - The options for running the agent
|
|
205
274
|
* @param { string } options.prompt - The prompt for the agent
|
|
206
275
|
* @param { string } [options.parentSpanContext] - The parent span context for tracing
|
|
207
|
-
* @param {
|
|
276
|
+
* @param { ModelProvider } [options.modelProvider] - LLM provider to use
|
|
208
277
|
* @param { string } [options.model] - The model name as specified in the provider API
|
|
209
|
-
* @param {
|
|
278
|
+
* @param { string } [options.agentState] - The agent state to resume the agent from as
|
|
279
|
+
* returned by a previous run.
|
|
280
|
+
* @param { string } [options.storageState] - The browser storage state as returned by
|
|
281
|
+
* a previous run.
|
|
282
|
+
* @param { boolean } [options.enableThinking] - Whether to enable thinking in the
|
|
283
|
+
* underlying LLM. Defaults to true.
|
|
284
|
+
* @param { number } [options.timeout] - The timeout in seconds for the agent. Note:
|
|
285
|
+
* This is a soft timeout. The agent will finish a step even after the timeout has
|
|
286
|
+
* been reached.
|
|
287
|
+
* @param { string } [options.cdpUrl] - The URL of an existing Chrome DevTools Protocol
|
|
288
|
+
* (CDP) browser instance.
|
|
289
|
+
* @param { number } [options.maxSteps] - The maximum number of steps the agent can take.
|
|
290
|
+
* Defaults to 100.
|
|
291
|
+
* @param { number } [options.thinkingTokenBudget] - The maximum number of tokens the
|
|
292
|
+
* underlying LLM can spend on thinking per step, if supported by the LLM provider.
|
|
293
|
+
* @param { string } [options.startUrl] - The URL to start the agent on. Make sure it's
|
|
294
|
+
* a valid URL - refer to https://playwright.dev/docs/api/class-page#page-goto
|
|
295
|
+
* If not specified, the agent will infer this from the prompt.
|
|
296
|
+
* @param { boolean } [options.returnScreenshots] - Whether to return screenshots with
|
|
297
|
+
* each step. Defaults to false. Set stream to true for doc comments.
|
|
298
|
+
* @param { boolean } [options.returnAgentState] - Whether to return the agent state.
|
|
299
|
+
* Agent state can be used to resume the agent in subsequent runs.
|
|
300
|
+
* CAUTION: Agent state is a very large object. Defaults to false.
|
|
301
|
+
* @param { boolean } [options.returnStorageState] - Whether to return the storage state.
|
|
302
|
+
* Storage state includes browser cookies, auth, etc.
|
|
303
|
+
* CAUTION: Storage state is a relatively large object. Defaults to false.
|
|
210
304
|
* @returns { Promise<ReadableStream<RunAgentResponseChunk>> } The agent output streamed
|
|
211
305
|
*/
|
|
212
306
|
run(options: Omit<RunAgentOptions, 'stream'> & {
|
|
@@ -271,56 +365,12 @@ declare class EvalsResource extends BaseResource {
|
|
|
271
365
|
}): Promise<GetDatapointsResponse<D, T>>;
|
|
272
366
|
}
|
|
273
367
|
|
|
274
|
-
declare class PipelineResource extends BaseResource {
|
|
275
|
-
constructor(baseHttpUrl: string, projectApiKey: string);
|
|
276
|
-
/**
|
|
277
|
-
* Run a pipeline with the given inputs and environment variables.
|
|
278
|
-
*
|
|
279
|
-
* @param {Object} options - Pipeline run options
|
|
280
|
-
* @param {string} options.pipeline - Pipeline name
|
|
281
|
-
* @param {Record<string, NodeInput>} options.inputs - Input values for the pipeline
|
|
282
|
-
* @param {Record<string, string>} [options.env] - Environment variables for the pipeline run
|
|
283
|
-
* @param {Record<string, string>} [options.metadata] - Metadata for the pipeline run
|
|
284
|
-
* @param {StringUUID} [options.currentSpanId] - Parent span id for the resulting trace
|
|
285
|
-
* @param {StringUUID} [options.currentTraceId] - Trace id for the resulting trace
|
|
286
|
-
*
|
|
287
|
-
* @throws {Error} If the project API key is not set
|
|
288
|
-
* @throws {Error} If the pipeline run fails
|
|
289
|
-
*
|
|
290
|
-
* @returns {Promise<PipelineRunResponse>} Response from the pipeline run
|
|
291
|
-
*/
|
|
292
|
-
run({ pipeline, inputs, env, metadata, currentSpanId, currentTraceId, }: PipelineRunRequest): Promise<PipelineRunResponse>;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
declare class SemanticSearchResource extends BaseResource {
|
|
296
|
-
constructor(baseHttpUrl: string, projectApiKey: string);
|
|
297
|
-
/**
|
|
298
|
-
* Perform a semantic search on the given dataset.
|
|
299
|
-
*
|
|
300
|
-
* @param {Object} options - Search options
|
|
301
|
-
* @param {string} options.query - Query to search for
|
|
302
|
-
* @param {UUID} options.datasetId - Dataset ID created in the UI
|
|
303
|
-
* @param {number} [options.limit] - Maximum number of results to return
|
|
304
|
-
* @param {number} [options.threshold] - Lowest similarity score to return
|
|
305
|
-
* @throws {Error} If an error happens while performing the semantic search
|
|
306
|
-
* @returns {Promise<SemanticSearchResponse>} Response from the semantic search
|
|
307
|
-
*/
|
|
308
|
-
search({ query, datasetId, limit, threshold, }: {
|
|
309
|
-
query: string;
|
|
310
|
-
datasetId: StringUUID;
|
|
311
|
-
limit?: number;
|
|
312
|
-
threshold?: number;
|
|
313
|
-
}): Promise<SemanticSearchResponse>;
|
|
314
|
-
}
|
|
315
|
-
|
|
316
368
|
declare class LaminarClient {
|
|
317
369
|
private baseUrl;
|
|
318
370
|
private projectApiKey;
|
|
319
371
|
private _agent;
|
|
320
372
|
private _browserEvents;
|
|
321
373
|
private _evals;
|
|
322
|
-
private _pipelines;
|
|
323
|
-
private _semanticSearch;
|
|
324
374
|
constructor({ baseUrl, projectApiKey, port, }: {
|
|
325
375
|
baseUrl?: string;
|
|
326
376
|
projectApiKey?: string;
|
|
@@ -329,8 +379,6 @@ declare class LaminarClient {
|
|
|
329
379
|
get agent(): AgentResource;
|
|
330
380
|
get browserEvents(): BrowserEventsResource;
|
|
331
381
|
get evals(): EvalsResource;
|
|
332
|
-
get pipelines(): PipelineResource;
|
|
333
|
-
get semanticSearch(): SemanticSearchResource;
|
|
334
382
|
}
|
|
335
383
|
|
|
336
384
|
declare abstract class EvaluationDataset<D, T> {
|