pub struct ChatCompletionCreateRequestBuilder { /* private fields */ }Expand description
表示聊天补全创建构建器。
Implementations§
Source§impl ChatCompletionCreateRequestBuilder
impl ChatCompletionCreateRequestBuilder
Sourcepub fn messages(self, messages: Vec<ChatCompletionMessage>) -> Self
pub fn messages(self, messages: Vec<ChatCompletionMessage>) -> Self
直接设置消息列表。
Sourcepub fn message_system(self, content: impl Into<String>) -> Self
pub fn message_system(self, content: impl Into<String>) -> Self
追加一条 system 消息。
Sourcepub fn message_user(self, content: impl Into<String>) -> Self
pub fn message_user(self, content: impl Into<String>) -> Self
追加一条 user 消息。
Sourcepub fn message_assistant(self, content: impl Into<String>) -> Self
pub fn message_assistant(self, content: impl Into<String>) -> Self
追加一条 assistant 消息。
Sourcepub fn temperature(self, temperature: f32) -> Self
pub fn temperature(self, temperature: f32) -> Self
设置温度。
Sourcepub fn max_tokens(self, max_tokens: u32) -> Self
pub fn max_tokens(self, max_tokens: u32) -> Self
设置最大 token 数。
Sourcepub fn tool(self, tool: ChatToolDefinition) -> Self
pub fn tool(self, tool: ChatToolDefinition) -> Self
追加工具定义。
Sourcepub fn tool_choice(self, tool_choice: impl Into<ChatToolChoice>) -> Self
pub fn tool_choice(self, tool_choice: impl Into<ChatToolChoice>) -> Self
设置工具选择策略。
Sourcepub fn extra_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
设置附加请求头。
Sourcepub fn extra_query(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn extra_query( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
设置附加查询参数。
Sourcepub fn extra_body(
self,
key: impl Into<String>,
value: impl Into<JsonPayload>,
) -> Self
pub fn extra_body( self, key: impl Into<String>, value: impl Into<JsonPayload>, ) -> Self
在请求体根对象中追加字段。
Sourcepub fn provider_option(
self,
key: impl Into<String>,
value: impl Into<JsonPayload>,
) -> Self
pub fn provider_option( self, key: impl Into<String>, value: impl Into<JsonPayload>, ) -> Self
在 provider 对应的 provider_options 节点下追加字段。
Sourcepub fn cancellation_token(self, token: CancellationToken) -> Self
pub fn cancellation_token(self, token: CancellationToken) -> Self
设置取消令牌。
Sourcepub async fn send(self) -> Result<ChatCompletion>
pub async fn send(self) -> Result<ChatCompletion>
Sourcepub async fn send_with_meta(self) -> Result<ApiResponse<ChatCompletion>>
pub async fn send_with_meta(self) -> Result<ApiResponse<ChatCompletion>>
Trait Implementations§
Source§impl Clone for ChatCompletionCreateRequestBuilder
impl Clone for ChatCompletionCreateRequestBuilder
Source§fn clone(&self) -> ChatCompletionCreateRequestBuilder
fn clone(&self) -> ChatCompletionCreateRequestBuilder
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 moreSource§impl Default for ChatCompletionCreateRequestBuilder
impl Default for ChatCompletionCreateRequestBuilder
Source§fn default() -> ChatCompletionCreateRequestBuilder
fn default() -> ChatCompletionCreateRequestBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ChatCompletionCreateRequestBuilder
impl !RefUnwindSafe for ChatCompletionCreateRequestBuilder
impl Send for ChatCompletionCreateRequestBuilder
impl Sync for ChatCompletionCreateRequestBuilder
impl Unpin for ChatCompletionCreateRequestBuilder
impl UnsafeUnpin for ChatCompletionCreateRequestBuilder
impl !UnwindSafe for ChatCompletionCreateRequestBuilder
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