create_audio_block() — langchain Function Reference
Architecture documentation for the create_audio_block() function in content.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD dda33e3e_9826_516f_37bf_bbac40d17c37["create_audio_block()"] c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"] dda33e3e_9826_516f_37bf_bbac40d17c37 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630 style dda33e3e_9826_516f_37bf_bbac40d17c37 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
libs/core/langchain_core/messages/content.py lines 1123–1186
def create_audio_block(
*,
url: str | None = None,
base64: str | None = None,
file_id: str | None = None,
mime_type: str | None = None,
id: str | None = None,
index: int | str | None = None,
**kwargs: Any,
) -> AudioContentBlock:
"""Create an `AudioContentBlock`.
Args:
url: URL of the audio.
base64: Base64-encoded audio data.
file_id: ID of the audio file from a file storage system.
mime_type: MIME type of the audio.
Required for base64 data.
id: Content block identifier.
Generated automatically if not provided.
index: Index of block in aggregate response.
Used during streaming.
Returns:
A properly formatted `AudioContentBlock`.
Raises:
ValueError: If no audio source is provided or if `base64` is used without
`mime_type`.
!!! note
The `id` is generated automatically if not provided, using a UUID4 format
prefixed with `'lc_'` to indicate it is a LangChain-generated ID.
"""
if not any([url, base64, file_id]):
msg = "Must provide one of: url, base64, or file_id"
raise ValueError(msg)
if base64 and not mime_type:
msg = "mime_type is required when using base64 data"
raise ValueError(msg)
block = AudioContentBlock(type="audio", id=ensure_id(id))
if url is not None:
block["url"] = url
if base64 is not None:
block["base64"] = base64
if file_id is not None:
block["file_id"] = file_id
if mime_type is not None:
block["mime_type"] = mime_type
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_audio_block() do?
create_audio_block() is a function in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is create_audio_block() defined?
create_audio_block() is defined in libs/core/langchain_core/messages/content.py at line 1123.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free