openai_interface/chat/
retrieve.rs1pub mod request {
7 use std::collections::HashMap;
8
9 use url::Url;
10
11 use crate::{
12 errors::OapiError,
13 rest::get::{Get, GetNoStream},
14 };
15
16 pub struct ChatRetrieveRequest {
21 pub completion_id: String,
22 pub extra_query: HashMap<String, String>,
23 }
24
25 impl Get for ChatRetrieveRequest {
26 fn build_url(&self, base_url: &str) -> Result<String, crate::errors::OapiError> {
28 let mut url =
29 Url::parse(base_url.trim_end_matches('/')).map_err(|e| OapiError::UrlError(e))?;
30 url.path_segments_mut()
31 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
32 .push("chat")
33 .push(&self.completion_id);
34
35 Ok(url.to_string())
36 }
37 }
38
39 impl GetNoStream for ChatRetrieveRequest {
40 type Response = crate::chat::ChatCompletion;
41 }
42}