Skip to main content

mistral_openapi_client/models/
completion_response_stream_choice.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 * The version of the OpenAPI document: 1.0.0
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct CompletionResponseStreamChoice {
16    #[serde(rename = "index")]
17    pub index: i32,
18    #[serde(rename = "delta")]
19    pub delta: Box<models::DeltaMessage>,
20    #[serde(rename = "finish_reason", deserialize_with = "Option::deserialize")]
21    pub finish_reason: Option<FinishReason>,
22}
23
24impl CompletionResponseStreamChoice {
25    pub fn new(index: i32, delta: models::DeltaMessage, finish_reason: Option<FinishReason>) -> CompletionResponseStreamChoice {
26        CompletionResponseStreamChoice {
27            index,
28            delta: Box::new(delta),
29            finish_reason,
30        }
31    }
32}
33/// 
34#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
35pub enum FinishReason {
36    #[serde(rename = "stop")]
37    Stop,
38    #[serde(rename = "length")]
39    Length,
40    #[serde(rename = "error")]
41    Error,
42    #[serde(rename = "tool_calls")]
43    ToolCalls,
44}
45
46impl Default for FinishReason {
47    fn default() -> FinishReason {
48        Self::Stop
49    }
50}
51