langsmith
Description
LangSmith Client SDK
This package contains the Python client for interacting with the LangSmith platform.
To install:
pip install -U langsmith
export LANGSMITH_TRACING=true
export LANGSMITH_API_KEY=ls_...Then trace:
import openai
from langsmith.wrappers import wrap_openai
from langsmith import traceable
# Auto-trace LLM calls in-context
client = wrap_openai(openai.Client())
@traceable # Auto-trace this function
def pipeline(user_input: str):
result = client.chat.completions.create(
messages=[{"role": "user", "content": user_input}],
model="gpt-3.5-turbo"
)
return result.choices[0].message.content
pipeline("Hello, world!")See the resulting nested trace 🌐 here.
LangSmith helps you and your team develop and evaluate language models and intelligent agents. It is compatible with any LLM application.
Cookbook: For tutorials on how to get more value out of LangSmith, check out the Langsmith Cookbook repo.
A typical workflow looks like:
- Set up an account with LangSmith.
- Log traces while debugging and prototyping.
- Run benchmark evaluations and continuously improve with the collected data.
We'll walk through these steps in more detail below.
1. Connect to LangSmith
Sign up for LangSmith using your GitHub, Discord accounts, or an email address and password. If you sign up with an email, make sure to verify your email address before logging in.
Then, create a unique API key on the Settings Page, which is found in the menu at the top right corner of the page.
[!NOTE] Save the API Key in a secure location. It will not be shown again.
2. Log Traces
You can log traces natively using the LangSmith SDK or within your LangChain application.
Logging Traces with LangChain
LangSmith seamlessly integrates with the Python LangChain library to record traces from your LLM applications.
- Copy the environment variables from the Settings Page and add them to your application.
Tracing can be activated by setting the following environment variables or by manually specifying the LangChainTracer.
import os
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_ENDPOINT"] = "https://api.smith.langchain.com"
# os.environ["LANGSMITH_ENDPOINT"] = "https://eu.api.smith.langchain.com" # If signed up in the EU region
os.environ["LANGSMITH_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>"
# os.environ["LANGSMITH_PROJECT"] = "My Project Name" # Optional: "default" is used if not set
# os.environ["LANGSMITH_WORKSPACE_ID"] = "<YOUR-WORKSPACE-ID>" # Required for org-scoped API keysTip: Projects are groups of traces. All runs are logged to a project. If not specified, the project is set to
default.
- Run an Agent, Chain, or Language Model in LangChain
If the environment variables are correctly set, your application will automatically connect to the LangSmith platform.
from langchain_core.runnables import chain
@chain
def add_val(x: dict) -> dict:
return {"val": x["val"] + 1}
add_val({"val": 1})Logging Traces Outside LangChain
You can still use the LangSmith development platform without depending on any LangChain code.
- Copy the environment variables from the Settings Page and add them to your application.
import os
os.environ["LANGSMITH_ENDPOINT"] = "https://api.smith.langchain.com"
os.environ["LANGSMITH_API_KEY"] = "<YOUR-LANGSMITH-API-KEY>"
# os.environ["LANGSMITH_PROJECT"] = "My Project Name" # Optional: "default" is used if not set- Log traces
The easiest way to log traces using the SDK is via the @traceable decorator. Below is an example.
from datetime import datetime
from typing import List, Optional, Tuple
import openai
from langsmith import traceable
from langsmith.wrappers import wrap_openai
client = wrap_openai(openai.Client())
@traceable
def argument_generator(query: str, additional_description: str = "") -> str:
return client.chat.completions.create(
[
{"role": "system", "content": "You are a debater making an argument on a topic."
f"{additional_description}"
f" The current time is {datetime.now()}"},
{"role": "user", "content": f"The discussion topic is {query}"}
]
).choices[0].message.content
@traceable
def argument_chain(query: str, additional_description: str = "") -> str:
argument = argument_generator(query, additional_description)
# ... Do other processing or call other functions...
return argument
argument_chain("Why is blue better than orange?")Alternatively, you can manually log events using the Client directly or using a RunTree, which is what the traceable decorator is meant to manage for you!
A RunTree tracks your application. Each RunTree object is required to have a name and run_type. These and other important attributes are as follows:
name:str- used to identify the component's purposerun_type:str- Currently one of "llm", "chain" or "tool"; more options will be added in the futureinputs:dict- the inputs to the componentoutputs:Optional[dict]- the (optional) returned values from the componenterror:Optional[str]- Any error messages that may have arisen during the call
from langsmith.run_trees import RunTree
parent_run = RunTree(
name="My Chat Bot",
run_type="chain",
inputs={"text": "Summarize this morning's meetings."},
# project_name= "Defaults to the LANGSMITH_PROJECT env var"
)
parent_run.post()
# .. My Chat Bot calls an LLM
child_llm_run = parent_run.create_child(
name="My Proprietary LLM",
run_type="llm",
inputs={
"prompts": [
"You are an AI Assistant. The time is XYZ."
" Summarize this morning's meetings."
]
},
)
child_llm_run.post()
child_llm_run.end(
outputs={
"generations": [
"I should use the transcript_loader tool"
" to fetch meeting_transcripts from XYZ"
]
}
)
child_llm_run.patch()
# .. My Chat Bot takes the LLM output and calls
# a tool / function for fetching transcripts ..
child_tool_run = parent_run.create_child(
name="transcript_loader",
run_type="tool",
inputs={"date": "XYZ", "content_type": "meeting_transcripts"},
)
child_tool_run.post()
# The tool returns meeting notes to the chat bot
child_tool_run.end(outputs={"meetings": ["Meeting1 notes.."]})
child_tool_run.patch()
child_chain_run = parent_run.create_child(
name="Unreliable Component",
run_type="tool",
inputs={"input": "Summarize these notes..."},
)
child_chain_run.post()
try:
# .... the component does work
raise ValueError("Something went wrong")
child_chain_run.end(outputs={"output": "foo"}
child_chain_run.patch()
except Exception as e:
child_chain_run.end(error=f"I errored again {e}")
child_chain_run.patch()
pass
# .. The chat agent recovers
parent_run.end(outputs={"output": ["The meeting notes are as follows:..."]})
res = parent_run.patch()
res.result()Create a Dataset from Existing Runs
Once your runs are stored in LangSmith, you can convert them into a dataset. For this example, we will do so using the Client, but you can also do this using the web interface, as explained in the LangSmith docs.
from langsmith import Client
client = Client()
dataset_name = "Example Dataset"
# We will only use examples from the top level AgentExecutor run here,
# and exclude runs that errored.
runs = client.list_runs(
project_name="my_project",
execution_order=1,
error=False,
)
dataset = client.create_dataset(dataset_name, description="An example dataset")
for run in runs:
client.create_example(
inputs=run.inputs,
outputs=run.outputs,
dataset_id=dataset.id,
)Evaluating Runs
Check out the LangSmith Testing & Evaluation dos for up-to-date workflows.
For generating automated feedback on individual runs, you can run evaluations directly using the LangSmith client.
from typing import Optional
from langsmith.evaluation import StringEvaluator
def jaccard_chars(output: str, answer: str) -> float:
"""Naive Jaccard similarity between two strings."""
prediction_chars = set(output.strip().lower())
answer_chars = set(answer.strip().lower())
intersection = prediction_chars.intersection(answer_chars)
union = prediction_chars.union(answer_chars)
return len(intersection) / len(union)
def grader(run_input: str, run_output: str, answer: Optional[str]) -> dict:
"""Compute the score and/or label for this run."""
if answer is None:
value = "AMBIGUOUS"
score = 0.5
else:
score = jaccard_chars(run_output, answer)
value = "CORRECT" if score > 0.9 else "INCORRECT"
return dict(score=score, value=value)
evaluator = StringEvaluator(evaluation_name="Jaccard", grading_function=grader)
runs = client.list_runs(
project_name="my_project",
execution_order=1,
error=False,
)
for run in runs:
client.evaluate_run(run, evaluator)Integrations
LangSmith easily integrates with your favorite LLM framework.
OpenAI SDK
We provide a convenient wrapper for the OpenAI SDK.
In order to use, you first need to set your LangSmith API key.
export LANGSMITH_API_KEY=<your-api-key>Next, you will need to install the LangSmith SDK:
pip install -U langsmithAfter that, you can wrap the OpenAI client:
from openai import OpenAI
from langsmith import wrappers
client = wrappers.wrap_openai(OpenAI())Now, you can use the OpenAI client as you normally would, but now everything is logged to LangSmith!
client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Say this is a test"}],
)Oftentimes, you use the OpenAI client inside of other functions.
You can get nested traces by using this wrapped client and decorating those functions with @traceable.
See this documentation for more documentation how to use this decorator
from langsmith import traceable
@traceable(name="Call OpenAI")
def my_function(text: str):
return client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": f"Say {text}"}],
)
my_function("hello world")Instructor
We provide a convenient integration with Instructor, largely by virtue of it essentially just using the OpenAI SDK.
In order to use, you first need to set your LangSmith API key.
export LANGSMITH_API_KEY=<your-api-key>Next, you will need to install the LangSmith SDK:
pip install -U langsmithAfter that, you can wrap the OpenAI client:
from openai import OpenAI
from langsmith import wrappers
client = wrappers.wrap_openai(OpenAI())After this, you can patch the OpenAI client using instructor:
import instructor
client = instructor.patch(OpenAI())Now, you can use instructor as you normally would, but now everything is logged to LangSmith!
from pydantic import BaseModel
class UserDetail(BaseModel):
name: str
age: int
user = client.chat.completions.create(
model="gpt-3.5-turbo",
response_model=UserDetail,
messages=[
{"role": "user", "content": "Extract Jason is 25 years old"},
]
)Oftentimes, you use instructor inside of other functions.
You can get nested traces by using this wrapped client and decorating those functions with @traceable.
See this documentation for more documentation how to use this decorator
@traceable()
def my_function(text: str) -> UserDetail:
return client.chat.completions.create(
model="gpt-3.5-turbo",
response_model=UserDetail,
messages=[
{"role": "user", "content": f"Extract {text}"},
]
)
my_function("Jason is 25 years old")Pytest Plugin
The LangSmith pytest plugin lets Python developers define their datasets and evaluations as pytest test cases. See online docs for more information.
This plugin is installed as part of the LangSmith SDK, and is enabled by default. See also official pytest docs: How to install and use plugins
Additional Documentation
To learn more about the LangSmith platform, check out the docs.
License
The LangSmith SDK is licensed under the MIT License.
The copyright information for certain dependencies' are reproduced in their corresponding COPYRIGHT.txt files in this repo, including the following:
Classes
ApiKeyAuth
API key authentication for write replicas.
ServiceAuth
Service-to-service JWT authentication for write replicas.
AuthHeaders
Custom authentication headers for write replicas.
WriteReplica
Configuration for a write replica endpoint.
RunTree
Run Schema with back-references for posting runs.
ReplicaAuth
CacheEntry
A single cache entry with metadata for TTL tracking.
CacheMetrics
Cache performance metrics.
PromptCache
Thread-safe LRU cache with background thread refresh.
AsyncPromptCache
Thread-safe LRU cache with asyncio task refresh.
Cache
Deprecated alias for PromptCache. Use PromptCache instead.
AsyncCache
Deprecated alias for AsyncPromptCache. Use AsyncPromptCache instead.
LangSmithError
An error occurred while communicating with the LangSmith API.
LangSmithAPIError
Internal server error while communicating with LangSmith.
LangSmithRequestTimeout
Client took too long to send request body.
LangSmithUserError
User error caused an exception when communicating with LangSmith.
LangSmithRateLimitError
You have exceeded the rate limit for the LangSmith API.
LangSmithAuthError
Couldn't authenticate with the LangSmith API.
LangSmithNotFoundError
Couldn't find the requested resource.
LangSmithConflictError
The resource already exists.
LangSmithConnectionError
Couldn't connect to the LangSmith API.
LangSmithExceptionGroup
Port of ExceptionGroup for Py < 3.11.
LangSmithWarning
Base class for warnings.
LangSmithMissingAPIKeyWarning
Warning for missing API key.
FilterPoolFullWarning
Filter urllib3 warnings logged when the connection pool isn't reused.
FilterLangSmithRetry
Filter for retries from this lib.
LangSmithRetry
Wrapper to filter logs with this name.
ContextThreadPoolExecutor
ThreadPoolExecutor that copies the context to the child thread.
LangSmithPlugin
Plugin for rendering LangSmith results.
StringNode
String node extracted from the data.
StringNodeProcessor
Processes a list of string nodes for masking.
ReplacerOptions
Configuration options for replacing sensitive data.
StringNodeRule
Declarative rule used for replacing sensitive data.
RuleNodeProcessor
String node processor that uses a list of rules to replace sensitive data.
CallableNodeProcessor
String node processor that uses a callable function to replace sensitive data.
_NULL_SENTRY
A sentinel singleton class used to distinguish omitted keyword arguments
_Matcher
A class for making assertions on expectation values.
_Expect
A class for setting expectations on test results.
LangSmithExtra
Any additional info to be injected into the run dynamically.
SupportsLangsmithExtra
Implementations of this Protocol accept an optional langsmith_extra parameter.
trace
Manage a LangSmith run in context.
ZoneInfo
Introduced in python 3.9.
TracerProvider
Used for optional OTEL tracing.
ListThreadsItem
Item returned by :meth:Client.list_threads.
Client
Client for interacting with the LangSmith API.
Attachment
Annotated type that will be stored as an attachment if used.
BinaryIOLike
Protocol for binary IO-like objects.
ExampleBase
Example base model.
ExampleCreate
Example upload with attachments.
ExampleUpsertWithAttachments
Example create with attachments.
AttachmentInfo
Info for an attachment.
Example
Example model.
ExampleSearch
Example returned via search.
AttachmentsOperations
Operations to perform on attachments.
ExampleUpdate
Example update with attachments.
DataType
Enum for dataset data types.
DatasetBase
Dataset base model.
DatasetTransformation
Schema for dataset transformations.
Dataset
Dataset ORM model.
DatasetVersion
Class representing a dataset version.
RunBase
Base Run schema.
Run
Run schema when loading from the DB.
RunTypeEnum
(Deprecated) Enum for run types. Use string directly.
RunLikeDict
Run-like dictionary, for type-hinting.
RunWithAnnotationQueueInfo
Run schema with annotation queue info.
FeedbackSourceBase
Base class for feedback sources.
APIFeedbackSource
API feedback source.
ModelFeedbackSource
Model feedback source.
FeedbackSourceType
Feedback source type.
FeedbackBase
Feedback schema.
FeedbackCategory
Specific value and label pair for feedback.
FeedbackConfig
Represents how a feedback value ought to be interpreted.
FeedbackCreate
Schema used for creating feedback.
Feedback
Schema for getting feedback.
TracerSession
TracerSession schema for the API.
TracerSessionResult
A project, hydrated with additional information.
BaseMessageLike
A protocol representing objects similar to BaseMessage.
DatasetShareSchema
Represents the schema for a dataset share.
AnnotationQueueRubricItem
Represents a rubric item assigned to an annotation queue.
AnnotationQueue
Represents an annotation queue.
AnnotationQueueWithDetails
Represents an annotation queue with details.
BatchIngestConfig
Configuration for batch ingestion.
LangSmithInfo
Information about the LangSmith server.
LangSmithSettings
Settings for the LangSmith tenant.
FeedbackIngestToken
Represents the schema for a feedback ingest token.
RunEvent
Run event schema.
TimeDeltaInput
Timedelta input schema.
DatasetDiffInfo
Represents the difference information between two datasets.
ComparativeExperiment
Represents a comparative experiment.
PromptCommit
Represents a Prompt with a manifest.
ListedPromptCommit
Represents a listed prompt commit with associated metadata.
Prompt
Represents a Prompt with metadata.
ListPromptsResponse
A list of prompts with metadata.
PromptSortField
Enum for sorting fields for prompts.
InputTokenDetails
Breakdown of input token counts.
OutputTokenDetails
Breakdown of output token counts.
InputCostDetails
Breakdown of input token costs.
OutputCostDetails
Breakdown of output token costs.
UsageMetadata
Usage metadata for a message, such as token counts.
ExtractedUsageMetadata
Usage metadata dictionary extracted from a run.
UpsertExamplesResponse
Response object returned from the upsert_examples_multipart method.
ExampleWithRuns
Example with runs.
ExperimentRunStats
Run statistics for an experiment.
ExperimentResults
Results container for experiment data with stats and examples.
InsightsReport
An Insights Report created by the Insights Agent over a tracing project.
FeedbackFormulaWeightedVariable
A feedback key and weight used when calculating feedback formulas.
FeedbackFormulaCreate
Schema used for creating a feedback formula.
FeedbackFormulaUpdate
Schema used for updating a feedback formula.
FeedbackFormula
Schema for getting feedback formulas.
FeedbackConfigSchema
Represents a feedback configuration for a tenant's feedback key.
TracingMiddleware
Middleware for propagating distributed tracing context using LangSmith.
AsyncClient
Async Client for interacting with the LangSmith API.
GitInfo
TracingExtra
TracingExtra
TracingExtra
ExecutionResult
Result of executing a command in a sandbox.
ResourceSpec
Resource specification for a sandbox.
Volume
Represents a persistent volume.
VolumeMountSpec
Specification for mounting a volume in a sandbox template.
SandboxTemplate
Represents a SandboxTemplate.
ResourceStatus
Lightweight provisioning status for any async-created resource.
Pool
Represents a Sandbox Pool for pre-provisioned sandboxes.
OutputChunk
A single chunk of streaming output from command execution.
CommandHandle
Handle to a running command with streaming output and auto-reconnect.
AsyncCommandHandle
Async handle to a running command with streaming output and auto-reconnect.
AsyncSandboxClient
Async client for interacting with the Sandbox Server API.
SandboxClient
Client for interacting with the Sandbox Server API.
Sandbox
Represents an active sandbox for running commands and file operations.
SandboxClientError
Base exception for sandbox client errors.
SandboxAPIError
Raised when the API endpoint returns an unexpected error.
SandboxAuthenticationError
Raised when authentication fails (invalid or missing API key).
SandboxConnectionError
Raised when connection to the sandbox server fails.
SandboxServerReloadError
Raised when the server sends a 1001 Going Away close frame.
ResourceNotFoundError
Raised when a resource is not found.
ResourceTimeoutError
Raised when an operation times out.
ResourceInUseError
Raised when deleting a resource that is still in use.
ResourceAlreadyExistsError
Raised when creating a resource that already exists.
ResourceNameConflictError
Raised when updating a resource name to one that already exists.
ValidationError
Raised when request validation fails.
QuotaExceededError
Raised when organization quota limits are exceeded.
ResourceCreationError
Raised when resource provisioning fails.
DataplaneNotConfiguredError
Raised when dataplane_url is not available for the sandbox.
SandboxNotReadyError
Raised when attempting to interact with a sandbox that is not ready.
SandboxOperationError
Raised when a sandbox operation fails (run, read, write).
CommandTimeoutError
Raised when a command exceeds its timeout.
RetryTransport
Sync httpx transport that retries on transient errors.
AsyncRetryTransport
Async httpx transport that retries on transient errors.
AsyncSandbox
Represents an active sandbox for running commands and file operations async.
Category
A category for categorical feedback.
FeedbackConfig
Configuration to define a type of feedback.
EvaluationResult
Evaluation result.
EvaluationResults
Batch evaluation results.
RunEvaluator
Evaluator interface class.
ComparisonEvaluationResult
Feedback scores for the results of comparative evaluations.
DynamicRunEvaluator
A dynamic evaluator that wraps a function and transforms it into a RunEvaluator.
DynamicComparisonRunEvaluator
Compare predictions (as traces) from 2 or more runs.
AsyncExperimentResults
CategoricalScoreConfig
Configuration for a categorical score.
ContinuousScoreConfig
Configuration for a continuous score.
LLMEvaluator
A class for building LLM-as-a-judge evaluators.
ExperimentResultRow
ExperimentResults
Represents the results of an evaluate() call.
ComparativeExperimentResults
Represents the results of an evaluate_comparative() call.
StringEvaluator
Grades the run's string input, output, and optional answer.
Functions
get_cached_client
configure
Configure global LangSmith tracing context.
validate_extracted_usage_metadata
Validate that the dict only contains allowed keys.
configure_global_prompt_cache
Configure the global prompt cache.
configure_global_async_prompt_cache
Configure the global prompt cache.
get_invalid_prompt_identifier_msg
Get the error message for an invalid prompt identifier.
tracing_is_enabled
Return True if tracing is enabled.
test_tracking_is_disabled
Return True if testing is enabled.
xor_args
Validate specified keyword args are mutually exclusive.
raise_for_status_with_text
Raise an error with the response text.
get_enum_value
Get the value of a string enum.
log_once
Log a message at the specified level, but only once.
get_messages_from_inputs
Extract messages from the given inputs dictionary.
get_message_generation_from_outputs
Retrieve the message generation from the given outputs.
get_prompt_from_inputs
Retrieve the prompt from the given inputs.
get_llm_generation_from_outputs
Get the LLM generation from the outputs.
get_docker_compose_command
Get the correct docker compose command for this system.
convert_langchain_message
Convert a LangChain message to an example.
is_base_message_like
Check if the given object is similar to BaseMessage.
is_env_var_truish
Check if the given environment variable is truish.
get_env_var
Retrieve an environment variable from a list of namespaces.
get_tracer_project
Get the project name for a LangSmith tracer.
filter_logs
Temporarily adds specified filters to a logger.
get_cache_dir
Get the testing cache directory.
filter_request_headers
Filter request headers based on ignore_hosts and allow_hosts.
with_cache
Use a cache for requests.
with_optional_cache
Use a cache for requests.
deepish_copy
Deep copy a value with a compromise for uncopyable objects.
is_version_greater_or_equal
Check if the current version is greater or equal to the target version.
parse_prompt_identifier
Parse a string in the format of owner/name:hash, name:hash, owner/name, or name.
get_api_url
Get the LangSmith API URL from the environment or the given value.
get_api_key
Get the API key from the environment or the given value.
get_workspace_id
Get workspace ID.
get_host_url
Get the host URL based on the web URL or API URL.
is_truish
Check if the value is truish.
pytest_addoption
Set a boolean flag for LangSmith output.
pytest_cmdline_preparse
Call immediately after command line options are parsed (pytest v7).
pytest_load_initial_conftests
Handle args in pytest v8+.
pytest_runtest_call
Apply LangSmith tracking to tests marked with @pytest.mark.langsmith.
pytest_report_teststatus
Remove the short test-status character outputs ("./F").
pytest_configure
Register the 'langsmith' marker.
create_anonymizer
Create an anonymizer function.
get_current_run_tree
Get the current run tree.
set_tracing_parent
Set a RunTree as the active tracing parent within this block.
set_run_metadata
Update metadata on the current run tree.
get_tracing_context
Get the current tracing context.
tracing_context
Set the tracing context for a block of code.
is_traceable_function
Check if a function is @traceable decorated.
ensure_traceable
Ensure that a function is traceable.
is_async
Inspect function or wrapped function to see if it is async.
traceable
Trace a function with langsmith.
as_runnable
Convert a function wrapped by the LangSmith @traceable decorator to a Runnable.
close_session
Close the session.
convert_prompt_to_openai_format
Convert a prompt to OpenAI format.
convert_prompt_to_anthropic_format
Convert a prompt to Anthropic format.
dump_model
Dump model depending on pydantic version.
prep_obj_for_push
Format the object so its Prompt Hub compatible.
uuid7
Generate a random UUID v7.
uuid7_from_datetime
Generate a UUID v7 from a datetime.
exec_git
get_git_info
Get information about the git repository.
get_runtime_and_metrics
Get the runtime information as well as metrics.
get_system_metrics
Get CPU and other performance metrics.
get_runtime_environment
Get information about the environment.
get_langchain_environment
get_langchain_core_version
get_docker_version
get_docker_compose_version
get_docker_environment
Get information about the environment.
get_langchain_env_vars
Retrieve the langchain environment variables.
get_langchain_env_var_metadata
Retrieve the langchain environment variables.
get_release_shas
wrap_openai
Patch the OpenAI client to make it traceable.
wrap_anthropic
Patch the Anthropic client to make it traceable.
wrap_gemini
Patch the Google Gen AI client to make it traceable.
run_ws_stream
Execute a command over WebSocket, yielding raw message dicts.
reconnect_ws_stream
Reconnect to an existing command over WebSocket.
run_ws_stream_async
Async equivalent of run_ws_stream.
reconnect_ws_stream_async
Async equivalent of reconnect_ws_stream.
parse_error_response
Parse standardized error response.
parse_error_response_simple
Parse error response (simplified version for sandbox operations).
parse_validation_error
Parse Pydantic validation error response.
extract_quota_type
Extract quota type from error message.
raise_creation_error
Raise ResourceCreationError with the error_type from the API response.
handle_sandbox_creation_error
Handle HTTP errors specific to sandbox creation.
handle_volume_creation_error
Handle HTTP errors specific to volume creation.
handle_pool_error
Handle HTTP errors specific to pool creation/update.
handle_client_http_error
Handle HTTP errors and raise appropriate exceptions (for client operations).
handle_sandbox_http_error
Handle HTTP errors for sandbox operations (run, read, write).
process_inputs
run_evaluator
Create a run evaluator from a function.
process_inputs
comparison_evaluator
Create a comaprison evaluator from a function.
aevaluate
Evaluate an async target system on a given dataset.
aevaluate_existing
Evaluate existing experiment runs asynchronously.
async_chain_from_iterable
Chain multiple async iterables.
async_iter_from_list
Convert a list of examples to an async iterable.
random_name
Generate a random name.
evaluate
Evaluate a target system on a given dataset.
evaluate_existing
Evaluate existing experiment runs.
evaluate_comparative
Evaluate existing experiment runs against each other.
Modules
langsmith
LangSmith Client.
run_trees
Schemas for the LangSmith API.
prompt_cache
Prompt caching module for LangSmith SDK.
utils
Generic utility functions.
pytest_plugin
LangSmith Pytest hooks.
anonymizer
_expect
Make approximate assertions as "expectations" on test results.
run_helpers
Decorator for creating a run tree from functions.
client
Client for interacting with the LangSmith API.
uuid
Public UUID v7 helpers.
schemas
Schemas for the LangSmith API.
middleware
Middleware for making it easier to do distributed tracing.
async_client
The Async LangSmith Client.
testing
LangSmith pytest testing module.
env
Utilities to get information about the runtime environment.
wrappers
This module provides convenient tracing wrappers for popular libraries.
sandbox
LangSmith Sandbox Module.
evaluation
Evaluation Helpers.
evaluator
This module contains the evaluator classes for evaluating runs.
llm_evaluator
Contains the LLMEvaluator class for building LLM-as-a-judge evaluators.
string_evaluator
This module contains the StringEvaluator class.