Installation
To use the LangSmith adapter, you need to install the LangSmith dependencies:Basic Usage
Configuration
The adapter uses the LangSmith client configuration. Set up your LangSmith credentials using environment variables:API Reference
LangSmithAdapter
The main adapter class for pulling data from LangSmith.get_evaluation_rows()
Pull runs from LangSmith and convert to EvaluationRow format.
project_name
- LangSmith project to read runs fromlimit
- Maximum number of rows to returninclude_tool_calls
- Whether to include tool calling information when presentrun_id
- Filter by specific run IDids
- Filter by list of run IDsrun_type
- Filter by run type (e.g., “llm”, “chain”, “tool”)execution_order
- Filter by execution orderparent_run_id
- Filter by parent run IDtrace_id
- Filter by specific trace IDtrace_ids
- Filter by list of trace IDsreference_example_id
- Filter by reference example IDsession_name
- Filter by session nameerror
- Filter by error status (True for errors, False for success, None for all)start_time
- Start time filter (ISO format string)end_time
- End time filter (ISO format string)filter_expr
- Server-side filter expression using LangSmith’s filter DSLtags
- Filter by specific tagsmetadata
- Filter by metadata key-value pairsfeedback_keys
- Filter by feedback keysfeedback_source
- Filter by feedback sourcetree_id
- Filter by tree IDoffset
- Pagination offsetorder_by
- Ordering specificationselect
- Fields to select in the response**list_runs_kwargs
- Additional parameters passed to LangSmith’s list_runs method
get_evaluation_rows_by_ids()
Get specific runs or traces by their IDs and convert to EvaluationRow format.
run_ids
- List of run IDs to fetchtrace_ids
- List of trace IDs to fetchinclude_tool_calls
- Whether to include tool calling informationproject_name
- Project name (stored in metadata)
Factory Function
For convenience, you can use the factory function:Source Code
The complete implementation is available on GitHub: eval_protocol/adapters/langsmith.pyFiltering Examples
For comprehensive documentation on LangSmith’s query and filtering capabilities, see the official LangSmith trace querying documentation. Here are some examples:Filter by Tags
Filter by Run Type
Filter by Time Range
Filter by Session
Filter by Metadata
Filter by Error Status
Advanced Filter Expression
Tool Calling Support
The adapter automatically handles tool calling traces from LangSmith:tool_calls
, tool_call_id
, and function_call
fields as appropriate.
Data Conversion
The adapter converts LangSmith runs to EvaluationRow format with intelligent handling of different input formats:Supported Run Formats
Metadata Preservation
The adapter stores the original LangSmith run and trace IDs in the evaluation row metadata:Advanced Features
Trace Deduplication
The adapter automatically deduplicates traces by selecting the last run per trace ID, ensuring you get the final state of each conversation:Message Deduplication
The adapter removes consecutive identical user messages to handle common echo patterns in LangChain integrations:Conversation Reconstruction
The adapter intelligently reconstructs conversations from LangSmith runs:- Prefers canonical conversations from
outputs.messages
when available - Falls back to input/output mapping for simple formats
- Handles tool calls and preserves tool calling context
- Supports LangChain message types with automatic role mapping