dspy_rs/predictors/
mod.rs

1pub mod predict;
2
3pub use predict::*;
4
5use crate::{Example, LM, LmUsage, Prediction};
6use std::sync::Arc;
7use tokio::sync::Mutex;
8
9#[allow(async_fn_in_trait)]
10pub trait Predictor: Send + Sync {
11    async fn forward(&self, inputs: Example) -> anyhow::Result<Prediction>;
12    async fn forward_with_config(
13        &self,
14        inputs: Example,
15        lm: Arc<Mutex<LM>>,
16    ) -> anyhow::Result<Prediction>;
17}
18
19pub struct DummyPredict;
20
21impl Predictor for DummyPredict {
22    async fn forward(&self, inputs: Example) -> anyhow::Result<Prediction> {
23        Ok(Prediction::new(inputs.data, LmUsage::default()))
24    }
25
26    #[allow(unused_variables)]
27    async fn forward_with_config(
28        &self,
29        inputs: Example,
30        lm: Arc<Mutex<LM>>,
31    ) -> anyhow::Result<Prediction> {
32        Ok(Prediction::new(inputs.data, LmUsage::default()))
33    }
34}