Home / Function/ serialize_inputs() — langchain Function Reference

serialize_inputs() — langchain Function Reference

Architecture documentation for the serialize_inputs() function in string_run_evaluator.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  132c0c4d_93e7_fc60_9da8_46f58df87075["serialize_inputs()"]
  8b074a3f_8729_0bb7_fe7d_db473df331ce["LLMStringRunMapper"]
  132c0c4d_93e7_fc60_9da8_46f58df87075 -->|defined in| 8b074a3f_8729_0bb7_fe7d_db473df331ce
  eeef200b_d96b_43d0_3074_30604390fe0c["map()"]
  eeef200b_d96b_43d0_3074_30604390fe0c -->|calls| 132c0c4d_93e7_fc60_9da8_46f58df87075
  c36025c6_da32_fa12_5c71_e60ffc858574["serialize_chat_messages()"]
  132c0c4d_93e7_fc60_9da8_46f58df87075 -->|calls| c36025c6_da32_fa12_5c71_e60ffc858574
  style 132c0c4d_93e7_fc60_9da8_46f58df87075 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py lines 78–99

    def serialize_inputs(self, inputs: dict) -> str:
        """Serialize inputs.

        Args:
            inputs: The inputs from the run, expected to contain prompts or messages.

        Returns:
            The serialized input text from the prompts or messages.

        Raises:
            ValueError: If neither prompts nor messages are found in the inputs.
        """
        if "prompts" in inputs:  # Should we even accept this?
            input_ = "\n\n".join(inputs["prompts"])
        elif "prompt" in inputs:
            input_ = inputs["prompt"]
        elif "messages" in inputs:
            input_ = self.serialize_chat_messages(inputs["messages"])
        else:
            msg = "LLM Run must have either messages or prompts as inputs."
            raise ValueError(msg)
        return input_

Domain

Subdomains

Called By

Frequently Asked Questions

What does serialize_inputs() do?
serialize_inputs() is a function in the langchain codebase, defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py.
Where is serialize_inputs() defined?
serialize_inputs() is defined in libs/langchain/langchain_classic/smith/evaluation/string_run_evaluator.py at line 78.
What does serialize_inputs() call?
serialize_inputs() calls 1 function(s): serialize_chat_messages.
What calls serialize_inputs()?
serialize_inputs() is called by 1 function(s): map.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free