Skip to main content

rusty_genius_cortex/
lib.rs

1use anyhow::Result;
2use async_trait::async_trait;
3use futures::channel::mpsc;
4use rusty_genius_core::protocol::InferenceEvent;
5
6pub mod backend;
7
8#[async_trait]
9pub trait Engine: Send + Sync {
10    /// Load a model from a path
11    async fn load_model(&mut self, model_path: &str) -> Result<()>;
12
13    /// Unload the currently loaded model to free resources
14    async fn unload_model(&mut self) -> Result<()>;
15
16    /// Run inference
17    /// Returns a channel of InferenceEvents
18    async fn infer(
19        &mut self,
20        prompt: &str,
21        // config: InferenceConfig, // We might need to import this
22    ) -> Result<mpsc::Receiver<Result<InferenceEvent>>>;
23}
24
25pub async fn create_engine() -> Box<dyn Engine> {
26    #[cfg(feature = "real-engine")]
27    {
28        Box::new(backend::Brain::new())
29    }
30
31    #[cfg(not(feature = "real-engine"))]
32    {
33        Box::new(backend::Pinky::new())
34    }
35}