StringPromptValue Class — langchain Architecture
Architecture documentation for the StringPromptValue class in prompt_values.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 160bdb5d_db6e_0f75_341a_120e781bc026["StringPromptValue"] 7deca977_9668_e807_4e77_0bc4519c0bfb["PromptValue"] 160bdb5d_db6e_0f75_341a_120e781bc026 -->|extends| 7deca977_9668_e807_4e77_0bc4519c0bfb 94d98b96_b32c_774d_c6fe_549a7fddfb68["prompt_values.py"] 160bdb5d_db6e_0f75_341a_120e781bc026 -->|defined in| 94d98b96_b32c_774d_c6fe_549a7fddfb68 3693f69f_a994_3e91_82e5_0f48cb9140e1["get_lc_namespace()"] 160bdb5d_db6e_0f75_341a_120e781bc026 -->|method| 3693f69f_a994_3e91_82e5_0f48cb9140e1 0db1cfdc_c563_7743_8dd1_78c286d27a4e["to_string()"] 160bdb5d_db6e_0f75_341a_120e781bc026 -->|method| 0db1cfdc_c563_7743_8dd1_78c286d27a4e 72d96c31_869c_6492_ef96_d020fcf3e99e["to_messages()"] 160bdb5d_db6e_0f75_341a_120e781bc026 -->|method| 72d96c31_869c_6492_ef96_d020fcf3e99e
Relationship Graph
Source Code
libs/core/langchain_core/prompt_values.py lines 54–77
class StringPromptValue(PromptValue):
"""String prompt value."""
text: str
"""Prompt text."""
type: Literal["StringPromptValue"] = "StringPromptValue"
@classmethod
def get_lc_namespace(cls) -> list[str]:
"""Get the namespace of the LangChain object.
Returns:
`["langchain", "prompts", "base"]`
"""
return ["langchain", "prompts", "base"]
def to_string(self) -> str:
"""Return prompt as string."""
return self.text
def to_messages(self) -> list[BaseMessage]:
"""Return prompt as messages."""
return [HumanMessage(content=self.text)]
Defined In
Extends
Source
Frequently Asked Questions
What is the StringPromptValue class?
StringPromptValue is a class in the langchain codebase, defined in libs/core/langchain_core/prompt_values.py.
Where is StringPromptValue defined?
StringPromptValue is defined in libs/core/langchain_core/prompt_values.py at line 54.
What does StringPromptValue extend?
StringPromptValue extends PromptValue.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free