pub struct Completion {
pub text: String,
pub tool_calls: Vec<ToolCall>,
pub stop_reason: StopReason,
pub usage: Usage,
pub model: String,
}Expand description
One answer from a model.
Fields§
§text: String§tool_calls: Vec<ToolCall>§stop_reason: StopReason§usage: Usage§model: StringThe model that actually answered, which is not always the one asked for — providers alias and pin.
Implementations§
Source§impl Completion
impl Completion
Sourcepub fn text(text: impl Into<String>) -> Completion
pub fn text(text: impl Into<String>) -> Completion
A plain text answer, mostly for fakes and tests.
pub fn with_tool_call(self, call: ToolCall) -> Completion
pub fn with_usage(self, usage: Usage) -> Completion
pub fn with_model(self, model: impl Into<String>) -> Completion
pub fn wants_tools(&self) -> bool
Sourcepub fn to_message(&self) -> Message
pub fn to_message(&self) -> Message
Replay this answer as an assistant turn.
The tool loop has to put the assistant’s own words and its tool requests back into the conversation, or the provider rejects the tool results as answers to a question nobody asked.
Trait Implementations§
Source§impl Clone for Completion
impl Clone for Completion
Source§impl Debug for Completion
impl Debug for Completion
Source§impl Default for Completion
impl Default for Completion
Source§fn default() -> Completion
fn default() -> Completion
Returns the “default value” for a type. Read more
Source§impl PartialEq for Completion
impl PartialEq for Completion
impl StructuralPartialEq for Completion
Auto Trait Implementations§
impl Freeze for Completion
impl RefUnwindSafe for Completion
impl Send for Completion
impl Sync for Completion
impl Unpin for Completion
impl UnsafeUnpin for Completion
impl UnwindSafe for Completion
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