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
§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 chatml::ChatMLFormatter;pub use chatml::ChatMLMessage;pub use chatml::MessageRole as ChatMLMessageRole;
Modules§
- chatml
- ChatML message formatter for simpaticoder.
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