pub struct HarmonyContext { /* private fields */ }Expand description
Context for tracking Harmony parsing state within a sequence.
This wraps the openai-harmony crate’s StreamableParser and provides delta extraction for streaming responses.
Implementations§
Source§impl HarmonyContext
impl HarmonyContext
Sourcepub fn process_token(&mut self, token_id: u32) -> HarmonyDelta
pub fn process_token(&mut self, token_id: u32) -> HarmonyDelta
Process a token and return any new delta content
Sourcepub fn current_channel(&self) -> Option<HarmonyChannel>
pub fn current_channel(&self) -> Option<HarmonyChannel>
Get the currently active channel
Sourcepub fn accumulated(&self) -> &HarmonyAccumulated
pub fn accumulated(&self) -> &HarmonyAccumulated
Get all accumulated content
Sourcepub fn reasoning_content(&self) -> Option<String>
pub fn reasoning_content(&self) -> Option<String>
Get accumulated reasoning content (analysis + commentary)
Sourcepub fn final_content(&self) -> Option<String>
pub fn final_content(&self) -> Option<String>
Get accumulated final content
Sourcepub fn get_reasoning_delta(&mut self) -> Option<String>
pub fn get_reasoning_delta(&mut self) -> Option<String>
Get the reasoning delta since last call (for streaming). Returns new reasoning content that hasn’t been sent yet.
Sourcepub fn get_final_delta(&mut self) -> Option<String>
pub fn get_final_delta(&mut self) -> Option<String>
Get the final content delta since last call (for streaming). Returns new final content that hasn’t been sent yet.
Sourcepub fn process_eos(&mut self)
pub fn process_eos(&mut self)
Signal end of stream to the parser
Sourcepub fn current_recipient(&self) -> Option<String>
pub fn current_recipient(&self) -> Option<String>
Get the recipient (for tool calls) if any
Sourcepub fn has_tool_call(&self) -> bool
pub fn has_tool_call(&self) -> bool
Check if there’s a tool call in progress
Sourcepub fn get_tool_calls(&self) -> &[HarmonyToolCall]
pub fn get_tool_calls(&self) -> &[HarmonyToolCall]
Get all completed tool calls
Sourcepub fn get_current_tool_call(&self) -> Option<(&str, &str)>
pub fn get_current_tool_call(&self) -> Option<(&str, &str)>
Get the current tool call being built (if any) Returns (recipient, arguments_so_far)
Sourcepub fn finalize_tool_calls(&mut self) -> Vec<HarmonyToolCall>
pub fn finalize_tool_calls(&mut self) -> Vec<HarmonyToolCall>
Finalize any pending tool call and return all tool calls. This should be called when the sequence is done. Note: This takes ownership of the tool calls, so calling it twice will return an empty vector the second time.
Auto Trait Implementations§
impl Freeze for HarmonyContext
impl RefUnwindSafe for HarmonyContext
impl Send for HarmonyContext
impl Sync for HarmonyContext
impl Unpin for HarmonyContext
impl UnwindSafe for HarmonyContext
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<T> Downcast for Twhere
T: AsAny + ?Sized,
impl<T> Downcast for Twhere
T: AsAny + ?Sized,
§fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
fn downcast_ref<T>(&self) -> Option<&T>where
T: AsAny,
Any.§fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
fn downcast_mut<T>(&mut self) -> Option<&mut T>where
T: AsAny,
Any.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.