Skip to main content

ds_api/raw/response/non_streaming/
chat_completion_response.rs

1use serde::Deserialize;
2
3use super::{choice::Choice, object_type::ObjectType, usage::Usage};
4use crate::raw::Model;
5
6#[derive(Debug, Deserialize)]
7pub struct ChatCompletionResponse {
8    pub id: String,
9    pub choices: Vec<Choice>,
10    pub created: u64,
11    pub model: Model,
12    #[serde(default)]
13    pub system_fingerprint: Option<String>,
14    #[serde(rename = "object")]
15    pub object: ObjectType,
16    pub usage: Usage,
17}
18
19impl ChatCompletionResponse {
20    pub fn content(&self) -> Option<&str> {
21        self.choices.first()?.message.content.as_deref()
22    }
23}