openai_interface/chat/
delete.rs1pub mod request {
7 use url::Url;
8
9 use crate::{
10 chat::delete::response::ChatCompletionDeleted,
11 errors::OapiError,
12 rest::delete::{Delete, DeleteNoStream},
13 };
14
15 #[derive(Debug, Clone)]
20 pub struct ChatDeleteRequest<'a> {
21 pub completion_id: &'a str,
22 }
23
24 impl Delete for ChatDeleteRequest<'_> {
25 fn build_url(&self, base_url: &str) -> Result<String, crate::errors::OapiError> {
29 let mut url = Url::parse(base_url).map_err(OapiError::UrlError)?;
30 url.path_segments_mut()
31 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
32 .push("chat")
33 .push("completions")
34 .push(self.completion_id);
35 Ok(url.to_string())
36 }
37 }
38
39 impl DeleteNoStream for ChatDeleteRequest<'_> {
40 type Response = ChatCompletionDeleted;
41 }
42}
43
44pub mod response {
45 use serde::Deserialize;
46
47 #[derive(Debug, Clone, Deserialize)]
50 pub struct ChatCompletionDeleted {
51 pub id: String,
53 pub deleted: bool,
55 pub object: ChatCompletionDeletedObject,
57 }
58
59 #[derive(Debug, Clone, Deserialize)]
60 pub enum ChatCompletionDeletedObject {
61 #[serde(rename = "chat.completion.deleted")]
62 ChatCompletionDeleted,
63 }
64
65 crate::impl_from_str!(ChatCompletionDeleted);
66}