Home / Class/ ChatPromptValue Class — langchain Architecture

ChatPromptValue Class — langchain Architecture

Architecture documentation for the ChatPromptValue class in prompt_values.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  fbb5370a_524d_4802_fe81_dd4699b1a7b0["ChatPromptValue"]
  7deca977_9668_e807_4e77_0bc4519c0bfb["PromptValue"]
  fbb5370a_524d_4802_fe81_dd4699b1a7b0 -->|extends| 7deca977_9668_e807_4e77_0bc4519c0bfb
  94d98b96_b32c_774d_c6fe_549a7fddfb68["prompt_values.py"]
  fbb5370a_524d_4802_fe81_dd4699b1a7b0 -->|defined in| 94d98b96_b32c_774d_c6fe_549a7fddfb68
  29d8ecaa_c588_3872_fab7_8c58da83188b["to_string()"]
  fbb5370a_524d_4802_fe81_dd4699b1a7b0 -->|method| 29d8ecaa_c588_3872_fab7_8c58da83188b
  22881d91_715d_5e10_0a57_bb039ed45525["to_messages()"]
  fbb5370a_524d_4802_fe81_dd4699b1a7b0 -->|method| 22881d91_715d_5e10_0a57_bb039ed45525
  67ba0529_65e1_835f_37ab_fcd5de06aabb["get_lc_namespace()"]
  fbb5370a_524d_4802_fe81_dd4699b1a7b0 -->|method| 67ba0529_65e1_835f_37ab_fcd5de06aabb

Relationship Graph

Source Code

libs/core/langchain_core/prompt_values.py lines 80–104

class ChatPromptValue(PromptValue):
    """Chat prompt value.

    A type of a prompt value that is built from messages.
    """

    messages: Sequence[BaseMessage]
    """List of messages."""

    def to_string(self) -> str:
        """Return prompt as string."""
        return get_buffer_string(self.messages)

    def to_messages(self) -> list[BaseMessage]:
        """Return prompt as a list of messages."""
        return list(self.messages)

    @classmethod
    def get_lc_namespace(cls) -> list[str]:
        """Get the namespace of the LangChain object.

        Returns:
            `["langchain", "prompts", "chat"]`
        """
        return ["langchain", "prompts", "chat"]

Extends

Frequently Asked Questions

What is the ChatPromptValue class?
ChatPromptValue is a class in the langchain codebase, defined in libs/core/langchain_core/prompt_values.py.
Where is ChatPromptValue defined?
ChatPromptValue is defined in libs/core/langchain_core/prompt_values.py at line 80.
What does ChatPromptValue extend?
ChatPromptValue extends PromptValue.

Analyze Your Own Codebase

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

Try Supermodel Free