Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

815 B
Raw Blame
use async_trait::async_trait;
use flowy_error::FlowyResult;
pub use langchain_rust::schemas::Document as LangchainDocument;
use std::error::Error;
use uuid::Uuid;

pub mod multi_source_retriever;
pub mod sqlite_retriever;

#[async_trait]
pub trait AFRetriever: Send + Sync + 'static {
  fn get_rag_ids(&self) -> Vec<&str>;
  fn set_rag_ids(&mut self, new_rag_ids: Vec<String>);

  async fn retrieve_documents(&self, query: &str)
  -> Result<Vec<LangchainDocument>, Box<dyn Error>>;
}

#[async_trait]
pub trait MultipleSourceRetrieverStore: Send + Sync {
  fn retriever_name(&self) -> &'static str;
  async fn read_documents(
    &self,
    workspace_id: &Uuid,
    query: &str,
    limit: usize,
    rag_ids: &[String],
    score_threshold: f32,
    full_search: bool,
  ) -> FlowyResult<Vec<LangchainDocument>>;
}