__init__() — langchain Function Reference
Architecture documentation for the __init__() function in structured.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 860d9f0c_4ab4_1325_4192_4e882423b69c["__init__()"] 14de95af_eb88_e7a8_1ab1_98d03dd541e0["StructuredPrompt"] 860d9f0c_4ab4_1325_4192_4e882423b69c -->|defined in| 14de95af_eb88_e7a8_1ab1_98d03dd541e0 style 860d9f0c_4ab4_1325_4192_4e882423b69c fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/prompts/structured.py lines 36–72
def __init__(
self,
messages: Sequence[MessageLikeRepresentation],
schema_: dict | type[BaseModel] | None = None,
*,
structured_output_kwargs: dict[str, Any] | None = None,
template_format: PromptTemplateFormat = "f-string",
**kwargs: Any,
) -> None:
"""Create a structured prompt template.
Args:
messages: Sequence of messages.
schema_: Schema for the structured prompt.
structured_output_kwargs: Additional kwargs for structured output.
template_format: Template format for the prompt.
Raises:
ValueError: If schema is not provided.
"""
schema_ = schema_ or kwargs.pop("schema", None)
if not schema_:
err_msg = (
"Must pass in a non-empty structured output schema. Received: "
f"{schema_}"
)
raise ValueError(err_msg)
structured_output_kwargs = structured_output_kwargs or {}
for k in set(kwargs).difference(get_pydantic_field_names(self.__class__)):
structured_output_kwargs[k] = kwargs.pop(k)
super().__init__(
messages=messages,
schema_=schema_,
structured_output_kwargs=structured_output_kwargs,
template_format=template_format,
**kwargs,
)
Domain
Subdomains
Source
Frequently Asked Questions
What does __init__() do?
__init__() is a function in the langchain codebase, defined in libs/core/langchain_core/prompts/structured.py.
Where is __init__() defined?
__init__() is defined in libs/core/langchain_core/prompts/structured.py at line 36.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free