Skip to main content

MessageLike

Trait MessageLike 

Source
pub trait MessageLike {
    // Required method
    fn to_message(&self) -> Message;
}
Expand description

Trait for types that can be converted to a Message.

This provides a uniform interface for accepting various types as messages, such as raw strings, tuples of (role, content), or Message values directly.

§Examples

use synwire_core::messages::{Message, MessageLike};

let msg: Message = "Hello".to_message();
assert_eq!(msg.message_type(), "human");

let msg: Message = ("ai", "Hi there").to_message();
assert_eq!(msg.message_type(), "ai");

Required Methods§

Source

fn to_message(&self) -> Message

Convert to a Message.

Implementations on Foreign Types§

Source§

impl MessageLike for &str

Source§

impl MessageLike for (&str, &str)

Source§

fn to_message(&self) -> Message

First element is role ("human", "user", "ai", "assistant", "system"), second is content. Unrecognised roles default to human.

Source§

impl MessageLike for String

Implementors§