#[non_exhaustive]pub struct PromptResponse {
pub output: String,
pub usage: Usage,
pub completion_calls: Vec<CompletionCall>,
pub messages: Option<Vec<Message>>,
pub content: OneOrMany<AssistantContent>,
}Expand description
The result of an agent run, returned by both the blocking
(PromptRequest) and streaming (StreamingPromptRequest) surfaces so a
call site reads identically whether it used .prompt() or .stream_prompt().
On the streaming surface this is the payload of the terminal
MultiTurnStreamItem::FinalResponse item.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.output: StringConcatenated assistant text for the final turn.
usage: UsageAggregated token usage across the whole run.
completion_calls: Vec<CompletionCall>Successfully completed completion requests made by this agent run.
usage remains the aggregate across the whole run. Use the last
entry’s usage to inspect the final completion request’s prompt/context
length. Zero-valued entry usage means the provider reported no usage
metrics for that request.
messages: Option<Vec<Message>>Accumulated message history for the run (the run’s persisted transcript), unless memory/history bookkeeping was disabled for the request.
content: OneOrMany<AssistantContent>Structured assistant content for the final turn.
Where output is the concatenated text, this preserves
the individual content parts (text, reasoning, images, …).
Implementations§
Source§impl PromptResponse
impl PromptResponse
pub fn new(output: impl Into<String>, usage: Usage) -> Self
pub fn with_messages(self, messages: Vec<Message>) -> Self
Sourcepub fn with_completion_calls(
self,
completion_calls: Vec<CompletionCall>,
) -> Self
pub fn with_completion_calls( self, completion_calls: Vec<CompletionCall>, ) -> Self
Attach completion call details to this response.
Sourcepub fn with_content(self, content: OneOrMany<AssistantContent>) -> Self
pub fn with_content(self, content: OneOrMany<AssistantContent>) -> Self
Set the structured assistant content for the final turn.
Sourcepub fn messages(&self) -> Option<&[Message]>
pub fn messages(&self) -> Option<&[Message]>
The run’s accumulated message history, if tracked.
Sourcepub fn content(&self) -> &OneOrMany<AssistantContent>
pub fn content(&self) -> &OneOrMany<AssistantContent>
The structured assistant content for the final turn.
Sourcepub fn completion_calls(&self) -> &[CompletionCall]
pub fn completion_calls(&self) -> &[CompletionCall]
Returns successfully completed completion requests made by this agent run.
Zero-valued entry usage means the provider reported no usage metrics for that request.
Trait Implementations§
Source§impl Clone for PromptResponse
impl Clone for PromptResponse
Source§fn clone(&self) -> PromptResponse
fn clone(&self) -> PromptResponse
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 PromptResponse
impl Debug for PromptResponse
Source§impl<'de> Deserialize<'de> for PromptResponse
impl<'de> Deserialize<'de> for PromptResponse
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for PromptResponse
impl Display for PromptResponse
Auto Trait Implementations§
impl Freeze for PromptResponse
impl RefUnwindSafe for PromptResponse
impl Send for PromptResponse
impl Sync for PromptResponse
impl Unpin for PromptResponse
impl UnsafeUnpin for PromptResponse
impl UnwindSafe for PromptResponse
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> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
impl<T> CloneDebuggableStorage for Twhere
T: DebuggableStorage + Clone,
fn clone_storage(&self) -> Box<dyn CloneDebuggableStorage>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> CloneableStorage for T
impl<T> CloneableStorage for T
fn clone_storage(&self) -> Box<dyn CloneableStorage>
impl<T> DebuggableStorage for T
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> 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,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§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.