Awaits all pending trace batches. Useful for environments where you need to be sure that all tracing requests finish before execution ends, such as serverless environments.
A promise that resolves once all currently pending traces have sent.
Clone a public dataset to your own langsmith tenant. This operation is idempotent. If you already have a dataset with the given name, this function will do nothing.
The token of the public dataset to clone.
Optional
options: { datasetName?: string; sourceApiUrl?: string } = {}Additional options for cloning the dataset.
Optional
datasetName?: stringThe name of the dataset to create in your tenant. Defaults to the name of the public dataset.
Optional
sourceApiUrl?: stringThe URL of the langsmith server where the data is hosted. Defaults to the API URL of your current client.
Create an annotation queue on the LangSmith API.
The options for creating an annotation queue
The name of the annotation queue
Optional
description?: stringThe description of the annotation queue
Optional
queueId?: stringThe ID of the annotation queue
The created AnnotationQueue object
Creates a presigned feedback token and URL.
The token can be used to authorize feedback metrics without needing an API key. This is useful for giving browser-based applications the ability to submit feedback without needing to expose an API key.
The ID of the run.
The feedback key.
Additional options for the token.
Optional
expiration?: string | TimeDeltaThe expiration time for the token.
Optional
feedbackConfig?: FeedbackConfigA promise that resolves to a FeedbackIngestToken.
Optional
options: { description?: string; isPublic?: boolean; readme?: string; tags?: string[] }Get a run from an annotation queue at the specified index.
The ID of the annotation queue
The index of the run to retrieve
A Promise that resolves to a RunWithAnnotationQueueInfo object
List the annotation queues on the LangSmith API.
The options for listing annotation queues
Optional
limit?: numberThe maximum number of queues to return
Optional
name?: stringThe name of the queue to filter by
Optional
nameContains?: stringThe substring that the queue name should contain
Optional
queueIds?: string[]The IDs of the queues to filter by
An iterator of AnnotationQueue objects
Retrieves a list of presigned feedback tokens for a given run ID.
The ID of the run.
An async iterable of FeedbackIngestToken objects.
Optional
options: {List runs from the LangSmith server.
// List all runs in a project
const projectRuns = client.listRuns({ projectName: "<your_project>" });
// List LLM and Chat runs in the last 24 hours
const todaysLLMRuns = client.listRuns({
projectName: "<your_project>",
start_time: new Date(Date.now() - 24 * 60 * 60 * 1000),
run_type: "llm",
});
// List traces in a project
const rootRuns = client.listRuns({
projectName: "<your_project>",
execution_order: 1,
});
// List runs without errors
const correctRuns = client.listRuns({
projectName: "<your_project>",
error: false,
});
// List runs by run ID
const runIds = [
"a36092d2-4ad5-4fb4-9c0d-0dba9a2ed836",
"9398e6be-964f-4aa4-8ae9-ad78cd4b7074",
];
const selectedRuns = client.listRuns({ run_ids: runIds });
// List all "chain" type runs that took more than 10 seconds and had `total_tokens` greater than 5000
const chainRuns = client.listRuns({
projectName: "<your_project>",
filter: 'and(eq(run_type, "chain"), gt(latency, 10), gt(total_tokens, 5000))',
});
// List all runs called "extractor" whose root of the trace was assigned feedback "user_score" score of 1
const goodExtractorRuns = client.listRuns({
projectName: "<your_project>",
filter: 'eq(name, "extractor")',
traceFilter: 'and(eq(feedback_key, "user_score"), eq(feedback_score, 1))',
});
// 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
const complexRuns = client.listRuns({
projectName: "<your_project>",
filter: 'and(gt(start_time, "2023-07-15T12:34:56Z"), or(neq(error, null), and(eq(feedback_key, "Correctness"), eq(feedback_score, 0.0))))',
});
Get shared examples.
The share token to get examples for. A share token is the UUID (or LangSmith URL, including UUID) generated when explicitly marking an example as public.
Optional
options: { exampleIds?: string[] }Additional options for listing the examples.
Optional
exampleIds?: string[]A list of example IDs to filter by.
The shared examples.
Optional
run: RunOptional
sourceInfo: { [key: string]: any }Optional
options: { includeModel?: boolean }Optional
options: {Read an annotation queue with the specified queue ID.
The ID of the annotation queue to read
The AnnotationQueue object
Optional
datasetId: stringOptional
datasetName: stringGet dataset version by closest date or exact tag.
Use this to resolve the nearest version to a given timestamp or for a given tag.
The options for getting the dataset version
Optional
asOf?: string | DateThe timestamp of the dataset to retrieve
Optional
datasetId?: stringThe ID of the dataset
Optional
datasetName?: stringThe name of the dataset
Optional
tag?: stringThe tag of the dataset to retrieve
The dataset version
Optional
datasetId: stringOptional
datasetName: stringLets you run a similarity search query on a dataset.
Requires the dataset to be indexed. Please see the indexDataset
method to set up indexing.
The input on which to run the similarity search. Must have the same schema as the dataset.
The dataset to search for similar examples.
The maximum number of examples to return. Will return the top limit
most
similar examples in order of most similar to least similar. If no similar
examples are found, random examples will be returned.
A filter string to apply to the search. Only examples will be returned that match the filter string. Some examples of filters
- eq(metadata.mykey, "value")
- and(neq(metadata.my.nested.key, "value"), neq(metadata.mykey, "value"))
- or(eq(metadata.mykey, "value"), eq(metadata.mykey, "othervalue"))
A list of similar examples.
Update an annotation queue with the specified queue ID.
The ID of the annotation queue to update
The options for updating the annotation queue
The new name for the annotation queue
Optional
description?: stringThe new description for the annotation queue
Update a dataset
The dataset details to update
The updated dataset
Updates a tag on a dataset.
If the tag is already assigned to a different version of this dataset, the tag will be moved to the new version. The as_of parameter is used to determine which version of the dataset to apply the new tags to.
It must be an exact version of the dataset to succeed. You can use the "readDatasetVersion" method to find the exact version to apply the tags to.
Update examples with attachments using multipart form data.
List of ExampleUpdateWithAttachments objects to upsert
Promise with the update response
Optional
options: {Upload examples with attachments using multipart form data.
List of ExampleUploadWithAttachments objects to upload
Promise with the upload response
Static
get
Add runs to an annotation queue with the specified queue ID.