gleamstral/message
Types
Individual content part in a multi-modal message
Text: Text contentImageUrl: URL pointing to an image or a base64 encoded image string
pub type ContentPart {
Text(String)
ImageUrl(String)
}
Constructors
-
Text(String) -
ImageUrl(String)
Represents a message in a conversation with the AI model
SystemMessage: Instructions or context for the modelUserMessage: Input from the user to the modelAssistantMessage: Response from the model, potentially including tool callsToolMessage: Result of a tool function execution
pub type Message {
SystemMessage(content: MessageContent)
UserMessage(content: MessageContent)
AssistantMessage(
content: String,
tool_calls: Option(List(tool.ToolCall)),
prefix: Bool,
)
ToolMessage(
content: MessageContent,
tool_call_id: String,
name: String,
)
}
Constructors
-
SystemMessage(content: MessageContent) -
UserMessage(content: MessageContent) -
AssistantMessage( content: String, tool_calls: Option(List(tool.ToolCall)), prefix: Bool, ) -
ToolMessage( content: MessageContent, tool_call_id: String, name: String, )
Content of a message, which can be text-only or multi-modal
TextContent: Simple text messageMultiContent: Message with multiple content parts (text and/or images)
pub type MessageContent {
TextContent(String)
MultiContent(List(ContentPart))
}
Constructors
-
TextContent(String) -
MultiContent(List(ContentPart))
Represents the role of a message in a conversation
System: System messages provide context and instructions to the modelUser: User messages represent the human interacting with the modelAssistant: Assistant messages are the model’s responsesTool: Tool messages contain the results of tool function calls
pub type MessageRole {
System
User
Assistant
Tool
}
Constructors
-
System -
User -
Assistant -
Tool
Functions
pub fn message_decoder() -> Decoder(Message)
pub fn message_encoder(message: Message) -> Json