mistral_rouille/models/chat_completion_request_function_call.rs
1/*
2 * Mistral AI API
3 *
4 * Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it.
5 *
6 * Build date: 2024-06-15T23:41:00.377209-06:00[America/Mexico_City]
7 * Generated using: https://openapi-generator.tech
8 * Open API specification v0.0.2 provided by Mistral @ https://docs.mistral.ai/redocusaurus/plugin-redoc-0.yaml
9 * Custom generation templates by [GovCraft Ai](https://www.govcraft.ai)
10 * Contact: roland@govcraft.ai
11 */
12
13use crate::models;
14use serde::{Deserialize, Serialize};
15
16#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
17pub struct ChatCompletionRequestFunctionCall {
18 /// ID of the model to use. You can use the [List Available Models](/api#operation/listModels) API to see all of your available models, or see our [Model overview](/models) for model descriptions.
19 #[serde(rename = "model")]
20 pub model: String,
21 /// The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be `user` or `system`. When role is `tool`, the properties should contain `tool_call_id` (string or `null`).
22 #[serde(rename = "messages")]
23 pub messages: Vec<models::ChatFnMessages>,
24 /// What sampling temperature to use, between 0.0 and 1.0. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or `top_p` but not both.
25 #[serde(rename = "temperature", skip_serializing_if = "Option::is_none")]
26 pub temperature: Option<f64>,
27 /// Nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or `temperature` but not both.
28 #[serde(rename = "top_p", skip_serializing_if = "Option::is_none")]
29 pub top_p: Option<f64>,
30 /// The maximum number of tokens to generate in the completion. The token count of your prompt plus `max_tokens` cannot exceed the model's context length.
31 #[serde(rename = "max_tokens", skip_serializing_if = "Option::is_none")]
32 pub max_tokens: Option<u32>,
33 /// Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
34 #[serde(rename = "stream", skip_serializing_if = "Option::is_none")]
35 pub stream: Option<bool>,
36 /// Whether to inject a safety prompt before all conversations.
37 #[serde(rename = "safe_prompt", skip_serializing_if = "Option::is_none")]
38 pub safe_prompt: Option<bool>,
39 /// A list of available tools for the model. Use this to specify functions for which the model can generate JSON inputs.
40 #[serde(rename = "tools", skip_serializing_if = "Option::is_none")]
41 pub tools: Option<Vec<models::ChatCompletionRequestFunctionCallToolsInner>>,
42 /// Specifies if/how functions are called. If set to `none` the model won't call a function and will generate a message instead. If set to `auto` the model can choose to either generate a message or call a function. If set to `any` the model is forced to call a function.
43 #[serde(rename = "tool_choice", skip_serializing_if = "Option::is_none")]
44 pub tool_choice: Option<String>,
45 /// The seed to use for random sampling. If set, different calls will generate deterministic results.
46 #[serde(rename = "random_seed", skip_serializing_if = "Option::is_none")]
47 pub random_seed: Option<i32>,
48}
49
50impl ChatCompletionRequestFunctionCall {
51 /// Creates a new `ChatCompletionRequestFunctionCall` instance.
52 ///
53 /// # Arguments
54 /// * `model`
55 /// * `messages`
56 ///
57 /// # Returns
58 ///
59 /// A new `ChatCompletionRequestFunctionCall` instance.
60 pub fn new(
61 model: String,
62 messages: Vec<models::ChatFnMessages>,
63 ) -> ChatCompletionRequestFunctionCall {
64 ChatCompletionRequestFunctionCall {
65 model,
66 messages,
67 temperature: None,
68 top_p: None,
69 max_tokens: None,
70 stream: None,
71 safe_prompt: None,
72 tools: None,
73 tool_choice: None,
74 random_seed: None,
75 }
76 }
77}