Home / Function/ _convert_input() — langchain Function Reference

_convert_input() — langchain Function Reference

Architecture documentation for the _convert_input() function in chat_models.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  494835ff_15be_f036_50fa_f8855bc47703["_convert_input()"]
  48aa29b8_65e7_522f_a445_a441eeb6baff["BaseChatModel"]
  494835ff_15be_f036_50fa_f8855bc47703 -->|defined in| 48aa29b8_65e7_522f_a445_a441eeb6baff
  f961f0c9_5051_8b77_5e6c_256782a5be2a["invoke()"]
  f961f0c9_5051_8b77_5e6c_256782a5be2a -->|calls| 494835ff_15be_f036_50fa_f8855bc47703
  4e73982c_eba2_614b_29c5_4974d3b4d313["ainvoke()"]
  4e73982c_eba2_614b_29c5_4974d3b4d313 -->|calls| 494835ff_15be_f036_50fa_f8855bc47703
  2c835c4d_6d4b_1dc6_028c_27710e69a32a["stream()"]
  2c835c4d_6d4b_1dc6_028c_27710e69a32a -->|calls| 494835ff_15be_f036_50fa_f8855bc47703
  9d211053_b2a3_2915_b514_1f332955694a["astream()"]
  9d211053_b2a3_2915_b514_1f332955694a -->|calls| 494835ff_15be_f036_50fa_f8855bc47703
  style 494835ff_15be_f036_50fa_f8855bc47703 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/core/langchain_core/language_models/chat_models.py lines 375–386

    def _convert_input(self, model_input: LanguageModelInput) -> PromptValue:
        if isinstance(model_input, PromptValue):
            return model_input
        if isinstance(model_input, str):
            return StringPromptValue(text=model_input)
        if isinstance(model_input, Sequence):
            return ChatPromptValue(messages=convert_to_messages(model_input))
        msg = (
            f"Invalid input type {type(model_input)}. "
            "Must be a PromptValue, str, or list of BaseMessages."
        )
        raise ValueError(msg)

Domain

Subdomains

Frequently Asked Questions

What does _convert_input() do?
_convert_input() is a function in the langchain codebase, defined in libs/core/langchain_core/language_models/chat_models.py.
Where is _convert_input() defined?
_convert_input() is defined in libs/core/langchain_core/language_models/chat_models.py at line 375.
What calls _convert_input()?
_convert_input() is called by 4 function(s): ainvoke, astream, invoke, stream.

Analyze Your Own Codebase

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

Try Supermodel Free