use std::fmt::Debug;
use crate::{ingestion::IngestionNode, ingestion::IngestionStream, Embeddings};
use anyhow::Result;
use async_trait::async_trait;
#[cfg(test)]
use mockall::{automock, predicate::*};
#[cfg_attr(test, automock)]
#[async_trait]
pub trait Transformer: Send + Sync + Debug {
async fn transform_node(&self, node: IngestionNode) -> Result<IngestionNode>;
fn concurrency(&self) -> Option<usize> {
None
}
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait BatchableTransformer: Send + Sync + Debug {
fn batch_size(&self) -> Option<usize> {
None
}
async fn batch_transform(&self, nodes: Vec<IngestionNode>) -> IngestionStream;
fn concurrency(&self) -> Option<usize> {
None
}
}
#[cfg_attr(test, automock)]
pub trait Loader {
fn into_stream(self) -> IngestionStream;
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait ChunkerTransformer: Send + Sync + Debug {
async fn transform_node(&self, node: IngestionNode) -> IngestionStream;
fn concurrency(&self) -> Option<usize> {
None
}
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait NodeCache: Send + Sync + Debug {
async fn get(&self, node: &IngestionNode) -> bool;
async fn set(&self, node: &IngestionNode);
}
#[async_trait]
pub trait Embed: Debug + Send + Sync {
async fn embed(&self, input: Vec<String>) -> Result<Embeddings>;
}
#[async_trait]
pub trait SimplePrompt: Debug + Send + Sync {
async fn prompt(&self, prompt: &str) -> Result<String>;
}
#[cfg_attr(test, automock)]
#[async_trait]
pub trait Persist: Send + Sync {
async fn setup(&self) -> Result<()>;
async fn store(&self, node: IngestionNode) -> Result<IngestionNode>;
async fn batch_store(&self, nodes: Vec<IngestionNode>) -> IngestionStream;
fn batch_size(&self) -> Option<usize> {
None
}
}