pub struct DialogueContext {
pub turns: Vec<DialogueTurn>,
pub participants: Vec<String>,
pub current_addressee: Option<String>,
pub dialogue_id: Option<String>,
}Expand description
Tracks the state of a multi-turn dialogue.
§Why Dialogue Context?
Coreference in dialogue requires knowing:
- Who are the active participants?
- What has been said recently?
- Who is the current addressee?
This context enables proper resolution of:
- Speaker pronouns (“I”, “you”)
- Addressee tracking
- Response token classification based on prior turn
Fields§
§turns: Vec<DialogueTurn>All turns in the dialogue.
participants: Vec<String>Active participant IDs.
current_addressee: Option<String>Current addressee (who the last turn was directed at).
dialogue_id: Option<String>Dialogue identifier.
Implementations§
Source§impl DialogueContext
impl DialogueContext
Sourcepub fn new() -> DialogueContext
pub fn new() -> DialogueContext
Create a new empty dialogue context.
Sourcepub fn add_turn(&mut self, turn: DialogueTurn)
pub fn add_turn(&mut self, turn: DialogueTurn)
Add a turn to the dialogue.
Sourcepub fn last_turns(&self, n: usize) -> &[DialogueTurn]
pub fn last_turns(&self, n: usize) -> &[DialogueTurn]
Get the last N turns.
Sourcepub fn turns_by_speaker(&self, speaker: &str) -> Vec<&DialogueTurn>
pub fn turns_by_speaker(&self, speaker: &str) -> Vec<&DialogueTurn>
Get turns from a specific speaker.
Sourcepub fn cutoff_count(&self) -> usize
pub fn cutoff_count(&self) -> usize
Count response tokens that triggered cutoffs.
Sourcepub fn aside_count(&self) -> usize
pub fn aside_count(&self) -> usize
Count aside sequences.
Trait Implementations§
Source§impl Clone for DialogueContext
impl Clone for DialogueContext
Source§fn clone(&self) -> DialogueContext
fn clone(&self) -> DialogueContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DialogueContext
impl Debug for DialogueContext
Source§impl Default for DialogueContext
impl Default for DialogueContext
Source§fn default() -> DialogueContext
fn default() -> DialogueContext
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for DialogueContext
impl<'de> Deserialize<'de> for DialogueContext
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DialogueContext, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DialogueContext, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for DialogueContext
impl Serialize for DialogueContext
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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for DialogueContext
impl RefUnwindSafe for DialogueContext
impl Send for DialogueContext
impl Sync for DialogueContext
impl Unpin for DialogueContext
impl UnsafeUnpin for DialogueContext
impl UnwindSafe for DialogueContext
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
Mutably borrows from an owned value. Read more
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>,
impl<T> ErasedDestructor for Twhere
T: 'static,
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>
Converts
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>
Converts
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