pub struct StreamTextResult<O> { /* private fields */ }Expand description
Result of a streaming call with independent event views and a final result.
Reading a view or awaiting final_result drives
progress. Views created through full_stream keep
their unread events until consumed or dropped; a slow view does not
block another view. The final owner drop cancels the pipeline.
Implementations§
Source§impl<O> StreamTextResult<O>
impl<O> StreamTextResult<O>
Sourcepub fn split(self) -> (EventStream, Completion<O>)
pub fn split(self) -> (EventStream, Completion<O>)
Splits the result into the event stream and the completion handle.
Sourcepub fn full_stream(&mut self) -> EventStream
pub fn full_stream(&mut self) -> EventStream
Creates an independent view starting at the current event cursor.
Creating a view leaves the result’s cursor in place, allowing later views to read the same events. Lagging views retain unread events.
Sourcepub fn into_completion(self) -> Completion<O> ⓘ
pub fn into_completion(self) -> Completion<O> ⓘ
Returns a completion future that drives the pipeline without an event consumer.
Sourcepub async fn final_result(self) -> Result<GenerateTextResult<O>, Error>
pub async fn final_result(self) -> Result<GenerateTextResult<O>, Error>
Drives the pipeline and returns its owned final result.
§Errors
Returns the error that ended the call. Retain the result to borrow its text, usage, steps and output repeatedly after successful completion.
Sourcepub fn text_view(&mut self) -> impl Stream<Item = String> + Send + use<O>
pub fn text_view(&mut self) -> impl Stream<Item = String> + Send + use<O>
Creates an independent view yielding only text deltas.
Inspect a full view or await the final result for terminal errors.
Sourcepub fn events(&mut self) -> &mut EventStream
pub fn events(&mut self) -> &mut EventStream
The result’s current event cursor; consuming it advances future view starts.
Source§impl<O: Send + Sync + 'static> StreamTextResult<O>
impl<O: Send + Sync + 'static> StreamTextResult<O>
Returns cloneable final-result waiters that jointly drive the pipeline.
The result and error are shared through Arc, so neither must be
cloneable. Each waiter resolves to the same allocation. Dropping all
waiters and event views cancels an unfinished call.
Source§impl<O: Send + 'static> StreamTextResult<O>
impl<O: Send + 'static> StreamTextResult<O>
Sourcepub fn text_stream(self) -> impl Stream<Item = Result<String, Error>> + Send
pub fn text_stream(self) -> impl Stream<Item = Result<String, Error>> + Send
Consumes the result, yielding text deltas only. The final item is an error when the call failed.
Sourcepub fn partial_output_stream(
self,
) -> impl Stream<Item = PartialOutput<O>> + Send
pub fn partial_output_stream( self, ) -> impl Stream<Item = PartialOutput<O>> + Send
Consumes the result, yielding the structured output as it grows.
Only the first text part of the call (or retry attempt) is parsed; a value is published
whenever the repaired partial JSON changes. Errors are not reported
here: use consume or the completion for them.
Sourcepub fn partial_output_view(
&mut self,
) -> impl Stream<Item = PartialOutput<O>> + Send + use<O>
pub fn partial_output_view( &mut self, ) -> impl Stream<Item = PartialOutput<O>> + Send + use<O>
Creates an independent view of changing structured output.
Like the consuming view, this parses the first text part per attempt; terminal errors remain available through the final result.