objectiveai_api/ensemble_llm/fetcher/
objectiveai.rs1use crate::ctx;
4use objectiveai::error::StatusError;
5use std::sync::Arc;
6
7pub struct ObjectiveAiFetcher {
9 pub client: Arc<objectiveai::HttpClient>,
11}
12
13impl ObjectiveAiFetcher {
14 pub fn new(client: Arc<objectiveai::HttpClient>) -> Self {
16 Self { client }
17 }
18}
19
20#[async_trait::async_trait]
21impl<CTXEXT> super::Fetcher<CTXEXT> for ObjectiveAiFetcher
22where
23 CTXEXT: Send + Sync + 'static,
24{
25 async fn fetch(
26 &self,
27 _ctx: ctx::Context<CTXEXT>,
28 id: &str,
29 ) -> Result<
30 Option<(objectiveai::ensemble_llm::EnsembleLlm, u64)>,
31 objectiveai::error::ResponseError,
32 > {
33 match objectiveai::ensemble_llm::get_ensemble_llm(&self.client, id)
34 .await
35 {
36 Ok(ensemble_llm) => Ok(Some((ensemble_llm.inner, ensemble_llm.created))),
37 Err(e) if e.status() == 404 => Ok(None),
38 Err(e) => Err(objectiveai::error::ResponseError::from(&e)),
39 }
40 }
41}