map() — langchain Function Reference
Architecture documentation for the map() function in string_run_evaluator.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD b15ccccb_1344_8d38_767a_922bd0d352ca["map()"] e9537ec5_dd39_fde8_64f7_e16f805b8dbe["StringExampleMapper"] b15ccccb_1344_8d38_767a_922bd0d352ca -->|defined in| e9537ec5_dd39_fde8_64f7_e16f805b8dbe f56f231b_b6eb_b4a1_5171_9aa21c13ee17["__call__()"] f56f231b_b6eb_b4a1_5171_9aa21c13ee17 -->|calls| b15ccccb_1344_8d38_767a_922bd0d352ca da073bde_7e9c_b610_6d77_18f3b0290349["serialize_chat_messages()"] b15ccccb_1344_8d38_767a_922bd0d352ca -->|calls| da073bde_7e9c_b610_6d77_18f3b0290349 c36025c6_da32_fa12_5c71_e60ffc858574["serialize_chat_messages()"] b15ccccb_1344_8d38_767a_922bd0d352ca -->|calls| c36025c6_da32_fa12_5c71_e60ffc858574 eeef200b_d96b_43d0_3074_30604390fe0c["map()"] b15ccccb_1344_8d38_767a_922bd0d352ca -->|calls| eeef200b_d96b_43d0_3074_30604390fe0c style b15ccccb_1344_8d38_767a_922bd0d352ca fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py lines 240–265
def map(self, example: Example) -> dict[str, str]:
"""Maps the Example, or dataset row to a dictionary."""
if not example.outputs:
msg = f"Example {example.id} has no outputs to use as a reference."
raise ValueError(msg)
if self.reference_key is None:
if len(example.outputs) > 1:
msg = (
f"Example {example.id} has multiple outputs, so you must"
" specify a reference_key."
)
raise ValueError(msg)
output = next(iter(example.outputs.values()))
elif self.reference_key not in example.outputs:
msg = (
f"Example {example.id} does not have reference key"
f" {self.reference_key}."
)
raise ValueError(msg)
else:
output = example.outputs[self.reference_key]
return {
"reference": self.serialize_chat_messages([output])
if isinstance(output, dict) and output.get("type") and output.get("data")
else output,
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does map() do?
map() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py.
Where is map() defined?
map() is defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py at line 240.
What does map() call?
map() calls 3 function(s): map, serialize_chat_messages, serialize_chat_messages.
What calls map()?
map() is called by 1 function(s): __call__.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free