pub struct ChatCompletionRequest {Show 14 fields
pub model: String,
pub messages: Vec<ChatMessage>,
pub temperature: Option<f32>,
pub top_p: Option<f32>,
pub max_tokens: Option<u32>,
pub stop: Option<Vec<String>>,
pub stream: Option<bool>,
pub tools: Option<Vec<Tool>>,
pub tool_choice: Option<ToolChoice>,
pub frequency_penalty: Option<f32>,
pub presence_penalty: Option<f32>,
pub user: Option<String>,
pub response_format: Option<ResponseFormat>,
pub extra: HashMap<String, Value>,
}Expand description
Chat Completion 请求
Fields§
§model: String模型名称
messages: Vec<ChatMessage>消息列表
temperature: Option<f32>温度参数 (0.0 - 2.0)
top_p: Option<f32>Top-p 采样
max_tokens: Option<u32>生成的最大 token 数
stop: Option<Vec<String>>停止序列
stream: Option<bool>是否流式输出
tools: Option<Vec<Tool>>可用工具列表
tool_choice: Option<ToolChoice>工具选择策略
frequency_penalty: Option<f32>频率惩罚
presence_penalty: Option<f32>存在惩罚
user: Option<String>用户标识
response_format: Option<ResponseFormat>响应格式
extra: HashMap<String, Value>额外参数(用于不同提供商的特殊参数)
Implementations§
Source§impl ChatCompletionRequest
impl ChatCompletionRequest
Sourcepub fn new(model: impl Into<String>) -> ChatCompletionRequest
pub fn new(model: impl Into<String>) -> ChatCompletionRequest
创建新请求
Sourcepub fn message(self, message: ChatMessage) -> ChatCompletionRequest
pub fn message(self, message: ChatMessage) -> ChatCompletionRequest
添加消息
Sourcepub fn system(self, content: impl Into<String>) -> ChatCompletionRequest
pub fn system(self, content: impl Into<String>) -> ChatCompletionRequest
添加系统消息
Sourcepub fn user(self, content: impl Into<String>) -> ChatCompletionRequest
pub fn user(self, content: impl Into<String>) -> ChatCompletionRequest
添加用户消息
Sourcepub fn temperature(self, temp: f32) -> ChatCompletionRequest
pub fn temperature(self, temp: f32) -> ChatCompletionRequest
设置温度
Sourcepub fn max_tokens(self, tokens: u32) -> ChatCompletionRequest
pub fn max_tokens(self, tokens: u32) -> ChatCompletionRequest
设置最大 token 数
Sourcepub fn tool(self, tool: Tool) -> ChatCompletionRequest
pub fn tool(self, tool: Tool) -> ChatCompletionRequest
添加工具
Sourcepub fn tools(self, tools: Vec<Tool>) -> ChatCompletionRequest
pub fn tools(self, tools: Vec<Tool>) -> ChatCompletionRequest
设置工具列表
Sourcepub fn stream(self) -> ChatCompletionRequest
pub fn stream(self) -> ChatCompletionRequest
启用流式输出
Trait Implementations§
Source§impl Clone for ChatCompletionRequest
impl Clone for ChatCompletionRequest
Source§fn clone(&self) -> ChatCompletionRequest
fn clone(&self) -> ChatCompletionRequest
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 Debug for ChatCompletionRequest
impl Debug for ChatCompletionRequest
Source§impl Default for ChatCompletionRequest
impl Default for ChatCompletionRequest
Source§fn default() -> ChatCompletionRequest
fn default() -> ChatCompletionRequest
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for ChatCompletionRequest
impl<'de> Deserialize<'de> for ChatCompletionRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatCompletionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ChatCompletionRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for ChatCompletionRequest
impl Serialize for ChatCompletionRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for ChatCompletionRequest
impl RefUnwindSafe for ChatCompletionRequest
impl Send for ChatCompletionRequest
impl Sync for ChatCompletionRequest
impl Unpin for ChatCompletionRequest
impl UnsafeUnpin for ChatCompletionRequest
impl UnwindSafe for ChatCompletionRequest
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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> Message for T
impl<T> Message for T
Source§fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
fn from_boxed(m: BoxedMessage) -> Result<Self, BoxedDowncastErr>
Convert a BoxedMessage to this concrete type
Source§fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
fn box_message(self, pid: &ActorId) -> Result<BoxedMessage, BoxedDowncastErr>
Convert this message to a BoxedMessage