langsmith 0.0.36 → 0.0.37

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.
@@ -26,7 +26,7 @@ services:
26
26
  environment:
27
27
  - LANGCHAIN_ENV=local_docker
28
28
  - LOG_LEVEL=warning
29
- entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker --connection-class lc_database.queue.connection.RedisRetry"
29
+ entrypoint: "rq worker --with-scheduler -u redis://langchain-redis:6379 --serializer lc_database.queue.serializer.ORJSONSerializer --worker-class lc_database.queue.worker.Worker --connection-class lc_database.queue.connection.RedisRetry --job-class lc_database.queue.job.AsyncJob"
30
30
  langchain-hub:
31
31
  image: langchain/${_LANGSMITH_IMAGE_PREFIX-}langchainhub-backend:latest
32
32
  environment:
package/dist/client.cjs CHANGED
@@ -581,7 +581,7 @@ class Client {
581
581
  }
582
582
  await response.json();
583
583
  }
584
- async createExample(inputs, outputs, { datasetId, datasetName, createdAt }) {
584
+ async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId }) {
585
585
  let datasetId_ = datasetId;
586
586
  if (datasetId_ === undefined && datasetName === undefined) {
587
587
  throw new Error("Must provide either datasetName or datasetId");
@@ -599,6 +599,7 @@ class Client {
599
599
  inputs,
600
600
  outputs,
601
601
  created_at: createdAt_.toISOString(),
602
+ id: exampleId,
602
603
  };
603
604
  const response = await this.caller.call(fetch, `${this.apiUrl}/examples`, {
604
605
  method: "POST",
@@ -711,7 +712,7 @@ class Client {
711
712
  feedbackSourceType: "model",
712
713
  });
713
714
  }
714
- async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, }) {
715
+ async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, }) {
715
716
  const feedback_source = {
716
717
  type: feedbackSourceType ?? "api",
717
718
  metadata: sourceInfo ?? {},
@@ -722,7 +723,7 @@ class Client {
722
723
  feedback_source.metadata["__run"] = { run_id: sourceRunId };
723
724
  }
724
725
  const feedback = {
725
- id: uuid.v4(),
726
+ id: feedbackId ?? uuid.v4(),
726
727
  run_id: runId,
727
728
  key,
728
729
  score,
@@ -737,11 +738,8 @@ class Client {
737
738
  body: JSON.stringify(feedback),
738
739
  signal: AbortSignal.timeout(this.timeout_ms),
739
740
  });
740
- if (!response.ok) {
741
- throw new Error(`Failed to create feedback for run ${runId}: ${response.status} ${response.statusText}`);
742
- }
743
- const result = await response.json();
744
- return result;
741
+ await raiseForStatus(response, "create feedback");
742
+ return feedback;
745
743
  }
746
744
  async updateFeedback(feedbackId, { score, value, correction, comment, }) {
747
745
  const feedbackUpdate = {};
package/dist/client.d.ts CHANGED
@@ -53,6 +53,7 @@ export type CreateExampleOptions = {
53
53
  datasetId?: string;
54
54
  datasetName?: string;
55
55
  createdAt?: Date;
56
+ exampleId?: string;
56
57
  };
57
58
  export declare class Client {
58
59
  private apiKey?;
@@ -125,7 +126,7 @@ export declare class Client {
125
126
  datasetId?: string;
126
127
  datasetName?: string;
127
128
  }): Promise<void>;
128
- createExample(inputs: KVMap, outputs: KVMap, { datasetId, datasetName, createdAt }: CreateExampleOptions): Promise<Example>;
129
+ createExample(inputs: KVMap, outputs: KVMap, { datasetId, datasetName, createdAt, exampleId }: CreateExampleOptions): Promise<Example>;
129
130
  createLLMExample(input: string, generation: string | undefined, options: CreateExampleOptions): Promise<Example>;
130
131
  createChatExample(input: KVMap[] | LangChainBaseMessage[], generations: KVMap | LangChainBaseMessage | undefined, options: CreateExampleOptions): Promise<Example>;
131
132
  readExample(exampleId: string): Promise<Example>;
@@ -140,7 +141,7 @@ export declare class Client {
140
141
  sourceInfo?: KVMap;
141
142
  loadChildRuns: boolean;
142
143
  }): Promise<Feedback>;
143
- createFeedback(runId: string, key: string, { score, value, correction, comment, sourceInfo, feedbackSourceType, sourceRunId, }: {
144
+ createFeedback(runId: string, key: string, { score, value, correction, comment, sourceInfo, feedbackSourceType, sourceRunId, feedbackId, }: {
144
145
  score?: ScoreType;
145
146
  value?: ValueType;
146
147
  correction?: object;
@@ -148,6 +149,7 @@ export declare class Client {
148
149
  sourceInfo?: object;
149
150
  feedbackSourceType?: FeedbackSourceType;
150
151
  sourceRunId?: string;
152
+ feedbackId?: string;
151
153
  }): Promise<Feedback>;
152
154
  updateFeedback(feedbackId: string, { score, value, correction, comment, }: {
153
155
  score?: number | boolean | null;
package/dist/client.js CHANGED
@@ -555,7 +555,7 @@ export class Client {
555
555
  }
556
556
  await response.json();
557
557
  }
558
- async createExample(inputs, outputs, { datasetId, datasetName, createdAt }) {
558
+ async createExample(inputs, outputs, { datasetId, datasetName, createdAt, exampleId }) {
559
559
  let datasetId_ = datasetId;
560
560
  if (datasetId_ === undefined && datasetName === undefined) {
561
561
  throw new Error("Must provide either datasetName or datasetId");
@@ -573,6 +573,7 @@ export class Client {
573
573
  inputs,
574
574
  outputs,
575
575
  created_at: createdAt_.toISOString(),
576
+ id: exampleId,
576
577
  };
577
578
  const response = await this.caller.call(fetch, `${this.apiUrl}/examples`, {
578
579
  method: "POST",
@@ -685,7 +686,7 @@ export class Client {
685
686
  feedbackSourceType: "model",
686
687
  });
687
688
  }
688
- async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, }) {
689
+ async createFeedback(runId, key, { score, value, correction, comment, sourceInfo, feedbackSourceType = "api", sourceRunId, feedbackId, }) {
689
690
  const feedback_source = {
690
691
  type: feedbackSourceType ?? "api",
691
692
  metadata: sourceInfo ?? {},
@@ -696,7 +697,7 @@ export class Client {
696
697
  feedback_source.metadata["__run"] = { run_id: sourceRunId };
697
698
  }
698
699
  const feedback = {
699
- id: uuid.v4(),
700
+ id: feedbackId ?? uuid.v4(),
700
701
  run_id: runId,
701
702
  key,
702
703
  score,
@@ -711,11 +712,8 @@ export class Client {
711
712
  body: JSON.stringify(feedback),
712
713
  signal: AbortSignal.timeout(this.timeout_ms),
713
714
  });
714
- if (!response.ok) {
715
- throw new Error(`Failed to create feedback for run ${runId}: ${response.status} ${response.statusText}`);
716
- }
717
- const result = await response.json();
718
- return result;
715
+ await raiseForStatus(response, "create feedback");
716
+ return feedback;
719
717
  }
720
718
  async updateFeedback(feedbackId, { score, value, correction, comment, }) {
721
719
  const feedbackUpdate = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "langsmith",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "description": "Client library to connect to the LangSmith LLM Tracing and Evaluation Platform.",
5
5
  "files": [
6
6
  "dist/",