ChatCompletionRequest

Struct ChatCompletionRequest 

Source
pub struct ChatCompletionRequest {
Show 19 fields pub model: String, pub messages: Vec<ChatCompletionMessage>, pub temperature: Option<f64>, pub top_p: Option<f64>, pub n: Option<i64>, pub response_format: Option<Value>, pub stream: Option<bool>, pub stop: Option<Vec<String>>, pub max_tokens: Option<i64>, pub presence_penalty: Option<f64>, pub frequency_penalty: Option<f64>, pub logit_bias: Option<HashMap<String, i32>>, pub user: Option<String>, pub seed: Option<i64>, pub tools: Option<Vec<Tool>>, pub parallel_tool_calls: Option<bool>, pub tool_choice: Option<ToolChoiceType>, pub reasoning: Option<Reasoning>, pub transforms: Option<Vec<String>>,
}

Fields§

§model: String§messages: Vec<ChatCompletionMessage>§temperature: Option<f64>§top_p: Option<f64>§n: Option<i64>§response_format: Option<Value>§stream: Option<bool>§stop: Option<Vec<String>>§max_tokens: Option<i64>§presence_penalty: Option<f64>§frequency_penalty: Option<f64>§logit_bias: Option<HashMap<String, i32>>§user: Option<String>§seed: Option<i64>§tools: Option<Vec<Tool>>§parallel_tool_calls: Option<bool>§tool_choice: Option<ToolChoiceType>§reasoning: Option<Reasoning>§transforms: Option<Vec<String>>

Optional list of transforms to apply to the chat completion request.

Transforms allow modifying the request before it’s sent to the API, enabling features like prompt rewriting, content filtering, or other preprocessing steps. When None, no transforms are applied.

Implementations§

Source§

impl ChatCompletionRequest

Source

pub fn new(model: String, messages: Vec<ChatCompletionMessage>) -> Self

