pub struct PromptMessage {
pub content: Mutex<Vec<String>>,
pub built_prompt_message: Mutex<Option<String>>,
pub message_type: PromptMessageType,
pub concatenator: TextConcatenator,
}Expand description
An individual message within a prompt sequence.
Represents a single message with its content, type, and concatenation rules. Maintains thread-safe interior mutability for content manipulation and provides methods for building and accessing the message content.
Fields§
§content: Mutex<Vec<String>>§built_prompt_message: Mutex<Option<String>>§message_type: PromptMessageType§concatenator: TextConcatenatorImplementations§
Source§impl PromptMessage
impl PromptMessage
pub fn new( message_type: PromptMessageType, concatenator: &TextConcatenator, ) -> Self
Sourcepub fn set_content<T: AsRef<str>>(&self, content: T) -> &Self
pub fn set_content<T: AsRef<str>>(&self, content: T) -> &Self
Sets the primary content of the message, replacing any existing content.
If the provided content is empty, the message remains unchanged. Otherwise, replaces all existing content with the new content and rebuilds the message.
§Arguments
content- The new content to set for the message
§Returns
A reference to self for method chaining
Sourcepub fn prepend_content<T: AsRef<str>>(&self, content: T) -> &Self
pub fn prepend_content<T: AsRef<str>>(&self, content: T) -> &Self
Adds content to the beginning of the message.
If the provided content is empty, the message remains unchanged. Otherwise, inserts the new content at the start of the existing content and rebuilds the message.
§Arguments
content- The content to prepend to the message
§Returns
A reference to self for method chaining