Eai. Message
(eai v0.1.9)
Copy Markdown
Internal message representation (IR) based on AWS Bedrock Converse API format.
Uses Elixir tuples for content blocks, providing a unified format that all provider adapters can convert to/from. This solves the cross-provider compatibility problem and enables multimodal content injection.
Summary
Functions
Check if the message is effectively empty (no content blocks or only empty text).
Convert a Converse-format JSON map back to internal message.
Create a :user message from multimodal_inject blocks returned by read_media_file. Input is a list of JSON-decoded maps (the "blocks" array).
Check if message contains any :tool_use blocks.
Create a new message.
Create a :user message with tool_result block(s), ensuring Anthropic compatibility (tool results must be in their own :user message).
Extract text content from a message as a single string. Joins multiple :text blocks with double newline.
Convert internal message to a JSON-friendly map (atom keys → string keys). Useful for Bedrock Converse direct pass-through.
Extract :tool_use blocks from a message.
Types
Functions
Check if the message is effectively empty (no content blocks or only empty text).
Convert a Converse-format JSON map back to internal message.
Create a :user message from multimodal_inject blocks returned by read_media_file. Input is a list of JSON-decoded maps (the "blocks" array).
Check if message contains any :tool_use blocks.
@spec new(role(), String.t() | [content_block()]) :: t()
Create a new message.
When content is a binary, it's wrapped as [{:text, content}].
When content is a list, it's used directly (must be valid content blocks).
@spec new_tool_result(String.t(), [content_block()]) :: t()
Create a :user message with tool_result block(s), ensuring Anthropic compatibility (tool results must be in their own :user message).
Extract text content from a message as a single string. Joins multiple :text blocks with double newline.
Convert internal message to a JSON-friendly map (atom keys → string keys). Useful for Bedrock Converse direct pass-through.
Extract :tool_use blocks from a message.