mirror of
https://gitea.ingwaz.work/Ingwaz/openbrain-mcp.git
synced 2026-06-16 06:17:08 +00:00
Add TTL expiry for transient facts
This commit is contained in:
@@ -12,6 +12,7 @@ pub struct Config {
|
||||
pub database: DatabaseConfig,
|
||||
pub embedding: EmbeddingConfig,
|
||||
pub query: QueryConfig,
|
||||
pub ttl: TtlConfig,
|
||||
pub auth: AuthConfig,
|
||||
}
|
||||
|
||||
@@ -55,6 +56,13 @@ pub struct QueryConfig {
|
||||
pub text_weight: f32,
|
||||
}
|
||||
|
||||
/// TTL / expiry configuration
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct TtlConfig {
|
||||
#[serde(default = "default_cleanup_interval_seconds")]
|
||||
pub cleanup_interval_seconds: u64,
|
||||
}
|
||||
|
||||
/// Authentication configuration
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct AuthConfig {
|
||||
@@ -98,6 +106,7 @@ fn default_model_path() -> String { "models/all-MiniLM-L6-v2".to_string() }
|
||||
fn default_embedding_dim() -> usize { 384 }
|
||||
fn default_vector_weight() -> f32 { 0.6 }
|
||||
fn default_text_weight() -> f32 { 0.4 }
|
||||
fn default_cleanup_interval_seconds() -> u64 { 300 }
|
||||
fn default_auth_enabled() -> bool { false }
|
||||
|
||||
impl Config {
|
||||
@@ -119,6 +128,11 @@ impl Config {
|
||||
// Query settings
|
||||
.set_default("query.vector_weight", default_vector_weight() as f64)?
|
||||
.set_default("query.text_weight", default_text_weight() as f64)?
|
||||
// TTL settings
|
||||
.set_default(
|
||||
"ttl.cleanup_interval_seconds",
|
||||
default_cleanup_interval_seconds() as i64,
|
||||
)?
|
||||
// Auth settings
|
||||
.set_default("auth.enabled", default_auth_enabled())?
|
||||
// Load from environment with OPENBRAIN_ prefix
|
||||
@@ -170,6 +184,9 @@ impl Default for Config {
|
||||
vector_weight: default_vector_weight(),
|
||||
text_weight: default_text_weight(),
|
||||
},
|
||||
ttl: TtlConfig {
|
||||
cleanup_interval_seconds: default_cleanup_interval_seconds(),
|
||||
},
|
||||
auth: AuthConfig {
|
||||
enabled: default_auth_enabled(),
|
||||
api_keys: Vec::new(),
|
||||
|
||||
Reference in New Issue
Block a user