Examples found in repository?
examples/openrouter.rs (lines 14-23)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let api_key = env::var("OPENROUTER_API_KEY").unwrap().to_string();
9    let mut client = OpenAIClient::builder()
10        .with_endpoint("https://openrouter.ai/api/v1")
11        .with_api_key(api_key)
12        .build()?;
13
14    let req = ChatCompletionRequest::new(
15        GPT4_O_MINI.to_string(),
16        vec![chat_completion::ChatCompletionMessage {
17            role: chat_completion::MessageRole::user,
18            content: chat_completion::Content::Text(String::from("What is bitcoin?")),
19            name: None,
20            tool_calls: None,
21            tool_call_id: None,
22        }],
23    );
24
25    let result = client.chat_completion(req).await?;
26    println!("Content: {:?}", result.choices[0].message.content);
27    println!("Response Headers: {:?}", client.response_headers);
28
29    Ok(())
30}
More examples
Hide additional examples
examples/chat_completion.rs (lines 11-20)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
9    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
10
11    let req = ChatCompletionRequest::new(
12        GPT4_O_MINI.to_string(),
13        vec![chat_completion::ChatCompletionMessage {
14            role: chat_completion::MessageRole::user,
15            content: chat_completion::Content::Text(String::from("What is bitcoin?")),
16            name: None,
17            tool_calls: None,
18            tool_call_id: None,
19        }],
20    );
21
22    let result = client.chat_completion(req).await?;
23    println!("Content: {:?}", result.choices[0].message.content);
24
25    // print response headers
26    for (key, value) in client.response_headers.unwrap().iter() {
27        println!("{}: {:?}", key, value);
28    }
29
30    Ok(())
31}
examples/vision.rs (lines 11-35)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
9    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
10
11    let req = ChatCompletionRequest::new(
12        GPT4_O.to_string(),
13        vec![chat_completion::ChatCompletionMessage {
14            role: chat_completion::MessageRole::user,
15            content: chat_completion::Content::ImageUrl(vec![
16                chat_completion::ImageUrl {
17                    r#type: chat_completion::ContentType::text,
18                    text: Some(String::from("What's in this image?")),
19                    image_url: None,
20                },
21                chat_completion::ImageUrl {
22                    r#type: chat_completion::ContentType::image_url,
23                    text: None,
24                    image_url: Some(chat_completion::ImageUrlType {
25                        url: String::from(
26                            "https://upload.wikimedia.org/wikipedia/commons/5/50/Bitcoin.png",
27                        ),
28                    }),
29                },
30            ]),
31            name: None,
32            tool_calls: None,
33            tool_call_id: None,
34        }],
35    );
36
37    let result = client.chat_completion(req).await?;
38    println!("{:?}", result.choices[0].message.content);
39
40    Ok(())
41}
examples/openrouter_reasoning.rs (lines 16-27)
8async fn main() -> Result<(), Box<dyn std::error::Error>> {
9    let api_key = env::var("OPENROUTER_API_KEY").unwrap().to_string();
10    let mut client = OpenAIClient::builder()
11        .with_endpoint("https://openrouter.ai/api/v1")
12        .with_api_key(api_key)
13        .build()?;
14
15    // Example 1: Using reasoning with effort
16    let mut req = ChatCompletionRequest::new(
17        "x-ai/grok-3-mini".to_string(), // Grok model that supports reasoning
18        vec![chat_completion::ChatCompletionMessage {
19            role: chat_completion::MessageRole::user,
20            content: chat_completion::Content::Text(String::from(
21                "Explain quantum computing in simple terms.",
22            )),
23            name: None,
24            tool_calls: None,
25            tool_call_id: None,
26        }],
27    );
28
29    // Set reasoning with high effort
30    req.reasoning = Some(Reasoning {
31        mode: Some(ReasoningMode::Effort {
32            effort: ReasoningEffort::High,
33        }),
34        exclude: Some(false), // Include reasoning in response
35        enabled: None,
36    });
37
38    let result = client.chat_completion(req).await?;
39    println!("Content: {:?}", result.choices[0].message.content);
40
41    // Example 2: Using reasoning with max_tokens
42    let mut req2 = ChatCompletionRequest::new(
43        "anthropic/claude-4-sonnet".to_string(), // Claude model that supports max_tokens
44        vec![chat_completion::ChatCompletionMessage {
45            role: chat_completion::MessageRole::user,
46            content: chat_completion::Content::Text(String::from(
47                "What's the most efficient sorting algorithm?",
48            )),
49            name: None,
50            tool_calls: None,
51            tool_call_id: None,
52        }],
53    );
54
55    // Set reasoning with max_tokens
56    req2.reasoning = Some(Reasoning {
57        mode: Some(ReasoningMode::MaxTokens { max_tokens: 2000 }),
58        exclude: None,
59        enabled: None,
60    });
61
62    let result2 = client.chat_completion(req2).await?;
63    println!("Content: {:?}", result2.choices[0].message.content);
64
65    Ok(())
66}
examples/function_call.rs (lines 33-42)
19async fn main() -> Result<(), Box<dyn std::error::Error>> {
20    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
21    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
22
23    let mut properties = HashMap::new();
24    properties.insert(
25        "coin".to_string(),
26        Box::new(types::JSONSchemaDefine {
27            schema_type: Some(types::JSONSchemaType::String),
28            description: Some("The cryptocurrency to get the price of".to_string()),
29            ..Default::default()
30        }),
31    );
32
33    let req = ChatCompletionRequest::new(
34        GPT4_O.to_string(),
35        vec![chat_completion::ChatCompletionMessage {
36            role: chat_completion::MessageRole::user,
37            content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
38            name: None,
39            tool_calls: None,
40            tool_call_id: None,
41        }],
42    )
43    .tools(vec![chat_completion::Tool {
44        r#type: chat_completion::ToolType::Function,
45        function: types::Function {
46            name: String::from("get_coin_price"),
47            description: Some(String::from("Get the price of a cryptocurrency")),
48            parameters: types::FunctionParameters {
49                schema_type: types::JSONSchemaType::Object,
50                properties: Some(properties),
51                required: Some(vec![String::from("coin")]),
52            },
53        },
54    }])
55    .tool_choice(chat_completion::ToolChoiceType::Auto);
56
57    // debug request json
58    // let serialized = serde_json::to_string(&req).unwrap();
59    // println!("{}", serialized);
60
61    let result = client.chat_completion(req).await?;
62
63    match result.choices[0].finish_reason {
64        None => {
65            println!("No finish_reason");
66            println!("{:?}", result.choices[0].message.content);
67        }
68        Some(chat_completion::FinishReason::stop) => {
69            println!("Stop");
70            println!("{:?}", result.choices[0].message.content);
71        }
72        Some(chat_completion::FinishReason::length) => {
73            println!("Length");
74        }
75        Some(chat_completion::FinishReason::tool_calls) => {
76            println!("ToolCalls");
77            #[derive(Deserialize, Serialize)]
78            struct Currency {
79                coin: String,
80            }
81            let tool_calls = result.choices[0].message.tool_calls.as_ref().unwrap();
82            for tool_call in tool_calls {
83                let name = tool_call.function.name.clone().unwrap();
84                let arguments = tool_call.function.arguments.clone().unwrap();
85                let c: Currency = serde_json::from_str(&arguments)?;
86                let coin = c.coin;
87                if name == "get_coin_price" {
88                    let price = get_coin_price(&coin);
89                    println!("{coin} price: {price}");
90                }
91            }
92        }
93        Some(chat_completion::FinishReason::content_filter) => {
94            println!("ContentFilter");
95        }
96        Some(chat_completion::FinishReason::null) => {
97            println!("Null");
98        }
99    }
100    Ok(())
101}
examples/function_call_role.rs (lines 33-42)
19async fn main() -> Result<(), Box<dyn std::error::Error>> {
20    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
21    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
22
23    let mut properties = HashMap::new();
24    properties.insert(
25        "coin".to_string(),
26        Box::new(types::JSONSchemaDefine {
27            schema_type: Some(types::JSONSchemaType::String),
28            description: Some("The cryptocurrency to get the price of".to_string()),
29            ..Default::default()
30        }),
31    );
32
33    let req = ChatCompletionRequest::new(
34        GPT4_O.to_string(),
35        vec![chat_completion::ChatCompletionMessage {
36            role: chat_completion::MessageRole::user,
37            content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
38            name: None,
39            tool_calls: None,
40            tool_call_id: None,
41        }],
42    )
43    .tools(vec![chat_completion::Tool {
44        r#type: chat_completion::ToolType::Function,
45        function: types::Function {
46            name: String::from("get_coin_price"),
47            description: Some(String::from("Get the price of a cryptocurrency")),
48            parameters: types::FunctionParameters {
49                schema_type: types::JSONSchemaType::Object,
50                properties: Some(properties),
51                required: Some(vec![String::from("coin")]),
52            },
53        },
54    }]);
55
56    let result = client.chat_completion(req).await?;
57
58    match result.choices[0].finish_reason {
59        None => {
60            println!("No finish_reason");
61            println!("{:?}", result.choices[0].message.content);
62        }
63        Some(chat_completion::FinishReason::stop) => {
64            println!("Stop");
65            println!("{:?}", result.choices[0].message.content);
66        }
67        Some(chat_completion::FinishReason::length) => {
68            println!("Length");
69        }
70        Some(chat_completion::FinishReason::tool_calls) => {
71            println!("ToolCalls");
72            #[derive(Deserialize, Serialize)]
73            struct Currency {
74                coin: String,
75            }
76            let tool_calls = result.choices[0].message.tool_calls.as_ref().unwrap();
77            for tool_call in tool_calls {
78                let function_call = &tool_call.function;
79                let arguments = function_call.arguments.clone().unwrap();
80                let c: Currency = serde_json::from_str(&arguments)?;
81                let coin = c.coin;
82                println!("coin: {coin}");
83                let price = get_coin_price(&coin);
84                println!("price: {price}");
85
86                let req = ChatCompletionRequest::new(
87                    GPT4_O.to_string(),
88                    vec![
89                        chat_completion::ChatCompletionMessage {
90                            role: chat_completion::MessageRole::user,
91                            content: chat_completion::Content::Text(String::from(
92                                "What is the price of Ethereum?",
93                            )),
94                            name: None,
95                            tool_calls: None,
96                            tool_call_id: None,
97                        },
98                        chat_completion::ChatCompletionMessage {
99                            role: chat_completion::MessageRole::function,
100                            content: chat_completion::Content::Text({
101                                let price = get_coin_price(&coin);
102                                format!("{{\"price\": {price}}}")
103                            }),
104                            name: Some(String::from("get_coin_price")),
105                            tool_calls: None,
106                            tool_call_id: None,
107                        },
108                    ],
109                );
110
111                let result = client.chat_completion(req).await?;
112                println!("{:?}", result.choices[0].message.content);
113            }
114        }
115        Some(chat_completion::FinishReason::content_filter) => {
116            println!("ContentFilter");
117        }
118        Some(chat_completion::FinishReason::null) => {
119            println!("Null");
120        }
121    }
122    Ok(())
123}
Source§

