_get_messages() — langchain Function Reference
Architecture documentation for the _get_messages() function in runner_utils.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD c56a3c0a_b0e2_287c_e948_c9d9eb18b351["_get_messages()"] 8253c602_7d0c_9195_a7e1_3e9b19304131["runner_utils.py"] c56a3c0a_b0e2_287c_e948_c9d9eb18b351 -->|defined in| 8253c602_7d0c_9195_a7e1_3e9b19304131 6e6ec2d6_6138_30d5_cc46_459846fde288["_validate_example_inputs_for_language_model()"] 6e6ec2d6_6138_30d5_cc46_459846fde288 -->|calls| c56a3c0a_b0e2_287c_e948_c9d9eb18b351 5dad9d8a_ecf9_b785_9a01_d927f6bea73e["_arun_llm()"] 5dad9d8a_ecf9_b785_9a01_d927f6bea73e -->|calls| c56a3c0a_b0e2_287c_e948_c9d9eb18b351 916eedb8_7d10_72b9_9829_105f8ada65ab["_run_llm()"] 916eedb8_7d10_72b9_9829_105f8ada65ab -->|calls| c56a3c0a_b0e2_287c_e948_c9d9eb18b351 style c56a3c0a_b0e2_287c_e948_c9d9eb18b351 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/langchain/langchain_classic/smith/evaluation/runner_utils.py lines 303–342
def _get_messages(inputs: dict[str, Any]) -> dict:
"""Get Chat Messages from inputs.
Args:
inputs: The input dictionary.
Returns:
A list of chat messages.
Raises:
InputFormatError: If the input format is invalid.
"""
if not inputs:
msg = "Inputs should not be empty."
raise InputFormatError(msg)
input_copy = inputs.copy()
if "messages" in inputs:
input_copy["input"] = input_copy.pop("messages")
elif len(inputs) == 1:
input_copy["input"] = next(iter(inputs.values()))
if "input" in input_copy:
raw_messages = input_copy["input"]
if isinstance(raw_messages, list) and all(
isinstance(i, dict) for i in raw_messages
):
raw_messages = [raw_messages]
if len(raw_messages) == 1:
input_copy["input"] = messages_from_dict(raw_messages[0])
else:
msg = (
"Batch messages not supported. Please provide a"
" single list of messages."
)
raise InputFormatError(msg)
return input_copy
msg = (
f"Chat Run expects single List[dict] or List[List[dict]] 'messages'"
f" input. Got {inputs}"
)
raise InputFormatError(msg)
Domain
Subdomains
Source
Frequently Asked Questions
What does _get_messages() do?
_get_messages() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py.
Where is _get_messages() defined?
_get_messages() is defined in libs/langchain/langchain_classic/smith/evaluation/runner_utils.py at line 303.
What calls _get_messages()?
_get_messages() is called by 3 function(s): _arun_llm, _run_llm, _validate_example_inputs_for_language_model.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free