pub struct AsyncChatCompletion<N, M>{ /* private fields */ }Expand description
Builder for submitting a queued chat-completion task through a ZaiClient.
Posts to the async/chat/completions task-submission endpoint.
Implementations§
Source§impl<N, M> AsyncChatCompletion<N, M>
impl<N, M> AsyncChatCompletion<N, M>
Sourcepub fn new(model: N, messages: M) -> Self
pub fn new(model: N, messages: M) -> Self
Create a new async chat request from a model and the first message batch.
Sourcepub fn add_message(self, message: M) -> Self
pub fn add_message(self, message: M) -> Self
Append one message to the conversation.
Sourcepub fn extend_messages(self, messages: impl IntoIterator<Item = M>) -> Self
pub fn extend_messages(self, messages: impl IntoIterator<Item = M>) -> Self
Append multiple messages to the conversation.
Sourcepub fn with_request_id(self, request_id: impl Into<String>) -> Self
pub fn with_request_id(self, request_id: impl Into<String>) -> Self
Set the client-provided request identifier.
Sourcepub fn with_do_sample(self, do_sample: bool) -> Self
pub fn with_do_sample(self, do_sample: bool) -> Self
Enable or disable probabilistic sampling.
Sourcepub fn with_temperature(self, temperature: f64) -> Self
pub fn with_temperature(self, temperature: f64) -> Self
Set the sampling temperature.
Sourcepub fn with_top_p(self, top_p: f64) -> Self
pub fn with_top_p(self, top_p: f64) -> Self
Set the nucleus-sampling probability.
Sourcepub fn with_max_tokens(self, max_tokens: u32) -> Self
pub fn with_max_tokens(self, max_tokens: u32) -> Self
Set the maximum number of generated tokens.
Sourcepub fn add_tool(self, tool: N::Tool) -> Selfwhere
N: ChatToolSupport,
pub fn add_tool(self, tool: N::Tool) -> Selfwhere
N: ChatToolSupport,
Add one tool the model may call.
Sourcepub fn add_tools(self, tools: impl IntoIterator<Item = N::Tool>) -> Selfwhere
N: ChatToolSupport,
pub fn add_tools(self, tools: impl IntoIterator<Item = N::Tool>) -> Selfwhere
N: ChatToolSupport,
Add multiple tools the model may call.
Sourcepub fn with_tool_choice(self, tool_choice: ToolChoice) -> Selfwhere
N: ChatToolSupport,
pub fn with_tool_choice(self, tool_choice: ToolChoice) -> Selfwhere
N: ChatToolSupport,
Set automatic tool selection.
Sourcepub fn clear_tools(self) -> Selfwhere
N: ChatToolSupport,
pub fn clear_tools(self) -> Selfwhere
N: ChatToolSupport,
Remove all tools and their selection policy.
Sourcepub fn with_response_format(self, format: ResponseFormat) -> Selfwhere
N: ResponseFormatEnable,
pub fn with_response_format(self, format: ResponseFormat) -> Selfwhere
N: ResponseFormatEnable,
Set the response format for a text model.
Sourcepub fn with_watermark_enabled(self, enabled: bool) -> Selfwhere
N: WatermarkEnable,
pub fn with_watermark_enabled(self, enabled: bool) -> Selfwhere
N: WatermarkEnable,
Enable or disable audio-output watermarking.
Sourcepub fn with_user_id(self, user_id: impl Into<String>) -> Self
pub fn with_user_id(self, user_id: impl Into<String>) -> Self
Set the end-user identifier used for abuse monitoring.
Sourcepub fn with_stop(self, stop: impl Into<String>) -> Self
pub fn with_stop(self, stop: impl Into<String>) -> Self
Add the stop sequence for this request.
Sourcepub fn with_thinking(self, thinking: ThinkingType) -> Selfwhere
N: ThinkEnable,
pub fn with_thinking(self, thinking: ThinkingType) -> Selfwhere
N: ThinkEnable,
Configure thinking mode for a model that supports it.
Sourcepub fn with_reasoning_effort(self, effort: ReasoningEffort) -> Selfwhere
N: ReasoningEffortEnable,
pub fn with_reasoning_effort(self, effort: ReasoningEffort) -> Selfwhere
N: ReasoningEffortEnable,
Set reasoning depth for a model that supports reasoning_effort.