pub struct ChatCompletionResponseBuilder { /* private fields */ }Expand description
Builder for ChatCompletionResponse
Provides a fluent interface for constructing chat completion responses with sensible defaults.
Implementations§
Source§impl ChatCompletionResponseBuilder
impl ChatCompletionResponseBuilder
Sourcepub fn new(id: impl Into<String>, model: impl Into<String>) -> Self
pub fn new(id: impl Into<String>, model: impl Into<String>) -> Self
Create a new builder with required fields
§Arguments
id: Completion ID (e.g., “chatcmpl_abc123”)model: Model name used for generation
Sourcepub fn copy_from_request(self, request: &ChatCompletionRequest) -> Self
pub fn copy_from_request(self, request: &ChatCompletionRequest) -> Self
Copy common fields from a ChatCompletionRequest
This populates the model field from the request.
Sourcepub fn object(self, object: impl Into<String>) -> Self
pub fn object(self, object: impl Into<String>) -> Self
Set the object type (default: “chat.completion”)
Sourcepub fn created(self, timestamp: u64) -> Self
pub fn created(self, timestamp: u64) -> Self
Set the creation timestamp (default: current time)
Sourcepub fn choices(self, choices: Vec<ChatChoice>) -> Self
pub fn choices(self, choices: Vec<ChatChoice>) -> Self
Set the choices
Sourcepub fn add_choice(self, choice: ChatChoice) -> Self
pub fn add_choice(self, choice: ChatChoice) -> Self
Add a single choice
Sourcepub fn maybe_usage(self, usage: Option<Usage>) -> Self
pub fn maybe_usage(self, usage: Option<Usage>) -> Self
Set usage if provided (handles Option)
Sourcepub fn maybe_system_fingerprint(
self,
fingerprint: Option<impl Into<String>>,
) -> Self
pub fn maybe_system_fingerprint( self, fingerprint: Option<impl Into<String>>, ) -> Self
Set system fingerprint if provided (handles Option)
Sourcepub fn build(self) -> ChatCompletionResponse
pub fn build(self) -> ChatCompletionResponse
Build the ChatCompletionResponse
Trait Implementations§
Source§impl Clone for ChatCompletionResponseBuilder
impl Clone for ChatCompletionResponseBuilder
Source§fn clone(&self) -> ChatCompletionResponseBuilder
fn clone(&self) -> ChatCompletionResponseBuilder
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ChatCompletionResponseBuilder
impl RefUnwindSafe for ChatCompletionResponseBuilder
impl Send for ChatCompletionResponseBuilder
impl Sync for ChatCompletionResponseBuilder
impl Unpin for ChatCompletionResponseBuilder
impl UnwindSafe for ChatCompletionResponseBuilder
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