use super::types::KnowledgeDetailResponse;
use crate::{ZaiResult, client::http::HttpClient};
pub struct KnowledgeRetrieveRequest {
pub key: String,
url: String,
_body: (),
}
impl KnowledgeRetrieveRequest {
pub fn new(key: String, id: impl AsRef<str>) -> Self {
let url = format!(
"https://open.bigmodel.cn/api/llm-application/open/knowledge/{}",
id.as_ref()
);
Self {
key,
url,
_body: (),
}
}
pub async fn send(&self) -> ZaiResult<KnowledgeDetailResponse> {
let resp = self.get().await?;
let parsed = resp.json::<KnowledgeDetailResponse>().await?;
Ok(parsed)
}
}
impl HttpClient for KnowledgeRetrieveRequest {
type Body = ();
type ApiUrl = String;
type ApiKey = String;
fn api_url(&self) -> &Self::ApiUrl {
&self.url
}
fn api_key(&self) -> &Self::ApiKey {
&self.key
}
fn body(&self) -> &Self::Body {
&self._body
}
}
pub type KnowledgeRetrieveResponse = KnowledgeDetailResponse;