_validate_example_inputs_for_chain() — langchain Function Reference
Architecture documentation for the _validate_example_inputs_for_chain() function in runner_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD d899be86_77ab_646d_1c6a_429fffb92643["_validate_example_inputs_for_chain()"] 8253c602_7d0c_9195_a7e1_3e9b19304131["runner_utils.py"] d899be86_77ab_646d_1c6a_429fffb92643 -->|defined in| 8253c602_7d0c_9195_a7e1_3e9b19304131 42662eb3_17b6_0aaa_f09d_12aabcf769e7["_validate_example_inputs()"] 42662eb3_17b6_0aaa_f09d_12aabcf769e7 -->|calls| d899be86_77ab_646d_1c6a_429fffb92643 style d899be86_77ab_646d_1c6a_429fffb92643 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 381–418
def _validate_example_inputs_for_chain(
first_example: Example,
chain: Chain,
input_mapper: Callable[[dict], Any] | None,
) -> None:
"""Validate that the example inputs match the chain input keys."""
if input_mapper:
first_inputs = input_mapper(first_example.inputs or {})
missing_keys = set(chain.input_keys).difference(first_inputs)
if not isinstance(first_inputs, dict):
msg = (
"When using an input_mapper to prepare dataset example"
" inputs for a chain, the mapped value must be a dictionary."
f"\nGot: {first_inputs} of type {type(first_inputs)}."
)
raise InputFormatError(msg)
if missing_keys:
msg = (
"Missing keys after loading example using input_mapper."
f"\nExpected: {chain.input_keys}. Got: {first_inputs.keys()}"
)
raise InputFormatError(msg)
else:
first_inputs = first_example.inputs or {}
missing_keys = set(chain.input_keys).difference(first_inputs)
if len(first_inputs) == 1 and len(chain.input_keys) == 1:
# We can pass this through the run method.
# Refrain from calling to validate.
pass
elif missing_keys:
msg = (
"Example inputs missing expected chain input keys."
" Please provide an input_mapper to convert the example.inputs"
" to a compatible format for the chain you wish to evaluate."
f"Expected: {chain.input_keys}. "
f"Got: {first_inputs.keys()}"
)
raise InputFormatError(msg)
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does _validate_example_inputs_for_chain() do?
_validate_example_inputs_for_chain() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is _validate_example_inputs_for_chain() defined?
_validate_example_inputs_for_chain() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 381.
What calls _validate_example_inputs_for_chain()?
_validate_example_inputs_for_chain() is called by 1 function(s): _validate_example_inputs.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free