prompt_values.py — langchain Source File
Architecture documentation for prompt_values.py, a python file in the langchain codebase. 6 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 94d98b96_b32c_774d_c6fe_549a7fddfb68["prompt_values.py"] cccbe73e_4644_7211_4d55_e8fb133a8014["abc"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> cccbe73e_4644_7211_4d55_e8fb133a8014 cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7["collections.abc"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> cfe2bde5_180e_e3b0_df2b_55b3ebaca8e7 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3["typing"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> 8e2034b7_ceb8_963f_29fc_2ea6b50ef9b3 91721f45_4909_e489_8c1f_084f8bd87145["typing_extensions"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> 91721f45_4909_e489_8c1f_084f8bd87145 30d1300e_92bb_90d4_ac5e_1afe56db09d2["langchain_core.load.serializable"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> 30d1300e_92bb_90d4_ac5e_1afe56db09d2 d758344f_537f_649e_f467_b9d7442e86df["langchain_core.messages"] 94d98b96_b32c_774d_c6fe_549a7fddfb68 --> d758344f_537f_649e_f467_b9d7442e86df style 94d98b96_b32c_774d_c6fe_549a7fddfb68 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"""**Prompt values** for language model prompts.
Prompt values are used to represent different pieces of prompts. They can be used to
represent text, images, or chat message pieces.
"""
from __future__ import annotations
from abc import ABC, abstractmethod
from collections.abc import Sequence
from typing import Literal, cast
from typing_extensions import TypedDict
from langchain_core.load.serializable import Serializable
from langchain_core.messages import (
AnyMessage,
BaseMessage,
HumanMessage,
get_buffer_string,
)
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."""
class StringPromptValue(PromptValue):
"""String prompt value."""
text: str
"""Prompt text."""
type: Literal["StringPromptValue"] = "StringPromptValue"
// ... (102 more lines)
Domain
Subdomains
Dependencies
- abc
- collections.abc
- langchain_core.load.serializable
- langchain_core.messages
- typing
- typing_extensions
Source
Frequently Asked Questions
What does prompt_values.py do?
prompt_values.py is a source file in the langchain codebase, written in python. It belongs to the CoreAbstractions domain, Serialization subdomain.
What does prompt_values.py depend on?
prompt_values.py imports 6 module(s): abc, collections.abc, langchain_core.load.serializable, langchain_core.messages, typing, typing_extensions.
Where is prompt_values.py in the architecture?
prompt_values.py is located at libs/core/langchain_core/prompt_values.py (domain: CoreAbstractions, subdomain: Serialization, directory: libs/core/langchain_core).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free