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(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
36 for (key, value) in &self.extra_query {
37 url.query_pairs_mut().append_pair(key, value);
38 }
39
40 Ok(url.to_string())
41 }
42 }
43
44 impl GetNoStream for ChatRetrieveRequest {
45 type Response = crate::chat::ChatCompletion;
46 }
47}