openai_interface/vector_stores/files/
content.rs1use url::Url;
11
12use crate::{
13 errors::OapiError,
14 rest::get::{Get, GetNoStream},
15};
16
17#[derive(Debug, Clone)]
19pub struct RetrieveVectorStoreFileContentRequest<'a> {
20 pub vector_store_id: &'a str,
22 pub file_id: &'a str,
24 pub extra_query: Option<std::collections::HashMap<String, String>>,
26}
27
28impl Get for RetrieveVectorStoreFileContentRequest<'_> {
29 fn build_url(&self, base_url: &str) -> Result<String, OapiError> {
33 let mut url = Url::parse(base_url.trim_end_matches('/')).map_err(OapiError::UrlError)?;
34 url.path_segments_mut()
35 .map_err(|_| OapiError::UrlCannotBeBase(base_url.to_string()))?
36 .push("vector_stores")
37 .push(self.vector_store_id)
38 .push("files")
39 .push(self.file_id)
40 .push("content");
41
42 if let Some(extra_query) = &self.extra_query {
43 let mut pairs = url.query_pairs_mut();
44 for (key, value) in extra_query {
45 pairs.append_pair(key, value);
46 }
47 }
48
49 Ok(url.to_string())
50 }
51}
52
53impl GetNoStream for RetrieveVectorStoreFileContentRequest<'_> {
54 type Response = VectorStoreFileContentResponse;
55}
56
57#[derive(Debug, Clone, serde::Deserialize)]
59pub struct VectorStoreFileContentChunk {
60 #[serde(default)]
62 pub id: Option<String>,
63 #[serde(default)]
65 pub object: Option<String>,
66 #[serde(default)]
68 pub text: Option<String>,
69 #[serde(default)]
71 pub tokens: Option<u64>,
72 #[serde(default)]
74 pub attributes: Option<serde_json::Value>,
75}
76
77#[derive(Debug, Clone, serde::Deserialize)]
79pub struct VectorStoreFileContentResponse {
80 #[serde(default)]
82 pub data: Vec<VectorStoreFileContentChunk>,
83 #[serde(default)]
85 pub has_more: Option<bool>,
86}
87
88crate::impl_from_str!(VectorStoreFileContentResponse);