Expand description
Universal Message Format (UMF)
This crate provides a provider-agnostic message representation for LLM interactions. It follows the OpenAI-compatible JSON structure as the foundation while supporting conversion to any LLM provider format (Anthropic, Google Gemini, Cohere, etc.).
§Core Principles
- OpenAI-Compatible Base: The format follows OpenAI’s JSON structure
- Provider-Agnostic: Can be converted to any LLM provider format
- Metadata Support: Includes optional metadata for internal tracking
- Tool Calling Support: Full support for function/tool calling
- Hub Model: Internal format acts as conversion hub for all protocols
§Features
internal(default) - Core hub types for protocol conversionchatml- ChatML message formattingevents- Conversation event trackingstreaming- Streaming response supportmcp- Model Context Protocol types and conversionfull- All features enabled
§Usage
use umf::{InternalMessage, MessageRole, ContentBlock};
// Create a simple text message
let msg = InternalMessage::user("Hello, world!");
// Create a message with tool calls
let msg = InternalMessage::assistant_with_tools(
"Let me search for that",
vec![ContentBlock::tool_use("call_123", "search", serde_json::json!({"q": "rust"}))],
);Re-exports§
pub use internal::ConversionError;pub use internal::FromInternal;pub use internal::InternalTool;pub use internal::InternalToolCall;pub use internal::InternalToolResult;pub use internal::ToInternal;pub use internal::TryFromInternal;pub use internal::TryToInternal;pub use chatml::ChatMLFormatter;pub use chatml::ChatMLMessage;pub use chatml::MessageRole as ChatMLMessageRole;pub use events::Event;pub use events::EventEnvelope;pub use events::EventType;pub use events::McpContext;pub use events::MessageEvent;pub use events::ModelInfo;pub use events::ToolCall as EventToolCall;pub use events::ToolCallEvent;pub use events::ToolCallStatus;pub use events::ToolResult;pub use events::ToolResultEvent;
Modules§
- chatml
- ChatML message formatter for simpaticoder.
- events
- Event types for conversation tracking and storage
- internal
- Internal format module - the hub for protocol conversion.
Structs§
- Function
- Function definition for tools
- Function
Call - Function call structure for tool invocations
- Internal
Message - A message in the internal format
- Tool
- Tool definition for OpenAI-compatible tools
- Tool
Call - Tool call structure for function calling
Enums§
- Content
Block - A content block within a message
- Generate
Result - Result of generation with tools
- Image
Source - Image source for image blocks
- Message
Content - Message content (text or structured blocks)
- Message
Role - Message role in a conversation