langsmith 0.1.7 → 0.1.8
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 +84 -1
- package/dist/client.d.ts +144 -1
- package/dist/client.js +84 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -743,7 +743,89 @@ class Client {
|
|
|
743
743
|
}
|
|
744
744
|
return run;
|
|
745
745
|
}
|
|
746
|
-
|
|
746
|
+
/**
|
|
747
|
+
* List runs from the LangSmith server.
|
|
748
|
+
* @param projectId - The ID of the project to filter by.
|
|
749
|
+
* @param projectName - The name of the project to filter by.
|
|
750
|
+
* @param parentRunId - The ID of the parent run to filter by.
|
|
751
|
+
* @param traceId - The ID of the trace to filter by.
|
|
752
|
+
* @param referenceExampleId - The ID of the reference example to filter by.
|
|
753
|
+
* @param startTime - The start time to filter by.
|
|
754
|
+
* @param executionOrder - The execution order to filter by.
|
|
755
|
+
* @param runType - The run type to filter by.
|
|
756
|
+
* @param error - Indicates whether to filter by error runs.
|
|
757
|
+
* @param id - The ID of the run to filter by.
|
|
758
|
+
* @param query - The query string to filter by.
|
|
759
|
+
* @param filter - The filter string to apply to the run spans.
|
|
760
|
+
* @param traceFilter - The filter string to apply on the root run of the trace.
|
|
761
|
+
* @param limit - The maximum number of runs to retrieve.
|
|
762
|
+
* @returns {AsyncIterable<Run>} - The runs.
|
|
763
|
+
*
|
|
764
|
+
* @example
|
|
765
|
+
* // List all runs in a project
|
|
766
|
+
* const projectRuns = client.listRuns({ projectName: "<your_project>" });
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* // List LLM and Chat runs in the last 24 hours
|
|
770
|
+
* const todaysLLMRuns = client.listRuns({
|
|
771
|
+
* projectName: "<your_project>",
|
|
772
|
+
* start_time: new Date(Date.now() - 24 * 60 * 60 * 1000),
|
|
773
|
+
* run_type: "llm",
|
|
774
|
+
* });
|
|
775
|
+
*
|
|
776
|
+
* @example
|
|
777
|
+
* // List traces in a project
|
|
778
|
+
* const rootRuns = client.listRuns({
|
|
779
|
+
* projectName: "<your_project>",
|
|
780
|
+
* execution_order: 1,
|
|
781
|
+
* });
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
* // List runs without errors
|
|
785
|
+
* const correctRuns = client.listRuns({
|
|
786
|
+
* projectName: "<your_project>",
|
|
787
|
+
* error: false,
|
|
788
|
+
* });
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* // List runs by run ID
|
|
792
|
+
* const runIds = [
|
|
793
|
+
* "a36092d2-4ad5-4fb4-9c0d-0dba9a2ed836",
|
|
794
|
+
* "9398e6be-964f-4aa4-8ae9-ad78cd4b7074",
|
|
795
|
+
* ];
|
|
796
|
+
* const selectedRuns = client.listRuns({ run_ids: runIds });
|
|
797
|
+
*
|
|
798
|
+
* @example
|
|
799
|
+
* // List all "chain" type runs that took more than 10 seconds and had `total_tokens` greater than 5000
|
|
800
|
+
* const chainRuns = client.listRuns({
|
|
801
|
+
* projectName: "<your_project>",
|
|
802
|
+
* filter: 'and(eq(run_type, "chain"), gt(latency, 10), gt(total_tokens, 5000))',
|
|
803
|
+
* });
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* // List all runs called "extractor" whose root of the trace was assigned feedback "user_score" score of 1
|
|
807
|
+
* const goodExtractorRuns = client.listRuns({
|
|
808
|
+
* projectName: "<your_project>",
|
|
809
|
+
* filter: 'eq(name, "extractor")',
|
|
810
|
+
* traceFilter: 'and(eq(feedback_key, "user_score"), eq(feedback_score, 1))',
|
|
811
|
+
* });
|
|
812
|
+
*
|
|
813
|
+
* @example
|
|
814
|
+
* // List all runs that started after a specific timestamp and either have "error" not equal to null or a "Correctness" feedback score equal to 0
|
|
815
|
+
* const complexRuns = client.listRuns({
|
|
816
|
+
* projectName: "<your_project>",
|
|
817
|
+
* filter: 'and(gt(start_time, "2023-07-15T12:34:56Z"), or(neq(error, null), and(eq(feedback_key, "Correctness"), eq(feedback_score, 0.0))))',
|
|
818
|
+
* });
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* // List all runs where `tags` include "experimental" or "beta" and `latency` is greater than 2 seconds
|
|
822
|
+
* const taggedRuns = client.listRuns({
|
|
823
|
+
* projectName: "<your_project>",
|
|
824
|
+
* filter: 'and(or(has(tags, "experimental"), has(tags, "beta")), gt(latency, 2))',
|
|
825
|
+
* });
|
|
826
|
+
*/
|
|
827
|
+
async *listRuns(props) {
|
|
828
|
+
const { projectId, projectName, parentRunId, traceId, referenceExampleId, startTime, executionOrder, runType, error, id, query, filter, traceFilter, limit, } = props;
|
|
747
829
|
let projectIds = [];
|
|
748
830
|
if (projectId) {
|
|
749
831
|
projectIds = Array.isArray(projectId) ? projectId : [projectId];
|
|
@@ -761,6 +843,7 @@ class Client {
|
|
|
761
843
|
reference_example: referenceExampleId,
|
|
762
844
|
query,
|
|
763
845
|
filter,
|
|
846
|
+
trace_filter: traceFilter,
|
|
764
847
|
execution_order: executionOrder,
|
|
765
848
|
parent_run: parentRunId ? [parentRunId] : null,
|
|
766
849
|
start_time: startTime ? startTime.toISOString() : null,
|
package/dist/client.d.ts
CHANGED
|
@@ -12,20 +12,82 @@ interface ClientConfig {
|
|
|
12
12
|
autoBatchTracing?: boolean;
|
|
13
13
|
pendingAutoBatchedRunLimit?: number;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Represents the parameters for listing runs (spans) from the Langsmith server.
|
|
17
|
+
*/
|
|
15
18
|
interface ListRunsParams {
|
|
19
|
+
/**
|
|
20
|
+
* The ID or IDs of the project(s) to filter by.
|
|
21
|
+
*/
|
|
16
22
|
projectId?: string | string[];
|
|
23
|
+
/**
|
|
24
|
+
* The name or names of the project(s) to filter by.
|
|
25
|
+
*/
|
|
17
26
|
projectName?: string | string[];
|
|
27
|
+
/**
|
|
28
|
+
* The ID of the trace to filter by.
|
|
29
|
+
*/
|
|
18
30
|
traceId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The execution order to filter by.
|
|
33
|
+
*/
|
|
19
34
|
executionOrder?: number;
|
|
35
|
+
/**
|
|
36
|
+
* The ID of the parent run to filter by.
|
|
37
|
+
*/
|
|
20
38
|
parentRunId?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The ID of the reference example to filter by.
|
|
41
|
+
*/
|
|
21
42
|
referenceExampleId?: string;
|
|
43
|
+
/**
|
|
44
|
+
* The start time to filter by.
|
|
45
|
+
*/
|
|
22
46
|
startTime?: Date;
|
|
47
|
+
/**
|
|
48
|
+
* The run type to filter by.
|
|
49
|
+
*/
|
|
23
50
|
runType?: string;
|
|
51
|
+
/**
|
|
52
|
+
* Indicates whether to filter by error runs.
|
|
53
|
+
*/
|
|
24
54
|
error?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The ID or IDs of the runs to filter by.
|
|
57
|
+
*/
|
|
25
58
|
id?: string[];
|
|
59
|
+
/**
|
|
60
|
+
* The maximum number of runs to retrieve.
|
|
61
|
+
*/
|
|
26
62
|
limit?: number;
|
|
63
|
+
/**
|
|
64
|
+
* The query string to filter by.
|
|
65
|
+
*/
|
|
27
66
|
query?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The filter string to apply.
|
|
69
|
+
*
|
|
70
|
+
* Run Filtering:
|
|
71
|
+
* Listing runs with query params is useful for simple queries, but doesn't support many common needs, such as filtering by metadata, tags, or other fields.
|
|
72
|
+
* LangSmith supports a filter query language to permit more complex filtering operations when fetching runs. This guide will provide a high level overview of the grammar as well as a few examples of when it can be useful.
|
|
73
|
+
* If you'd prefer a more visual guide, you can get a taste of the language by viewing the table of runs on any of your projects' pages. We provide some recommended filters to get you started that you can copy and use the SDK.
|
|
74
|
+
*
|
|
75
|
+
* Grammar:
|
|
76
|
+
* The filtering grammar is based on common comparators on fields in the run object. Supported comparators include:
|
|
77
|
+
* - gte (greater than or equal to)
|
|
78
|
+
* - gt (greater than)
|
|
79
|
+
* - lte (less than or equal to)
|
|
80
|
+
* - lt (less than)
|
|
81
|
+
* - eq (equal to)
|
|
82
|
+
* - neq (not equal to)
|
|
83
|
+
* - has (check if run contains a tag or metadata json blob)
|
|
84
|
+
* - search (search for a substring in a string field)
|
|
85
|
+
*/
|
|
28
86
|
filter?: string;
|
|
87
|
+
/**
|
|
88
|
+
* The trace filter string to apply. Uses the same grammar as the filter string.
|
|
89
|
+
*/
|
|
90
|
+
traceFilter?: string;
|
|
29
91
|
}
|
|
30
92
|
interface UploadCSVParams {
|
|
31
93
|
csvFile: Blob;
|
|
@@ -135,7 +197,88 @@ export declare class Client {
|
|
|
135
197
|
projectOpts?: ProjectOptions;
|
|
136
198
|
}): Promise<string>;
|
|
137
199
|
private _loadChildRuns;
|
|
138
|
-
|
|
200
|
+
/**
|
|
201
|
+
* List runs from the LangSmith server.
|
|
202
|
+
* @param projectId - The ID of the project to filter by.
|
|
203
|
+
* @param projectName - The name of the project to filter by.
|
|
204
|
+
* @param parentRunId - The ID of the parent run to filter by.
|
|
205
|
+
* @param traceId - The ID of the trace to filter by.
|
|
206
|
+
* @param referenceExampleId - The ID of the reference example to filter by.
|
|
207
|
+
* @param startTime - The start time to filter by.
|
|
208
|
+
* @param executionOrder - The execution order to filter by.
|
|
209
|
+
* @param runType - The run type to filter by.
|
|
210
|
+
* @param error - Indicates whether to filter by error runs.
|
|
211
|
+
* @param id - The ID of the run to filter by.
|
|
212
|
+
* @param query - The query string to filter by.
|
|
213
|
+
* @param filter - The filter string to apply to the run spans.
|
|
214
|
+
* @param traceFilter - The filter string to apply on the root run of the trace.
|
|
215
|
+
* @param limit - The maximum number of runs to retrieve.
|
|
216
|
+
* @returns {AsyncIterable<Run>} - The runs.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* // List all runs in a project
|
|
220
|
+
* const projectRuns = client.listRuns({ projectName: "<your_project>" });
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* // List LLM and Chat runs in the last 24 hours
|
|
224
|
+
* const todaysLLMRuns = client.listRuns({
|
|
225
|
+
* projectName: "<your_project>",
|
|
226
|
+
* start_time: new Date(Date.now() - 24 * 60 * 60 * 1000),
|
|
227
|
+
* run_type: "llm",
|
|
228
|
+
* });
|
|
229
|
+
*
|
|
230
|
+
* @example
|
|
231
|
+
* // List traces in a project
|
|
232
|
+
* const rootRuns = client.listRuns({
|
|
233
|
+
* projectName: "<your_project>",
|
|
234
|
+
* execution_order: 1,
|
|
235
|
+
* });
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* // List runs without errors
|
|
239
|
+
* const correctRuns = client.listRuns({
|
|
240
|
+
* projectName: "<your_project>",
|
|
241
|
+
* error: false,
|
|
242
|
+
* });
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* // List runs by run ID
|
|
246
|
+
* const runIds = [
|
|
247
|
+
* "a36092d2-4ad5-4fb4-9c0d-0dba9a2ed836",
|
|
248
|
+
* "9398e6be-964f-4aa4-8ae9-ad78cd4b7074",
|
|
249
|
+
* ];
|
|
250
|
+
* const selectedRuns = client.listRuns({ run_ids: runIds });
|
|
251
|
+
*
|
|
252
|
+
* @example
|
|
253
|
+
* // List all "chain" type runs that took more than 10 seconds and had `total_tokens` greater than 5000
|
|
254
|
+
* const chainRuns = client.listRuns({
|
|
255
|
+
* projectName: "<your_project>",
|
|
256
|
+
* filter: 'and(eq(run_type, "chain"), gt(latency, 10), gt(total_tokens, 5000))',
|
|
257
|
+
* });
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* // List all runs called "extractor" whose root of the trace was assigned feedback "user_score" score of 1
|
|
261
|
+
* const goodExtractorRuns = client.listRuns({
|
|
262
|
+
* projectName: "<your_project>",
|
|
263
|
+
* filter: 'eq(name, "extractor")',
|
|
264
|
+
* traceFilter: 'and(eq(feedback_key, "user_score"), eq(feedback_score, 1))',
|
|
265
|
+
* });
|
|
266
|
+
*
|
|
267
|
+
* @example
|
|
268
|
+
* // List all runs that started after a specific timestamp and either have "error" not equal to null or a "Correctness" feedback score equal to 0
|
|
269
|
+
* const complexRuns = client.listRuns({
|
|
270
|
+
* projectName: "<your_project>",
|
|
271
|
+
* filter: 'and(gt(start_time, "2023-07-15T12:34:56Z"), or(neq(error, null), and(eq(feedback_key, "Correctness"), eq(feedback_score, 0.0))))',
|
|
272
|
+
* });
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* // List all runs where `tags` include "experimental" or "beta" and `latency` is greater than 2 seconds
|
|
276
|
+
* const taggedRuns = client.listRuns({
|
|
277
|
+
* projectName: "<your_project>",
|
|
278
|
+
* filter: 'and(or(has(tags, "experimental"), has(tags, "beta")), gt(latency, 2))',
|
|
279
|
+
* });
|
|
280
|
+
*/
|
|
281
|
+
listRuns(props: ListRunsParams): AsyncIterable<Run>;
|
|
139
282
|
shareRun(runId: string, { shareId }?: {
|
|
140
283
|
shareId?: string;
|
|
141
284
|
}): Promise<string>;
|
package/dist/client.js
CHANGED
|
@@ -716,7 +716,89 @@ export class Client {
|
|
|
716
716
|
}
|
|
717
717
|
return run;
|
|
718
718
|
}
|
|
719
|
-
|
|
719
|
+
/**
|
|
720
|
+
* List runs from the LangSmith server.
|
|
721
|
+
* @param projectId - The ID of the project to filter by.
|
|
722
|
+
* @param projectName - The name of the project to filter by.
|
|
723
|
+
* @param parentRunId - The ID of the parent run to filter by.
|
|
724
|
+
* @param traceId - The ID of the trace to filter by.
|
|
725
|
+
* @param referenceExampleId - The ID of the reference example to filter by.
|
|
726
|
+
* @param startTime - The start time to filter by.
|
|
727
|
+
* @param executionOrder - The execution order to filter by.
|
|
728
|
+
* @param runType - The run type to filter by.
|
|
729
|
+
* @param error - Indicates whether to filter by error runs.
|
|
730
|
+
* @param id - The ID of the run to filter by.
|
|
731
|
+
* @param query - The query string to filter by.
|
|
732
|
+
* @param filter - The filter string to apply to the run spans.
|
|
733
|
+
* @param traceFilter - The filter string to apply on the root run of the trace.
|
|
734
|
+
* @param limit - The maximum number of runs to retrieve.
|
|
735
|
+
* @returns {AsyncIterable<Run>} - The runs.
|
|
736
|
+
*
|
|
737
|
+
* @example
|
|
738
|
+
* // List all runs in a project
|
|
739
|
+
* const projectRuns = client.listRuns({ projectName: "<your_project>" });
|
|
740
|
+
*
|
|
741
|
+
* @example
|
|
742
|
+
* // List LLM and Chat runs in the last 24 hours
|
|
743
|
+
* const todaysLLMRuns = client.listRuns({
|
|
744
|
+
* projectName: "<your_project>",
|
|
745
|
+
* start_time: new Date(Date.now() - 24 * 60 * 60 * 1000),
|
|
746
|
+
* run_type: "llm",
|
|
747
|
+
* });
|
|
748
|
+
*
|
|
749
|
+
* @example
|
|
750
|
+
* // List traces in a project
|
|
751
|
+
* const rootRuns = client.listRuns({
|
|
752
|
+
* projectName: "<your_project>",
|
|
753
|
+
* execution_order: 1,
|
|
754
|
+
* });
|
|
755
|
+
*
|
|
756
|
+
* @example
|
|
757
|
+
* // List runs without errors
|
|
758
|
+
* const correctRuns = client.listRuns({
|
|
759
|
+
* projectName: "<your_project>",
|
|
760
|
+
* error: false,
|
|
761
|
+
* });
|
|
762
|
+
*
|
|
763
|
+
* @example
|
|
764
|
+
* // List runs by run ID
|
|
765
|
+
* const runIds = [
|
|
766
|
+
* "a36092d2-4ad5-4fb4-9c0d-0dba9a2ed836",
|
|
767
|
+
* "9398e6be-964f-4aa4-8ae9-ad78cd4b7074",
|
|
768
|
+
* ];
|
|
769
|
+
* const selectedRuns = client.listRuns({ run_ids: runIds });
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* // List all "chain" type runs that took more than 10 seconds and had `total_tokens` greater than 5000
|
|
773
|
+
* const chainRuns = client.listRuns({
|
|
774
|
+
* projectName: "<your_project>",
|
|
775
|
+
* filter: 'and(eq(run_type, "chain"), gt(latency, 10), gt(total_tokens, 5000))',
|
|
776
|
+
* });
|
|
777
|
+
*
|
|
778
|
+
* @example
|
|
779
|
+
* // List all runs called "extractor" whose root of the trace was assigned feedback "user_score" score of 1
|
|
780
|
+
* const goodExtractorRuns = client.listRuns({
|
|
781
|
+
* projectName: "<your_project>",
|
|
782
|
+
* filter: 'eq(name, "extractor")',
|
|
783
|
+
* traceFilter: 'and(eq(feedback_key, "user_score"), eq(feedback_score, 1))',
|
|
784
|
+
* });
|
|
785
|
+
*
|
|
786
|
+
* @example
|
|
787
|
+
* // List all runs that started after a specific timestamp and either have "error" not equal to null or a "Correctness" feedback score equal to 0
|
|
788
|
+
* const complexRuns = client.listRuns({
|
|
789
|
+
* projectName: "<your_project>",
|
|
790
|
+
* filter: 'and(gt(start_time, "2023-07-15T12:34:56Z"), or(neq(error, null), and(eq(feedback_key, "Correctness"), eq(feedback_score, 0.0))))',
|
|
791
|
+
* });
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* // List all runs where `tags` include "experimental" or "beta" and `latency` is greater than 2 seconds
|
|
795
|
+
* const taggedRuns = client.listRuns({
|
|
796
|
+
* projectName: "<your_project>",
|
|
797
|
+
* filter: 'and(or(has(tags, "experimental"), has(tags, "beta")), gt(latency, 2))',
|
|
798
|
+
* });
|
|
799
|
+
*/
|
|
800
|
+
async *listRuns(props) {
|
|
801
|
+
const { projectId, projectName, parentRunId, traceId, referenceExampleId, startTime, executionOrder, runType, error, id, query, filter, traceFilter, limit, } = props;
|
|
720
802
|
let projectIds = [];
|
|
721
803
|
if (projectId) {
|
|
722
804
|
projectIds = Array.isArray(projectId) ? projectId : [projectId];
|
|
@@ -734,6 +816,7 @@ export class Client {
|
|
|
734
816
|
reference_example: referenceExampleId,
|
|
735
817
|
query,
|
|
736
818
|
filter,
|
|
819
|
+
trace_filter: traceFilter,
|
|
737
820
|
execution_order: executionOrder,
|
|
738
821
|
parent_run: parentRunId ? [parentRunId] : null,
|
|
739
822
|
start_time: startTime ? startTime.toISOString() : null,
|
package/dist/index.cjs
CHANGED
|
@@ -6,4 +6,4 @@ Object.defineProperty(exports, "Client", { enumerable: true, get: function () {
|
|
|
6
6
|
var run_trees_js_1 = require("./run_trees.cjs");
|
|
7
7
|
Object.defineProperty(exports, "RunTree", { enumerable: true, get: function () { return run_trees_js_1.RunTree; } });
|
|
8
8
|
// Update using yarn bump-version
|
|
9
|
-
exports.__version__ = "0.1.
|
|
9
|
+
exports.__version__ = "0.1.8";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Client } from "./client.js";
|
|
2
2
|
export type { Dataset, Example, TracerSession, Run, Feedback, } from "./schemas.js";
|
|
3
3
|
export { RunTree, type RunTreeConfig } from "./run_trees.js";
|
|
4
|
-
export declare const __version__ = "0.1.
|
|
4
|
+
export declare const __version__ = "0.1.8";
|
package/dist/index.js
CHANGED