Skip to main content

zai_rs/knowledge/
retrieve.rs

1use super::types::KnowledgeDetailResponse;
2use crate::client::ZaiClient;
3
4/// Knowledge detail request (GET /llm-application/open/knowledge/{id})
5///
6/// Credentials and transport live on the [`ZaiClient`], passed to
7/// [`send_via`](Self::send_via).
8pub struct KnowledgeRetrieveRequest {
9    id: String,
10}
11
12impl KnowledgeRetrieveRequest {
13    /// Build a retrieve request with id.
14    pub fn new(id: impl Into<String>) -> Self {
15        Self { id: id.into() }
16    }
17
18    /// Send via a [`ZaiClient`] and parse the typed response.
19    pub async fn send_via(&self, client: &ZaiClient) -> crate::ZaiResult<KnowledgeDetailResponse> {
20        let route = crate::client::routes::KNOWLEDGE_GET;
21        let url = client.endpoints().resolve_route(route, &[&self.id])?;
22        client
23            .send_empty::<KnowledgeDetailResponse>(route.method(), url)
24            .await
25    }
26}
27
28/// Alias for symmetry with other modules
29pub type KnowledgeRetrieveResponse = KnowledgeDetailResponse;