Home / Class/ PromptValue Class — langchain Architecture

PromptValue Class — langchain Architecture

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

Entity Profile

Dependency Diagram

graph TD
  7deca977_9668_e807_4e77_0bc4519c0bfb["PromptValue"]
  f3658565_d05c_7f49_b7f8_622b7ef34f33["Serializable"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|extends| f3658565_d05c_7f49_b7f8_622b7ef34f33
  94d98b96_b32c_774d_c6fe_549a7fddfb68["prompt_values.py"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|defined in| 94d98b96_b32c_774d_c6fe_549a7fddfb68
  08a9a0a8_65d7_bc02_9532_3893852ddba3["is_lc_serializable()"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|method| 08a9a0a8_65d7_bc02_9532_3893852ddba3
  4f87cac5_6dfc_0803_5c06_da90f906cee0["get_lc_namespace()"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|method| 4f87cac5_6dfc_0803_5c06_da90f906cee0
  e0313f1b_1239_3185_5fa9_893b8f75972b["to_string()"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|method| e0313f1b_1239_3185_5fa9_893b8f75972b
  5ea10f6a_ee20_1712_49fe_7e12a5841ba3["to_messages()"]
  7deca977_9668_e807_4e77_0bc4519c0bfb -->|method| 5ea10f6a_ee20_1712_49fe_7e12a5841ba3

Relationship Graph

Source Code

libs/core/langchain_core/prompt_values.py lines 24–51

class PromptValue(Serializable, ABC):
    """Base abstract class for inputs to any language model.

    `PromptValues` can be converted to both LLM (pure text-generation) inputs and
    chat model inputs.
    """

    @classmethod
    def is_lc_serializable(cls) -> bool:
        """Return `True` as this class is serializable."""
        return True

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

        Returns:
            `["langchain", "schema", "prompt"]`
        """
        return ["langchain", "schema", "prompt"]

    @abstractmethod
    def to_string(self) -> str:
        """Return prompt value as string."""

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

Extends

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free