impl ChatCompletionRequest

Source

pub fn temperature(self, temperature: f64) -> Self

Source

pub fn top_p(self, top_p: f64) -> Self

Source

pub fn n(self, n: i64) -> Self

Source

pub fn response_format(self, response_format: Value) -> Self

Source

pub fn stream(self, stream: bool) -> Self

Source

pub fn stop(self, stop: Vec<String>) -> Self

Source

pub fn max_tokens(self, max_tokens: i64) -> Self

Source

pub fn presence_penalty(self, presence_penalty: f64) -> Self

Source

pub fn frequency_penalty(self, frequency_penalty: f64) -> Self

Source

pub fn logit_bias(self, logit_bias: HashMap<String, i32>) -> Self

Source

pub fn user(self, user: String) -> Self

Source

pub fn seed(self, seed: i64) -> Self

Source

pub fn tools(self, tools: Vec<Tool>) -> Self

Examples found in repository?
examples/function_call.rs (lines 43-54)
19async fn main() -> Result<(), Box<dyn std::error::Error>> {
20    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
21    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
22
23    let mut properties = HashMap::new();
24    properties.insert(
25        "coin".to_string(),
26        Box::new(types::JSONSchemaDefine {
27            schema_type: Some(types::JSONSchemaType::String),
28            description: Some("The cryptocurrency to get the price of".to_string()),
29            ..Default::default()
30        }),
31    );
32
33    let req = ChatCompletionRequest::new(
34        GPT4_O.to_string(),
35        vec![chat_completion::ChatCompletionMessage {
36            role: chat_completion::MessageRole::user,
37            content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
38            name: None,
39            tool_calls: None,
40            tool_call_id: None,
41        }],
42    )
43    .tools(vec![chat_completion::Tool {
44        r#type: chat_completion::ToolType::Function,
45        function: types::Function {
46            name: String::from("get_coin_price"),
47            description: Some(String::from("Get the price of a cryptocurrency")),
48            parameters: types::FunctionParameters {
49                schema_type: types::JSONSchemaType::Object,
50                properties: Some(properties),
51                required: Some(vec![String::from("coin")]),
52            },
53        },
54    }])
55    .tool_choice(chat_completion::ToolChoiceType::Auto);
56
57    // debug request json
58    // let serialized = serde_json::to_string(&req).unwrap();
59    // println!("{}", serialized);
60
61    let result = client.chat_completion(req).await?;
62
63    match result.choices[0].finish_reason {
64        None => {
65            println!("No finish_reason");
66            println!("{:?}", result.choices[0].message.content);
67        }
68        Some(chat_completion::FinishReason::stop) => {
69            println!("Stop");
70            println!("{:?}", result.choices[0].message.content);
71        }
72        Some(chat_completion::FinishReason::length) => {
73            println!("Length");
74        }
75        Some(chat_completion::FinishReason::tool_calls) => {
76            println!("ToolCalls");
77            #[derive(Deserialize, Serialize)]
78            struct Currency {
79                coin: String,
80            }
81            let tool_calls = result.choices[0].message.tool_calls.as_ref().unwrap();
82            for tool_call in tool_calls {
83                let name = tool_call.function.name.clone().unwrap();
84                let arguments = tool_call.function.arguments.clone().unwrap();
85                let c: Currency = serde_json::from_str(&arguments)?;
86                let coin = c.coin;
87                if name == "get_coin_price" {
88                    let price = get_coin_price(&coin);
89                    println!("{coin} price: {price}");
90                }
91            }
92        }
93        Some(chat_completion::FinishReason::content_filter) => {
94            println!("ContentFilter");
95        }
96        Some(chat_completion::FinishReason::null) => {
97            println!("Null");
98        }
99    }
100    Ok(())
101}
More examples
Hide additional examples
examples/function_call_role.rs (lines 43-54)
19async fn main() -> Result<(), Box<dyn std::error::Error>> {
20    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
21    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
22
23    let mut properties = HashMap::new();
24    properties.insert(
25        "coin".to_string(),
26        Box::new(types::JSONSchemaDefine {
27            schema_type: Some(types::JSONSchemaType::String),
28            description: Some("The cryptocurrency to get the price of".to_string()),
29            ..Default::default()
30        }),
31    );
32
33    let req = ChatCompletionRequest::new(
34        GPT4_O.to_string(),
35        vec![chat_completion::ChatCompletionMessage {
36            role: chat_completion::MessageRole::user,
37            content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
38            name: None,
39            tool_calls: None,
40            tool_call_id: None,
41        }],
42    )
43    .tools(vec![chat_completion::Tool {
44        r#type: chat_completion::ToolType::Function,
45        function: types::Function {
46            name: String::from("get_coin_price"),
47            description: Some(String::from("Get the price of a cryptocurrency")),
48            parameters: types::FunctionParameters {
49                schema_type: types::JSONSchemaType::Object,
50                properties: Some(properties),
51                required: Some(vec![String::from("coin")]),
52            },
53        },
54    }]);
55
56    let result = client.chat_completion(req).await?;
57
58    match result.choices[0].finish_reason {
59        None => {
60            println!("No finish_reason");
61            println!("{:?}", result.choices[0].message.content);
62        }
63        Some(chat_completion::FinishReason::stop) => {
64            println!("Stop");
65            println!("{:?}", result.choices[0].message.content);
66        }
67        Some(chat_completion::FinishReason::length) => {
68            println!("Length");
69        }
70        Some(chat_completion::FinishReason::tool_calls) => {
71            println!("ToolCalls");
72            #[derive(Deserialize, Serialize)]
73            struct Currency {
74                coin: String,
75            }
76            let tool_calls = result.choices[0].message.tool_calls.as_ref().unwrap();
77            for tool_call in tool_calls {
78                let function_call = &tool_call.function;
79                let arguments = function_call.arguments.clone().unwrap();
80                let c: Currency = serde_json::from_str(&arguments)?;
81                let coin = c.coin;
82                println!("coin: {coin}");
83                let price = get_coin_price(&coin);
84                println!("price: {price}");
85
86                let req = ChatCompletionRequest::new(
87                    GPT4_O.to_string(),
88                    vec![
89                        chat_completion::ChatCompletionMessage {
90                            role: chat_completion::MessageRole::user,
91                            content: chat_completion::Content::Text(String::from(
92                                "What is the price of Ethereum?",
93                            )),
94                            name: None,
95                            tool_calls: None,
96                            tool_call_id: None,
97                        },
98                        chat_completion::ChatCompletionMessage {
99                            role: chat_completion::MessageRole::function,
100                            content: chat_completion::Content::Text({
101                                let price = get_coin_price(&coin);
102                                format!("{{\"price\": {price}}}")
103                            }),
104                            name: Some(String::from("get_coin_price")),
105                            tool_calls: None,
106                            tool_call_id: None,
107                        },
108                    ],
109                );
110
111                let result = client.chat_completion(req).await?;
112                println!("{:?}", result.choices[0].message.content);
113            }
114        }
115        Some(chat_completion::FinishReason::content_filter) => {
116            println!("ContentFilter");
117        }
118        Some(chat_completion::FinishReason::null) => {
119            println!("Null");
120        }
121    }
122    Ok(())
123}
Source

