@lmnr-ai/lmnr 0.8.21 → 0.8.22

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/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { n as version, t as LaminarClient } from "./dist-B5CmOQ4s.mjs";
1
+ import { n as version, t as LaminarClient } from "./dist-BXwORFgR.mjs";
2
2
  import { A as SPAN_OUTPUT, D as SPAN_INPUT, E as SPAN_IDS_PATH, I as USER_ID, M as SPAN_SDK_VERSION, N as SPAN_TYPE, O as SPAN_INSTRUMENTATION_SOURCE, T as SESSION_ID, a as getFrontendUrl, b as HUMAN_EVALUATOR_OPTIONS, c as loadEnv, d as normalizeOtelSpanId, f as normalizeOtelTraceId, j as SPAN_PATH, k as SPAN_LANGUAGE_VERSION, m as otelTraceIdToUUID, n as Semaphore, p as otelSpanIdToUUID, s as initializeLogger, u as newUUID, v as ASSOCIATION_PROPERTIES, x as LaminarAttributes } from "./utils-CHJ0KZUR.mjs";
3
- import { a as getSpanProcessor, c as LaminarSpanProcessor, d as Laminar, f as instrumentClaudeAgentQuery, g as stringifyPromptForTelemetry, i as withTracingLevel, l as getLangVersion, m as TracingLevel, n as observeDecorator, o as getTracer, p as LaminarContextManager, r as observeExperimentalDecorator, s as getTracerProvider, t as observe, u as initializeLaminarInstrumentations } from "./decorators-BDFgXfgI.mjs";
3
+ import { _ as stringifyPromptForTelemetry, a as getSpanProcessor, c as LaminarSpanProcessor, d as Laminar, f as instrumentClaudeAgentQuery, h as TracingLevel, i as withTracingLevel, l as getLangVersion, m as LaminarContextManager, n as observeDecorator, o as getTracer, p as ASSOCIATION_PROPERTIES_KEY, r as observeExperimentalDecorator, s as getTracerProvider, t as observe, u as initializeLaminarInstrumentations } from "./decorators-DrWG-1Po.mjs";
4
4
  import { SpanKind, SpanStatusCode, TraceFlags, context, trace } from "@opentelemetry/api";
5
5
  import * as cliProgress from "cli-progress";
6
6
  //#region src/datasets.ts
@@ -232,23 +232,34 @@ var Evaluation = class {
232
232
  }
233
233
  }
234
234
  async evaluateInBatches(evalId) {
235
- const semaphore = new Semaphore(this.concurrencyLimit);
236
- const tasks = [];
237
- const evaluateTask = async (datapoint, index) => {
238
- try {
239
- const result = await this.evaluateDatapoint(evalId, datapoint, index);
240
- this.progressReporter.update(1);
241
- return [index, result];
242
- } finally {
243
- semaphore.release();
235
+ const baseContext = LaminarContextManager.getContext();
236
+ const currentAssociationProperties = baseContext.getValue(ASSOCIATION_PROPERTIES_KEY) ?? {};
237
+ const entityContext = baseContext.setValue(ASSOCIATION_PROPERTIES_KEY, {
238
+ ...currentAssociationProperties,
239
+ metadata: {
240
+ ...currentAssociationProperties.metadata ?? {},
241
+ evaluation_id: evalId
244
242
  }
245
- };
246
- for (let i = 0; i < await this.getLength(); i++) {
247
- await semaphore.acquire();
248
- const datapoint = Array.isArray(this.data) ? this.data[i] : await this.data.get(i);
249
- tasks.push(evaluateTask(datapoint, i));
250
- }
251
- return (await Promise.all(tasks)).sort((a, b) => a[0] - b[0]).map(([, result]) => result);
243
+ });
244
+ return LaminarContextManager.runWithIsolatedContext([entityContext], async () => {
245
+ const semaphore = new Semaphore(this.concurrencyLimit);
246
+ const tasks = [];
247
+ const evaluateTask = async (datapoint, index) => {
248
+ try {
249
+ const result = await this.evaluateDatapoint(evalId, datapoint, index);
250
+ this.progressReporter.update(1);
251
+ return [index, result];
252
+ } finally {
253
+ semaphore.release();
254
+ }
255
+ };
256
+ for (let i = 0; i < await this.getLength(); i++) {
257
+ await semaphore.acquire();
258
+ const datapoint = Array.isArray(this.data) ? this.data[i] : await this.data.get(i);
259
+ tasks.push(evaluateTask(datapoint, i));
260
+ }
261
+ return (await Promise.all(tasks)).sort((a, b) => a[0] - b[0]).map(([, result]) => result);
262
+ });
252
263
  }
253
264
  async evaluateDatapoint(evalId, datapoint, index) {
254
265
  return observe({