pub struct Conversation {
pub id: ConversationId,
pub title: String,
pub messages: Vec<ChatMessage>,
pub global_context: Vec<ContextItem>,
pub role: RoleName,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
pub metadata: AHashMap<String, String>,
pub token_budget: Option<usize>,
}Fields§
§id: ConversationIdUnique identifier for this conversation
title: StringHuman-readable title for the conversation
messages: Vec<ChatMessage>Messages in this conversation
global_context: Vec<ContextItem>Global context items for the entire conversation
role: RoleNameRole used for this conversation
created_at: DateTime<Utc>When this conversation was created
updated_at: DateTime<Utc>When this conversation was last updated
metadata: AHashMap<String, String>Metadata about the conversation
token_budget: Option<usize>Token budget for this conversation (if set)
Implementations§
Source§impl Conversation
impl Conversation
Sourcepub fn new(title: String, role: RoleName) -> Conversation
pub fn new(title: String, role: RoleName) -> Conversation
Create a new conversation
Sourcepub fn with_token_budget(self, budget: usize) -> Conversation
pub fn with_token_budget(self, budget: usize) -> Conversation
Set the token budget for this conversation.
Sourcepub fn check_rot(&self) -> Option<RotStatus>
pub fn check_rot(&self) -> Option<RotStatus>
Check the rot status of this conversation based on token budget.
Returns None if no token budget is set.
Uses estimated_context_length() as a conservative proxy for token count
(byte count is always >= token count, so this errs on the side of caution).
Sourcepub fn add_message(&mut self, message: ChatMessage)
pub fn add_message(&mut self, message: ChatMessage)
Add a message to the conversation
Sourcepub fn add_global_context(&mut self, context: ContextItem)
pub fn add_global_context(&mut self, context: ContextItem)
Add global context to the conversation
Sourcepub fn estimated_context_length(&self) -> usize
pub fn estimated_context_length(&self) -> usize
Get the total context length (approximation)
Trait Implementations§
Source§impl Clone for Conversation
impl Clone for Conversation
Source§fn clone(&self) -> Conversation
fn clone(&self) -> Conversation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Conversation
impl Debug for Conversation
Source§impl<'de> Deserialize<'de> for Conversation
impl<'de> Deserialize<'de> for Conversation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Conversation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Conversation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl From<&Conversation> for ConversationSummary
impl From<&Conversation> for ConversationSummary
Source§fn from(conversation: &Conversation) -> ConversationSummary
fn from(conversation: &Conversation) -> ConversationSummary
Source§impl Serialize for Conversation
impl Serialize for Conversation
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 Conversation
impl RefUnwindSafe for Conversation
impl Send for Conversation
impl Sync for Conversation
impl Unpin for Conversation
impl UnsafeUnpin for Conversation
impl UnwindSafe for Conversation
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more