pub fn parallel_tool_calls(self, parallel_tool_calls: bool) -> Self

Source

pub fn tool_choice(self, tool_choice: ToolChoiceType) -> Self

Examples found in repository?
examples/function_call.rs (line 55)
19async fn main() -> Result<(), Box<dyn std::error::Error>> {
20    let api_key = env::var("OPENAI_API_KEY").unwrap().to_string();
21    let mut client = OpenAIClient::builder().with_api_key(api_key).build()?;
22
23    let mut properties = HashMap::new();
24    properties.insert(
25        "coin".to_string(),
26        Box::new(types::JSONSchemaDefine {
27            schema_type: Some(types::JSONSchemaType::String),
28            description: Some("The cryptocurrency to get the price of".to_string()),
29            ..Default::default()
30        }),
31    );
32
33    let req = ChatCompletionRequest::new(
34        GPT4_O.to_string(),
35        vec![chat_completion::ChatCompletionMessage {
36            role: chat_completion::MessageRole::user,
37            content: chat_completion::Content::Text(String::from("What is the price of Ethereum?")),
38            name: None,
39            tool_calls: None,
40            tool_call_id: None,
41        }],
42    )
43    .tools(vec![chat_completion::Tool {
44        r#type: chat_completion::ToolType::Function,
45        function: types::Function {
46            name: String::from("get_coin_price"),
47            description: Some(String::from("Get the price of a cryptocurrency")),
48            parameters: types::FunctionParameters {
49                schema_type: types::JSONSchemaType::Object,
50                properties: Some(properties),
51                required: Some(vec![String::from("coin")]),
52            },
53        },
54    }])
55    .tool_choice(chat_completion::ToolChoiceType::Auto);
56
57    // debug request json
58    // let serialized = serde_json::to_string(&req).unwrap();
59    // println!("{}", serialized);
60
61    let result = client.chat_completion(req).await?;
62
63    match result.choices[0].finish_reason {
64        None => {
65            println!("No finish_reason");
66            println!("{:?}", result.choices[0].message.content);
67        }
68        Some(chat_completion::FinishReason::stop) => {
69            println!("Stop");
70            println!("{:?}", result.choices[0].message.content);
71        }
72        Some(chat_completion::FinishReason::length) => {
73            println!("Length");
74        }
75        Some(chat_completion::FinishReason::tool_calls) => {
76            println!("ToolCalls");
77            #[derive(Deserialize, Serialize)]
78            struct Currency {
79                coin: String,
80            }
81            let tool_calls = result.choices[0].message.tool_calls.as_ref().unwrap();
82            for tool_call in tool_calls {
83                let name = tool_call.function.name.clone().unwrap();
84                let arguments = tool_call.function.arguments.clone().unwrap();
85                let c: Currency = serde_json::from_str(&arguments)?;
86                let coin = c.coin;
87                if name == "get_coin_price" {
88                    let price = get_coin_price(&coin);
89                    println!("{coin} price: {price}");
90                }
91            }
92        }
93        Some(chat_completion::FinishReason::content_filter) => {
94            println!("ContentFilter");
95        }
96        Some(chat_completion::FinishReason::null) => {
97            println!("Null");
98        }
99    }
100    Ok(())
101}
Source

pub fn reasoning(self, reasoning: Reasoning) -> Self

Source

pub fn transforms(self, transforms: Vec<String>) -> Self

Trait Implementations§

Source§

impl Clone for ChatCompletionRequest

Source§

fn clone(&self) -> ChatCompletionRequest

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ChatCompletionRequest

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ChatCompletionRequest

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for ChatCompletionRequest

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,