use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value};
#[derive(Debug, Clone, Deserialize, JsonSchema)]
#[schemars(transform = crate::schema::strip_int_formats)]
pub struct Link {
pub target: u64,
pub relation: String,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
#[schemars(transform = crate::schema::strip_int_formats)]
pub struct Recollection {
pub id: u64,
pub score: f32,
pub content: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub metadata: Option<Map<String, Value>>,
}
#[derive(Debug, Clone, Copy, Deserialize, JsonSchema)]
#[serde(rename_all = "lowercase")]
pub enum ColumnOp {
Eq,
Ne,
Lt,
Le,
Gt,
Ge,
}
impl ColumnOp {
#[cfg(feature = "persistence")]
#[must_use]
pub(crate) fn as_sql(self) -> &'static str {
match self {
Self::Eq => "=",
Self::Ne => "!=",
Self::Lt => "<",
Self::Le => "<=",
Self::Gt => ">",
Self::Ge => ">=",
}
}
}
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct ColumnFilter {
pub field: String,
pub op: ColumnOp,
pub value: Value,
}
#[derive(Debug, Clone, Copy)]
pub struct FusionOptions {
pub hops: usize,
pub graph_boost: f64,
pub pool: Option<usize>,
}
impl Default for FusionOptions {
fn default() -> Self {
Self {
hops: 2,
graph_boost: 0.15,
pool: None,
}
}
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
#[schemars(transform = crate::schema::strip_int_formats)]
pub struct MemoryNode {
pub id: u64,
pub content: String,
pub hop: usize,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
#[schemars(transform = crate::schema::strip_int_formats)]
pub struct MemoryEdge {
pub from: u64,
pub to: u64,
pub relation: String,
}
#[derive(Debug, Clone, Default, Serialize, JsonSchema)]
pub struct Explanation {
pub nodes: Vec<MemoryNode>,
pub edges: Vec<MemoryEdge>,
}