langsmith 0.3.22 → 0.3.24

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/client.cjs CHANGED
@@ -2644,11 +2644,12 @@ class Client {
2644
2644
  * @returns The created AnnotationQueue object
2645
2645
  */
2646
2646
  async createAnnotationQueue(options) {
2647
- const { name, description, queueId } = options;
2647
+ const { name, description, queueId, rubricInstructions } = options;
2648
2648
  const body = {
2649
2649
  name,
2650
2650
  description,
2651
2651
  id: queueId || uuid.v4(),
2652
+ rubric_instructions: rubricInstructions,
2652
2653
  };
2653
2654
  const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues`, {
2654
2655
  method: "POST",
@@ -2664,17 +2665,18 @@ class Client {
2664
2665
  /**
2665
2666
  * Read an annotation queue with the specified queue ID.
2666
2667
  * @param queueId - The ID of the annotation queue to read
2667
- * @returns The AnnotationQueue object
2668
+ * @returns The AnnotationQueueWithDetails object
2668
2669
  */
2669
2670
  async readAnnotationQueue(queueId) {
2670
- // TODO: Replace when actual endpoint is added
2671
- const queueIteratorResult = await this.listAnnotationQueues({
2672
- queueIds: [queueId],
2673
- }).next();
2674
- if (queueIteratorResult.done) {
2675
- throw new Error(`Annotation queue with ID ${queueId} not found`);
2676
- }
2677
- return queueIteratorResult.value;
2671
+ const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2672
+ method: "GET",
2673
+ headers: this.headers,
2674
+ signal: AbortSignal.timeout(this.timeout_ms),
2675
+ ...this.fetchOptions,
2676
+ });
2677
+ await (0, error_js_1.raiseForStatus)(response, "read annotation queue");
2678
+ const data = await response.json();
2679
+ return data;
2678
2680
  }
2679
2681
  /**
2680
2682
  * Update an annotation queue with the specified queue ID.
@@ -2684,11 +2686,15 @@ class Client {
2684
2686
  * @param options.description - The new description for the annotation queue
2685
2687
  */
2686
2688
  async updateAnnotationQueue(queueId, options) {
2687
- const { name, description } = options;
2689
+ const { name, description, rubricInstructions } = options;
2688
2690
  const response = await this.caller.call((0, fetch_js_1._getFetchImplementation)(this.debug), `${this.apiUrl}/annotation-queues/${(0, _uuid_js_1.assertUuid)(queueId, "queueId")}`, {
2689
2691
  method: "PATCH",
2690
2692
  headers: { ...this.headers, "Content-Type": "application/json" },
2691
- body: JSON.stringify({ name, description }),
2693
+ body: JSON.stringify({
2694
+ name,
2695
+ description,
2696
+ rubric_instructions: rubricInstructions,
2697
+ }),
2692
2698
  signal: AbortSignal.timeout(this.timeout_ms),
2693
2699
  ...this.fetchOptions,
2694
2700
  });
package/dist/client.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { AsyncCallerParams } from "./utils/async_caller.js";
2
- import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleCreate, ExampleUpdate, ExampleUpdateWithoutId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, ExampleSearch, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, UploadExamplesResponse, UpdateExamplesResponse, DatasetVersion } from "./schemas.js";
2
+ import { ComparativeExperiment, DataType, Dataset, DatasetDiffInfo, DatasetShareSchema, Example, ExampleCreate, ExampleUpdate, ExampleUpdateWithoutId, Feedback, FeedbackConfig, FeedbackIngestToken, KVMap, LangChainBaseMessage, LangSmithSettings, LikePromptResponse, Prompt, PromptCommit, PromptSortField, Run, RunCreate, RunUpdate, ScoreType, ExampleSearch, TimeDelta, TracerSession, TracerSessionResult, ValueType, AnnotationQueue, RunWithAnnotationQueueInfo, Attachments, UploadExamplesResponse, UpdateExamplesResponse, DatasetVersion, AnnotationQueueWithDetails } from "./schemas.js";
3
3
  import { EvaluationResult, EvaluationResults, RunEvaluator } from "./evaluation/evaluator.js";
4
4
  export interface ClientConfig {
5
5
  apiUrl?: string;
@@ -743,13 +743,14 @@ export declare class Client implements LangSmithTracingClientInterface {
743
743
  name: string;
744
744
  description?: string;
745
745
  queueId?: string;
746
- }): Promise<AnnotationQueue>;
746
+ rubricInstructions?: string;
747
+ }): Promise<AnnotationQueueWithDetails>;
747
748
  /**
748
749
  * Read an annotation queue with the specified queue ID.
749
750
  * @param queueId - The ID of the annotation queue to read
750
- * @returns The AnnotationQueue object
751
+ * @returns The AnnotationQueueWithDetails object
751
752
  */
752
- readAnnotationQueue(queueId: string): Promise<AnnotationQueue>;
753
+ readAnnotationQueue(queueId: string): Promise<AnnotationQueueWithDetails>;
753
754
  /**
754
755
  * Update an annotation queue with the specified queue ID.
755
756
  * @param queueId - The ID of the annotation queue to update
@@ -760,6 +761,7 @@ export declare class Client implements LangSmithTracingClientInterface {
760
761
  updateAnnotationQueue(queueId: string, options: {
761
762
  name: string;
762
763
  description?: string;
764
+ rubricInstructions?: string;
763
765
  }): Promise<void>;
764
766
  /**
765
767
  * Delete an annotation queue with the specified queue ID.
package/dist/client.js CHANGED
@@ -2606,11 +2606,12 @@ export class Client {
2606
2606
  * @returns The created AnnotationQueue object
2607
2607
  */
2608
2608
  async createAnnotationQueue(options) {
2609
- const { name, description, queueId } = options;
2609
+ const { name, description, queueId, rubricInstructions } = options;
2610
2610
  const body = {
2611
2611
  name,
2612
2612
  description,
2613
2613
  id: queueId || uuid.v4(),
2614
+ rubric_instructions: rubricInstructions,
2614
2615
  };
2615
2616
  const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues`, {
2616
2617
  method: "POST",
@@ -2626,17 +2627,18 @@ export class Client {
2626
2627
  /**
2627
2628
  * Read an annotation queue with the specified queue ID.
2628
2629
  * @param queueId - The ID of the annotation queue to read
2629
- * @returns The AnnotationQueue object
2630
+ * @returns The AnnotationQueueWithDetails object
2630
2631
  */
2631
2632
  async readAnnotationQueue(queueId) {
2632
- // TODO: Replace when actual endpoint is added
2633
- const queueIteratorResult = await this.listAnnotationQueues({
2634
- queueIds: [queueId],
2635
- }).next();
2636
- if (queueIteratorResult.done) {
2637
- throw new Error(`Annotation queue with ID ${queueId} not found`);
2638
- }
2639
- return queueIteratorResult.value;
2633
+ const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2634
+ method: "GET",
2635
+ headers: this.headers,
2636
+ signal: AbortSignal.timeout(this.timeout_ms),
2637
+ ...this.fetchOptions,
2638
+ });
2639
+ await raiseForStatus(response, "read annotation queue");
2640
+ const data = await response.json();
2641
+ return data;
2640
2642
  }
2641
2643
  /**
2642
2644
  * Update an annotation queue with the specified queue ID.
@@ -2646,11 +2648,15 @@ export class Client {
2646
2648
  * @param options.description - The new description for the annotation queue
2647
2649
  */
2648
2650
  async updateAnnotationQueue(queueId, options) {
2649
- const { name, description } = options;
2651
+ const { name, description, rubricInstructions } = options;
2650
2652
  const response = await this.caller.call(_getFetchImplementation(this.debug), `${this.apiUrl}/annotation-queues/${assertUuid(queueId, "queueId")}`, {
2651
2653
  method: "PATCH",
2652
2654
  headers: { ...this.headers, "Content-Type": "application/json" },
2653
- body: JSON.stringify({ name, description }),
2655
+ body: JSON.stringify({
2656
+ name,
2657
+ description,
2658
+ rubric_instructions: rubricInstructions,
2659
+ }),
2654
2660
  signal: AbortSignal.timeout(this.timeout_ms),
2655
2661
  ...this.fetchOptions,
2656
2662
  });
package/dist/index.cjs CHANGED
@@ -8,4 +8,4 @@ Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () {
8
8
  var fetch_js_1 = require("./singletons/fetch.cjs");
9
9
  Object.defineProperty(exports, "overrideFetchImplementation", { enumerable: true, get: function () { return fetch_js_1.overrideFetchImplementation; } });
10
10
  // Update using yarn bump-version
11
- exports.__version__ = "0.3.22";
11
+ exports.__version__ = "0.3.24";
package/dist/index.d.ts CHANGED
@@ -2,4 +2,4 @@ export { Client, type ClientConfig, type LangSmithTracingClientInterface, } from
2
2
  export type { Dataset, Example, TracerSession, Run, Feedback, RetrieverOutput, } from "./schemas.js";
3
3
  export { RunTree, type RunTreeConfig } from "./run_trees.js";
4
4
  export { overrideFetchImplementation } from "./singletons/fetch.js";
5
- export declare const __version__ = "0.3.22";
5
+ export declare const __version__ = "0.3.24";
package/dist/index.js CHANGED
@@ -2,4 +2,4 @@ export { Client, } from "./client.js";
2
2
  export { RunTree } from "./run_trees.js";
3
3
  export { overrideFetchImplementation } from "./singletons/fetch.js";
4
4
  // Update using yarn bump-version
5
- export const __version__ = "0.3.22";
5
+ export const __version__ = "0.3.24";
package/dist/schemas.d.ts CHANGED
@@ -451,6 +451,10 @@ export interface AnnotationQueue {
451
451
  /** The ID of the tenant associated with the annotation queue. */
452
452
  tenant_id: string;
453
453
  }
454
+ export interface AnnotationQueueWithDetails extends AnnotationQueue {
455
+ /** The rubric instructions for the annotation queue. */
456
+ rubric_instructions?: string;
457
+ }
454
458
  export interface RunWithAnnotationQueueInfo extends BaseRun {
455
459
  /** The last time this run was reviewed. */
456
460
  last_reviewed_time?: string;
package/dist/vercel.cjs CHANGED
@@ -183,6 +183,11 @@ const RESERVED_METADATA_KEYS = [
183
183
  TRACE_METADATA_KEY.output,
184
184
  BAGGAGE_METADATA_KEY.output,
185
185
  ];
186
+ function getParentSpanId(span) {
187
+ // Backcompat shim to support OTEL 1.x and 2.x
188
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
189
+ return (span.parentSpanId ?? span.parentSpanContext?.spanId ?? undefined);
190
+ }
186
191
  /**
187
192
  * OpenTelemetry trace exporter for Vercel AI SDK.
188
193
  *
@@ -289,9 +294,12 @@ class AISDKExporter {
289
294
  return { ...rest, isEnabled: rest.isEnabled ?? defaultEnabled, metadata };
290
295
  }
291
296
  /** @internal */
292
- parseInteropFromMetadata(span) {
297
+ parseInteropFromMetadata(span, parentSpan) {
293
298
  if (!this.isRootRun(span))
294
299
  return undefined;
300
+ if (parentSpan?.name === "ai.toolCall") {
301
+ return undefined;
302
+ }
295
303
  const userTraceId = this.getSpanAttributeKey(span, RUN_ID_METADATA_KEY.output);
296
304
  const parentTrace = this.getSpanAttributeKey(span, TRACE_METADATA_KEY.output);
297
305
  if (parentTrace && userTraceId) {
@@ -580,12 +588,7 @@ class AISDKExporter {
580
588
  .sort((a, b) => sortByHr(a.startTime, b.startTime));
581
589
  for (const span of typedSpans) {
582
590
  const { traceId, spanId } = span.spanContext();
583
- const parentId =
584
- // Backcompat shim to support OTEL 1.x and 2.x
585
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
586
- span.parentSpanId ??
587
- span.parentSpanContext?.spanId ??
588
- undefined;
591
+ const parentId = getParentSpanId(span);
589
592
  this.traceByMap[traceId] ??= {
590
593
  childMap: {},
591
594
  nodeMap: {},
@@ -599,12 +602,15 @@ class AISDKExporter {
599
602
  const run = this.getRunCreate(span);
600
603
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] ??= -1;
601
604
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] += 1;
605
+ const parentSpan = parentId
606
+ ? typedSpans.find((i) => i.spanContext().spanId === parentId)
607
+ : undefined;
602
608
  traceMap.nodeMap[runId] ??= {
603
609
  id: runId,
604
610
  startTime: span.startTime,
605
611
  run,
606
612
  sent: false,
607
- interop: this.parseInteropFromMetadata(span),
613
+ interop: this.parseInteropFromMetadata(span, parentSpan),
608
614
  executionOrder: traceMap.relativeExecutionOrder[parentRunId ?? ROOT],
609
615
  };
610
616
  if (this.debug)
package/dist/vercel.js CHANGED
@@ -180,6 +180,11 @@ const RESERVED_METADATA_KEYS = [
180
180
  TRACE_METADATA_KEY.output,
181
181
  BAGGAGE_METADATA_KEY.output,
182
182
  ];
183
+ function getParentSpanId(span) {
184
+ // Backcompat shim to support OTEL 1.x and 2.x
185
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
186
+ return (span.parentSpanId ?? span.parentSpanContext?.spanId ?? undefined);
187
+ }
183
188
  /**
184
189
  * OpenTelemetry trace exporter for Vercel AI SDK.
185
190
  *
@@ -286,9 +291,12 @@ export class AISDKExporter {
286
291
  return { ...rest, isEnabled: rest.isEnabled ?? defaultEnabled, metadata };
287
292
  }
288
293
  /** @internal */
289
- parseInteropFromMetadata(span) {
294
+ parseInteropFromMetadata(span, parentSpan) {
290
295
  if (!this.isRootRun(span))
291
296
  return undefined;
297
+ if (parentSpan?.name === "ai.toolCall") {
298
+ return undefined;
299
+ }
292
300
  const userTraceId = this.getSpanAttributeKey(span, RUN_ID_METADATA_KEY.output);
293
301
  const parentTrace = this.getSpanAttributeKey(span, TRACE_METADATA_KEY.output);
294
302
  if (parentTrace && userTraceId) {
@@ -577,12 +585,7 @@ export class AISDKExporter {
577
585
  .sort((a, b) => sortByHr(a.startTime, b.startTime));
578
586
  for (const span of typedSpans) {
579
587
  const { traceId, spanId } = span.spanContext();
580
- const parentId =
581
- // Backcompat shim to support OTEL 1.x and 2.x
582
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
583
- span.parentSpanId ??
584
- span.parentSpanContext?.spanId ??
585
- undefined;
588
+ const parentId = getParentSpanId(span);
586
589
  this.traceByMap[traceId] ??= {
587
590
  childMap: {},
588
591
  nodeMap: {},
@@ -596,12 +599,15 @@ export class AISDKExporter {
596
599
  const run = this.getRunCreate(span);
597
600
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] ??= -1;
598
601
  traceMap.relativeExecutionOrder[parentRunId ?? ROOT] += 1;
602
+ const parentSpan = parentId
603
+ ? typedSpans.find((i) => i.spanContext().spanId === parentId)
604
+ : undefined;
599
605
  traceMap.nodeMap[runId] ??= {
600
606
  id: runId,
601
607
  startTime: span.startTime,
602
608
  run,
603
609
  sent: false,
604
- interop: this.parseInteropFromMetadata(span),
610
+ interop: this.parseInteropFromMetadata(span, parentSpan),
605
611
  executionOrder: traceMap.relativeExecutionOrder[parentRunId ?? ROOT],
606
612
  };
607
613
  if (this.debug)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "packageManager": "yarn@1.22.19",
6
6
  "files": [
@@ -141,8 +141,10 @@
141
141
  "@langchain/langgraph": "^0.2.20",
142
142
  "@langchain/openai": "^0.3.11",
143
143
  "@opentelemetry/api": "^1.9.0",
144
+ "@opentelemetry/auto-instrumentations-node": "^0.58.0",
144
145
  "@opentelemetry/sdk-trace-base": "^2.0.0",
145
146
  "@opentelemetry/sdk-trace-node": "^2.0.0",
147
+ "@opentelemetry/sdk-node": "^0.200.0",
146
148
  "@tsconfig/recommended": "^1.0.2",
147
149
  "@types/jest": "^29.5.1",
148
150
  "@typescript-eslint/eslint-plugin": "^5.59.8",