zai_rs/knowledge/
retrieve.rs1use super::types::KnowledgeDetailResponse;
2use crate::client::http::HttpClient;
3
4pub struct KnowledgeRetrieveRequest {
6 pub key: String,
8 url: String,
9 _body: (),
10}
11
12impl KnowledgeRetrieveRequest {
13 pub fn new(key: String, id: impl AsRef<str>) -> Self {
15 let url = format!(
16 "https://open.bigmodel.cn/api/llm-application/open/knowledge/{}",
17 id.as_ref()
18 );
19 Self {
20 key,
21 url,
22 _body: (),
23 }
24 }
25
26 pub async fn send(&self) -> anyhow::Result<KnowledgeDetailResponse> {
28 let resp = self.get().await?;
29 let parsed = resp.json::<KnowledgeDetailResponse>().await?;
30 Ok(parsed)
31 }
32}
33
34impl HttpClient for KnowledgeRetrieveRequest {
35 type Body = ();
36 type ApiUrl = String;
37 type ApiKey = String;
38
39 fn api_url(&self) -> &Self::ApiUrl {
40 &self.url
41 }
42 fn api_key(&self) -> &Self::ApiKey {
43 &self.key
44 }
45 fn body(&self) -> &Self::Body {
46 &self._body
47 }
48}
49
50pub type KnowledgeRetrieveResponse = KnowledgeDetailResponse;