pub trait MessageConversion {
// Required methods
fn to_anthropic_message(&self) -> Result<MessageParam, TypeError>;
fn to_google_message(&self) -> Result<GeminiContent, TypeError>;
fn to_openai_message(&self) -> Result<ChatMessage, TypeError>;
}Expand description
Trait for converting between different provider message formats
This trait enables conversion of messages between different LLM provider formats (e.g., Anthropic MessageParam ↔ Google GeminiContent ↔ OpenAI ChatMessage).
Currently focused on text content conversion, with support for other content types planned for future implementation.
Required Methods§
Sourcefn to_anthropic_message(&self) -> Result<MessageParam, TypeError>
fn to_anthropic_message(&self) -> Result<MessageParam, TypeError>
Convert this message to an Anthropic MessageParam
§Errors
Returns TypeError::UnsupportedConversion if the message contains
content types that cannot be represented in Anthropic’s format
Sourcefn to_google_message(&self) -> Result<GeminiContent, TypeError>
fn to_google_message(&self) -> Result<GeminiContent, TypeError>
Convert this message to a Google GeminiContent
§Errors
Returns TypeError::UnsupportedConversion if the message contains
content types that cannot be represented in Google’s format
Sourcefn to_openai_message(&self) -> Result<ChatMessage, TypeError>
fn to_openai_message(&self) -> Result<ChatMessage, TypeError>
Convert this message to an OpenAI ChatMessage
§Errors
Returns TypeError::UnsupportedConversion if the message contains
content types that cannot be represented in OpenAI’s format
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".