@lmnr-ai/lmnr 0.4.20 → 0.4.21
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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/cli.mjs.map +1 -1
- package/dist/index.d.mts +26 -2
- package/dist/index.d.ts +26 -2
- package/dist/index.js +48 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/decorators.ts +58 -0
- package/src/index.ts +1 -1
- package/src/laminar.ts +19 -2
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.21",
|
|
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.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.21\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.2\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,iBAAAA,UAAAC,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;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;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AC;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,OAAOC,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":["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.21",
|
|
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.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/cli.ts"],"sourcesContent":["{\n \"name\": \"@lmnr-ai/lmnr\",\n \"version\": \"0.4.21\",\n \"description\": \"TypeScript SDK for Laminar AI\",\n \"main\": \"dist/index.js\",\n \"types\": \"dist/index.d.ts\",\n \"scripts\": {\n \"build\": \"tsup src/index.ts src/cli.ts --format esm,cjs --dts\",\n \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n },\n \"bin\": {\n \"lmnr\": \"./dist/cli.js\"\n },\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/lmnr-ai/lmnr-ts.git\"\n },\n \"keywords\": [\n \"laminar\",\n \"lmnr\",\n \"sdk\",\n \"lmnr.ai\"\n ],\n \"author\": \"founders@lmnr.ai\",\n \"license\": \"Apache-2.0\",\n \"bugs\": {\n \"url\": \"https://github.com/lmnr-ai/lmnr-ts/issues\"\n },\n \"homepage\": \"https://github.com/lmnr-ai/lmnr-ts#README\",\n \"devDependencies\": {\n \"@anthropic-ai/sdk\": \"^0.27.3\",\n \"@aws-sdk/client-bedrock-runtime\": \"^3.679.0\",\n \"@azure/openai\": \"1.0.0-beta.13\",\n \"@google-cloud/aiplatform\": \"^3.29.0\",\n \"@google-cloud/vertexai\": \"^1.7.0\",\n \"@langchain/core\": \"^0.3.2\",\n \"@pinecone-database/pinecone\": \"^3.0.3\",\n \"@qdrant/js-client-rest\": \"^1.11.0\",\n \"@types/argparse\": \"^2.0.16\",\n \"@types/cli-progress\": \"^3.11.6\",\n \"@types/node\": \"^22.5.5\",\n \"@types/semver\": \"^7.5.8\",\n \"@types/uuid\": \"^10.0.0\",\n \"bufferutil\": \"^4.0.8\",\n \"chromadb\": \"^1.9.2\",\n \"cohere-ai\": \"^7.14.0\",\n \"langchain\": \"^0.3.2\",\n \"llamaindex\": \"^0.7.10\",\n \"openai\": \"^4.62.1\",\n \"runnables\": \"link:@langchain/core/runnables\",\n \"tsup\": \"^8.3.0\",\n \"typescript\": \"^5.6.2\",\n \"vectorstores\": \"link:@langchain/core/vectorstores\"\n },\n \"dependencies\": {\n \"@grpc/grpc-js\": \"^1.11.3\",\n \"@opentelemetry/api\": \"^1.9.0\",\n \"@opentelemetry/core\": \"^1.26.0\",\n \"@opentelemetry/exporter-trace-otlp-grpc\": \"^0.53.0\",\n \"@opentelemetry/exporter-trace-otlp-proto\": \"^0.53.0\",\n \"@opentelemetry/instrumentation\": \"^0.53.0\",\n \"@opentelemetry/sdk-node\": \"^0.53.0\",\n \"@opentelemetry/sdk-trace-base\": \"^1.26.0\",\n \"@opentelemetry/sdk-trace-node\": \"^1.26.0\",\n \"@opentelemetry/semantic-conventions\": \"^1.27.0\",\n \"@traceloop/ai-semantic-conventions\": \"^0.11.0\",\n \"@traceloop/instrumentation-anthropic\": \"^0.11.1\",\n \"@traceloop/instrumentation-azure\": \"^0.11.1\",\n \"@traceloop/instrumentation-bedrock\": \"^0.11.1\",\n \"@traceloop/instrumentation-chromadb\": \"^0.11.3\",\n \"@traceloop/instrumentation-cohere\": \"^0.11.1\",\n \"@traceloop/instrumentation-langchain\": \"^0.11.1\",\n \"@traceloop/instrumentation-llamaindex\": \"^0.11.1\",\n \"@traceloop/instrumentation-openai\": \"^0.11.3\",\n \"@traceloop/instrumentation-pinecone\": \"^0.11.1\",\n \"@traceloop/instrumentation-qdrant\": \"^0.11.1\",\n \"@traceloop/instrumentation-vertexai\": \"^0.11.1\",\n \"argparse\": \">=2.0\",\n \"cli-progress\": \">=3.12\",\n \"esbuild\": \">=0.23\",\n \"uuid\": \">=10.0.0\"\n }\n}\n","#!/usr/bin/env node\n\nimport { ArgumentParser } from \"argparse\";\nimport * as esbuild from \"esbuild\";\n\nconst pjson = require('../package.json');\n\nexport function loadModule({\n filename,\n moduleText,\n}: {\n filename: string;\n moduleText: string;\n}) {\n // TODO: Figure out how to remove all ts-ignores\n // TODO: Cleanup by setting the original values of _evaluation and _set_global_evaluation back\n // @ts-ignore\n globalThis._evaluation = undefined; // @ts-ignore\n globalThis._set_global_evaluation = true; // @ts-ignore\n\n // it needs \"require\" to be passed in\n new Function(\"require\", moduleText)(require);\n\n // Return the modified _evals global variable\n // @ts-ignore\n return globalThis._evaluation;\n}\n\nasync function cli() {\n const [, , ...args] = process.argv;\n\n // Use argparse, which is the port of the python library\n const parser = new ArgumentParser({\n prog: \"lmnr\",\n description: \"CLI for Laminar\",\n });\n\n parser.add_argument(\"-v\", \"--version\", { action: \"version\", version: pjson.version });\n\n const subparsers = parser.add_subparsers({\n title: \"subcommands\",\n dest: \"subcommand\",\n });\n\n const parser_eval = subparsers.add_parser(\"eval\", {\n description: \"Run an evaluation\",\n });\n\n parser_eval.add_argument(\"file\", {\n help: \"A file containing the evaluation to run\",\n });\n\n parser_eval.set_defaults({\n func: async (args: any) => {\n // TODO: Add various optimizations, e.g. minify, pure, tree shaking, etc.\n const buildOptions = {\n entryPoints: [args.file],\n outfile: \"tmp_out.js\",\n write: false, // will be loaded in memory as a temp file\n platform: \"node\" as esbuild.Platform,\n bundle: true,\n external: [\"node_modules/*\"],\n };\n\n const result = await esbuild.build(buildOptions);\n\n if (!result.outputFiles) {\n console.error(\"Error when building: No output files found\");\n process.exit(1);\n }\n\n const outputFileText = result.outputFiles[0].text;\n\n const evaluation = loadModule({\n filename: args.file,\n moduleText: outputFileText,\n });\n\n // @ts-ignore\n await evaluation.run();\n }\n });\n\n const parsed = parser.parse_args(args);\n await parsed.func(parsed);\n}\n\ncli();\n"],"mappings":";;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,MAAQ;AAAA,MACR,SAAW;AAAA,MACX,aAAe;AAAA,MACf,MAAQ;AAAA,MACR,OAAS;AAAA,MACT,SAAW;AAAA,QACT,OAAS;AAAA,QACT,MAAQ;AAAA,MACV;AAAA,MACA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AAC;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"]}
|
package/dist/index.d.mts
CHANGED
|
@@ -527,12 +527,13 @@ declare class Laminar {
|
|
|
527
527
|
* // | | bar
|
|
528
528
|
* // | | | openai.chat
|
|
529
529
|
*/
|
|
530
|
-
static startSpan({ name, input, spanType, context, traceId, }: {
|
|
530
|
+
static startSpan({ name, input, spanType, context, traceId, labels, }: {
|
|
531
531
|
name: string;
|
|
532
532
|
input?: any;
|
|
533
533
|
spanType?: 'LLM' | 'DEFAULT';
|
|
534
534
|
context?: Context;
|
|
535
535
|
traceId?: string;
|
|
536
|
+
labels?: Record<string, string>;
|
|
536
537
|
}): Span;
|
|
537
538
|
/**
|
|
538
539
|
* A utility wrapper around OpenTelemetry's `context.with()`. Useful for
|
|
@@ -593,5 +594,28 @@ interface ObserveOptions {
|
|
|
593
594
|
* });
|
|
594
595
|
*/
|
|
595
596
|
declare function observe<A extends unknown[], F extends (...args: A) => ReturnType<F>>({ name, sessionId, userId, traceType, spanType, traceId, }: ObserveOptions, fn: F, ...args: A): Promise<ReturnType<F>>;
|
|
597
|
+
/**
|
|
598
|
+
* Sets the labels for any spans inside the function. This is useful for adding
|
|
599
|
+
* labels to the spans created in the auto-instrumentations. Returns the result
|
|
600
|
+
* of the wrapped function, so you can use it in an `await` statement if needed.
|
|
601
|
+
*
|
|
602
|
+
* Requirements:
|
|
603
|
+
* - Labels must be created in your project in advance.
|
|
604
|
+
* - Keys must be strings from your label names.
|
|
605
|
+
* - Values must be strings matching the label's allowed values.
|
|
606
|
+
*
|
|
607
|
+
* @param labels - The labels to set.
|
|
608
|
+
* @returns The result of the wrapped function.
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* import { withLabels } from '@lmnr-ai/lmnr';
|
|
613
|
+
*
|
|
614
|
+
* const result = await withLabels({ endpoint: "ft-openai-<id>" }, () => {
|
|
615
|
+
* openai.chat.completions.create({});
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
declare function withLabels<A extends unknown[], F extends (...args: A) => ReturnType<F>>(labels: Record<string, string>, fn: F, ...args: A): ReturnType<F>;
|
|
596
620
|
|
|
597
|
-
export { type ChatMessage, type Datapoint, EvaluationDataset as Dataset, type EvaluateEvent, type Event, HumanEvaluator, Laminar, LaminarAttributes, LaminarDataset, type NodeInput, type PipelineRunRequest, type PipelineRunResponse, evaluate, observe };
|
|
621
|
+
export { type ChatMessage, type Datapoint, EvaluationDataset as Dataset, type EvaluateEvent, type Event, HumanEvaluator, Laminar, LaminarAttributes, LaminarDataset, type NodeInput, type PipelineRunRequest, type PipelineRunResponse, evaluate, observe, withLabels };
|
package/dist/index.d.ts
CHANGED
|
@@ -527,12 +527,13 @@ declare class Laminar {
|
|
|
527
527
|
* // | | bar
|
|
528
528
|
* // | | | openai.chat
|
|
529
529
|
*/
|
|
530
|
-
static startSpan({ name, input, spanType, context, traceId, }: {
|
|
530
|
+
static startSpan({ name, input, spanType, context, traceId, labels, }: {
|
|
531
531
|
name: string;
|
|
532
532
|
input?: any;
|
|
533
533
|
spanType?: 'LLM' | 'DEFAULT';
|
|
534
534
|
context?: Context;
|
|
535
535
|
traceId?: string;
|
|
536
|
+
labels?: Record<string, string>;
|
|
536
537
|
}): Span;
|
|
537
538
|
/**
|
|
538
539
|
* A utility wrapper around OpenTelemetry's `context.with()`. Useful for
|
|
@@ -593,5 +594,28 @@ interface ObserveOptions {
|
|
|
593
594
|
* });
|
|
594
595
|
*/
|
|
595
596
|
declare function observe<A extends unknown[], F extends (...args: A) => ReturnType<F>>({ name, sessionId, userId, traceType, spanType, traceId, }: ObserveOptions, fn: F, ...args: A): Promise<ReturnType<F>>;
|
|
597
|
+
/**
|
|
598
|
+
* Sets the labels for any spans inside the function. This is useful for adding
|
|
599
|
+
* labels to the spans created in the auto-instrumentations. Returns the result
|
|
600
|
+
* of the wrapped function, so you can use it in an `await` statement if needed.
|
|
601
|
+
*
|
|
602
|
+
* Requirements:
|
|
603
|
+
* - Labels must be created in your project in advance.
|
|
604
|
+
* - Keys must be strings from your label names.
|
|
605
|
+
* - Values must be strings matching the label's allowed values.
|
|
606
|
+
*
|
|
607
|
+
* @param labels - The labels to set.
|
|
608
|
+
* @returns The result of the wrapped function.
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* import { withLabels } from '@lmnr-ai/lmnr';
|
|
613
|
+
*
|
|
614
|
+
* const result = await withLabels({ endpoint: "ft-openai-<id>" }, () => {
|
|
615
|
+
* openai.chat.completions.create({});
|
|
616
|
+
* });
|
|
617
|
+
* ```
|
|
618
|
+
*/
|
|
619
|
+
declare function withLabels<A extends unknown[], F extends (...args: A) => ReturnType<F>>(labels: Record<string, string>, fn: F, ...args: A): ReturnType<F>;
|
|
596
620
|
|
|
597
|
-
export { type ChatMessage, type Datapoint, EvaluationDataset as Dataset, type EvaluateEvent, type Event, HumanEvaluator, Laminar, LaminarAttributes, LaminarDataset, type NodeInput, type PipelineRunRequest, type PipelineRunResponse, evaluate, observe };
|
|
621
|
+
export { type ChatMessage, type Datapoint, EvaluationDataset as Dataset, type EvaluateEvent, type Event, HumanEvaluator, Laminar, LaminarAttributes, LaminarDataset, type NodeInput, type PipelineRunRequest, type PipelineRunResponse, evaluate, observe, withLabels };
|
package/dist/index.js
CHANGED
|
@@ -35,9 +35,10 @@ __export(src_exports, {
|
|
|
35
35
|
Laminar: () => Laminar,
|
|
36
36
|
LaminarAttributes: () => LaminarAttributes,
|
|
37
37
|
LaminarDataset: () => LaminarDataset,
|
|
38
|
-
Span: () =>
|
|
38
|
+
Span: () => import_api8.Span,
|
|
39
39
|
evaluate: () => evaluate,
|
|
40
|
-
observe: () => observe
|
|
40
|
+
observe: () => observe,
|
|
41
|
+
withLabels: () => withLabels
|
|
41
42
|
});
|
|
42
43
|
module.exports = __toCommonJS(src_exports);
|
|
43
44
|
|
|
@@ -873,10 +874,11 @@ var Laminar = class {
|
|
|
873
874
|
name,
|
|
874
875
|
input,
|
|
875
876
|
spanType,
|
|
876
|
-
context:
|
|
877
|
-
traceId
|
|
877
|
+
context: context4,
|
|
878
|
+
traceId,
|
|
879
|
+
labels
|
|
878
880
|
}) {
|
|
879
|
-
let entityContext =
|
|
881
|
+
let entityContext = context4 != null ? context4 : import_api5.context.active();
|
|
880
882
|
const currentSpanPath = getSpanPath(entityContext);
|
|
881
883
|
const spanPath = currentSpanPath ? `${currentSpanPath}.${name}` : name;
|
|
882
884
|
entityContext = entityContext.setValue(SPAN_PATH_KEY, spanPath);
|
|
@@ -893,9 +895,14 @@ var Laminar = class {
|
|
|
893
895
|
console.warn(`Invalid trace ID ${traceId}. Expected a UUID.`);
|
|
894
896
|
}
|
|
895
897
|
}
|
|
898
|
+
const labelProperties = labels ? Object.entries(labels).reduce((acc, [key, value]) => {
|
|
899
|
+
acc[`${ASSOCIATION_PROPERTIES}.label.${key}`] = value;
|
|
900
|
+
return acc;
|
|
901
|
+
}, {}) : {};
|
|
896
902
|
const attributes = {
|
|
897
903
|
[SPAN_TYPE]: spanType != null ? spanType : "DEFAULT",
|
|
898
|
-
[
|
|
904
|
+
[SPAN_PATH]: spanPath,
|
|
905
|
+
...labelProperties
|
|
899
906
|
};
|
|
900
907
|
const span = getTracer().startSpan(name, { attributes }, entityContext);
|
|
901
908
|
if (traceId) {
|
|
@@ -1038,6 +1045,7 @@ var LaminarDataset = class extends EvaluationDataset {
|
|
|
1038
1045
|
};
|
|
1039
1046
|
|
|
1040
1047
|
// src/decorators.ts
|
|
1048
|
+
var import_api6 = require("@opentelemetry/api");
|
|
1041
1049
|
async function observe({
|
|
1042
1050
|
name,
|
|
1043
1051
|
sessionId,
|
|
@@ -1068,9 +1076,34 @@ async function observe({
|
|
|
1068
1076
|
traceId
|
|
1069
1077
|
}, fn, void 0, ...args);
|
|
1070
1078
|
}
|
|
1079
|
+
function withLabels(labels, fn, ...args) {
|
|
1080
|
+
var _a, _b;
|
|
1081
|
+
let entityContext = import_api6.context.active();
|
|
1082
|
+
const currentAssociationProperties = (_a = entityContext.getValue(ASSOCIATION_PROPERTIES_KEY)) != null ? _a : {};
|
|
1083
|
+
const labelProperties = Object.entries(labels).reduce((acc, [key, value]) => {
|
|
1084
|
+
acc[`label.${key}`] = value;
|
|
1085
|
+
return acc;
|
|
1086
|
+
}, {});
|
|
1087
|
+
entityContext = entityContext.setValue(
|
|
1088
|
+
ASSOCIATION_PROPERTIES_KEY,
|
|
1089
|
+
{ ...currentAssociationProperties, ...labelProperties }
|
|
1090
|
+
);
|
|
1091
|
+
const result = import_api6.context.with(entityContext, () => {
|
|
1092
|
+
return fn.apply(void 0, args);
|
|
1093
|
+
});
|
|
1094
|
+
const newAssociationProperties = (_b = entityContext.getValue(ASSOCIATION_PROPERTIES_KEY)) != null ? _b : {};
|
|
1095
|
+
for (const [key, value] of Object.entries(labelProperties)) {
|
|
1096
|
+
delete newAssociationProperties[`label.${key}`];
|
|
1097
|
+
}
|
|
1098
|
+
entityContext = entityContext.setValue(
|
|
1099
|
+
ASSOCIATION_PROPERTIES_KEY,
|
|
1100
|
+
newAssociationProperties
|
|
1101
|
+
);
|
|
1102
|
+
return result;
|
|
1103
|
+
}
|
|
1071
1104
|
|
|
1072
1105
|
// src/evaluations.ts
|
|
1073
|
-
var
|
|
1106
|
+
var import_api7 = require("@opentelemetry/api");
|
|
1074
1107
|
var DEFAULT_BATCH_SIZE = 5;
|
|
1075
1108
|
var getEvaluationUrl = (projectId, evaluationId) => {
|
|
1076
1109
|
return `https://www.lmnr.ai/project/${projectId}/evaluations/${evaluationId}`;
|
|
@@ -1220,12 +1253,12 @@ var Evaluation = class {
|
|
|
1220
1253
|
const batchPromises = batch.map(async (datapoint) => {
|
|
1221
1254
|
let ret;
|
|
1222
1255
|
await observe({ name: "evaluation", traceType: "EVALUATION" }, async () => {
|
|
1223
|
-
|
|
1256
|
+
import_api7.trace.getActiveSpan().setAttribute(SPAN_TYPE, "EVALUATION");
|
|
1224
1257
|
const { output, executorSpanId } = await observe(
|
|
1225
1258
|
{ name: "executor" },
|
|
1226
1259
|
async (data) => {
|
|
1227
|
-
const executorSpanId2 =
|
|
1228
|
-
|
|
1260
|
+
const executorSpanId2 = import_api7.trace.getActiveSpan().spanContext().spanId;
|
|
1261
|
+
import_api7.trace.getActiveSpan().setAttribute(SPAN_TYPE, "EXECUTOR");
|
|
1229
1262
|
return {
|
|
1230
1263
|
output: await this.executor(data),
|
|
1231
1264
|
executorSpanId: otelSpanIdToUUID(executorSpanId2)
|
|
@@ -1239,7 +1272,7 @@ var Evaluation = class {
|
|
|
1239
1272
|
const value = await observe(
|
|
1240
1273
|
{ name: evaluatorName },
|
|
1241
1274
|
async (output2, target2) => {
|
|
1242
|
-
|
|
1275
|
+
import_api7.trace.getActiveSpan().setAttribute(SPAN_TYPE, "EVALUATOR");
|
|
1243
1276
|
return await evaluator(output2, target2);
|
|
1244
1277
|
},
|
|
1245
1278
|
output,
|
|
@@ -1259,7 +1292,7 @@ var Evaluation = class {
|
|
|
1259
1292
|
data: datapoint.data,
|
|
1260
1293
|
target,
|
|
1261
1294
|
scores,
|
|
1262
|
-
traceId: otelTraceIdToUUID(
|
|
1295
|
+
traceId: otelTraceIdToUUID(import_api7.trace.getActiveSpan().spanContext().traceId),
|
|
1263
1296
|
// For now, all human evaluators are added to every datapoint
|
|
1264
1297
|
// In the future, we will allow to specify which evaluators are
|
|
1265
1298
|
// added to a particular datapoint, e.g. random sampling.
|
|
@@ -1302,7 +1335,7 @@ async function evaluate({
|
|
|
1302
1335
|
}
|
|
1303
1336
|
|
|
1304
1337
|
// src/index.ts
|
|
1305
|
-
var
|
|
1338
|
+
var import_api8 = require("@opentelemetry/api");
|
|
1306
1339
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1307
1340
|
0 && (module.exports = {
|
|
1308
1341
|
Dataset,
|
|
@@ -1312,6 +1345,7 @@ var import_api7 = require("@opentelemetry/api");
|
|
|
1312
1345
|
LaminarDataset,
|
|
1313
1346
|
Span,
|
|
1314
1347
|
evaluate,
|
|
1315
|
-
observe
|
|
1348
|
+
observe,
|
|
1349
|
+
withLabels
|
|
1316
1350
|
});
|
|
1317
1351
|
//# sourceMappingURL=index.js.map
|