use crate::core::{FactId, ScopeFilter, StoredFact};
use crate::error::Result;
use async_trait::async_trait;
#[derive(Debug, Clone)]
pub struct Entity {
pub name: String,
pub entity_type: String,
}
#[async_trait]
pub trait GraphBackend: Send + Sync {
async fn extract_entities(&self, text: &str) -> Result<Vec<Entity>>;
async fn build_relationships(&self, entities: &[Entity], fact_id: &FactId) -> Result<()>;
async fn get_related_facts(
&self,
fact_id: &FactId,
max_depth: usize,
filter: Option<&ScopeFilter>,
) -> Result<Vec<StoredFact>>;
async fn delete_fact_graph(&self, fact_id: &FactId) -> Result<()>;
}
#[derive(Debug, Clone)]
pub struct NoOpGraphBackend;
impl NoOpGraphBackend {
pub fn new() -> Self {
Self
}
}
impl Default for NoOpGraphBackend {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl GraphBackend for NoOpGraphBackend {
async fn extract_entities(&self, _text: &str) -> Result<Vec<Entity>> {
Ok(Vec::new())
}
async fn build_relationships(&self, _entities: &[Entity], _fact_id: &FactId) -> Result<()> {
Ok(())
}
async fn get_related_facts(
&self,
_fact_id: &FactId,
_max_depth: usize,
_filter: Option<&ScopeFilter>,
) -> Result<Vec<StoredFact>> {
Ok(Vec::new())
}
async fn delete_fact_graph(&self, _fact_id: &FactId) -> Result<()> {
Ok(())
}
}