create_text_block() — langchain Function Reference
Architecture documentation for the create_text_block() function in content.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 33bfcd9d_32f2_8901_8e93_011dcde69f21["create_text_block()"] c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"] 33bfcd9d_32f2_8901_8e93_011dcde69f21 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630 style 33bfcd9d_32f2_8901_8e93_011dcde69f21 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/content.py lines 950–992
def create_text_block(
text: str,
*,
id: str | None = None,
annotations: list[Annotation] | None = None,
index: int | str | None = None,
**kwargs: Any,
) -> TextContentBlock:
"""Create a `TextContentBlock`.
Args:
text: The text content of the block.
id: Content block identifier.
Generated automatically if not provided.
annotations: `Citation`s and other annotations for the text.
index: Index of block in aggregate response.
Used during streaming.
Returns:
A properly formatted `TextContentBlock`.
!!! note
The `id` is generated automatically if not provided, using a UUID4 format
prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
"""
block = TextContentBlock(
type="text",
text=text,
id=ensure_id(id),
)
if annotations is not None:
block["annotations"] = annotations
if index is not None:
block["index"] = index
extras = {k: v for k, v in kwargs.items() if v is not None}
if extras:
block["extras"] = extras
return block
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does create_text_block() do?
create_text_block() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is create_text_block() defined?
create_text_block() is defined in libs/core/langchain_core/messages/content.py at line 950.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free