Skip to main content

zai_rs/knowledge/
capacity.rs

1use super::types::KnowledgeCapacityResponse;
2use crate::client::http::HttpClient;
3
4/// Knowledge capacity request (GET /llm-application/open/knowledge/capacity)
5pub struct KnowledgeCapacityRequest {
6    /// Bearer API key
7    pub key: String,
8    url: String,
9    _body: (),
10}
11
12impl KnowledgeCapacityRequest {
13    /// Build a capacity request
14    pub fn new(key: String) -> Self {
15        let url =
16            "https://open.bigmodel.cn/api/llm-application/open/knowledge/capacity".to_string();
17        Self {
18            key,
19            url,
20            _body: (),
21        }
22    }
23
24    /// Send and parse typed response
25    pub async fn send(&self) -> crate::ZaiResult<KnowledgeCapacityResponse> {
26        let resp = self.get().await?;
27
28        let parsed = resp.json::<KnowledgeCapacityResponse>().await?;
29
30        Ok(parsed)
31    }
32}
33
34impl HttpClient for KnowledgeCapacityRequest {
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}