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: TextConcatenator
Implementations§
Source§impl PromptMessage
impl PromptMessage
pub fn new( message_type: PromptMessageType, concatenator: &TextConcatenator, ) -> PromptMessage
Sourcepub fn set_content<T>(&self, content: T) -> &PromptMessage
pub fn set_content<T>(&self, content: T) -> &PromptMessage
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>(&self, content: T) -> &PromptMessage
pub fn prepend_content<T>(&self, content: T) -> &PromptMessage
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
Sourcepub fn append_content<T>(&self, content: T) -> &PromptMessage
pub fn append_content<T>(&self, content: T) -> &PromptMessage
Sourcepub fn get_built_prompt_message(&self) -> Result<String, Error>
pub fn get_built_prompt_message(&self) -> Result<String, Error>
Trait Implementations§
Source§impl Clone for PromptMessage
impl Clone for PromptMessage
Source§fn clone(&self) -> PromptMessage
fn clone(&self) -> PromptMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for PromptMessage
impl Debug for PromptMessage
Source§impl<'de> Deserialize<'de> for PromptMessage
impl<'de> Deserialize<'de> for PromptMessage
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PromptMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PromptMessage, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for PromptMessage
impl Display for PromptMessage
Source§impl Serialize for PromptMessage
impl Serialize for PromptMessage
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !Freeze for PromptMessage
impl RefUnwindSafe for PromptMessage
impl Send for PromptMessage
impl Sync for PromptMessage
impl Unpin for PromptMessage
impl UnwindSafe for PromptMessage
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
. Read moreSource§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string
, but without panic on OOM.