First batch of smart stuff
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#[cfg(feature = "smart-features")]
|
||||
use notes_infra::factory::{EmbeddingProvider, VectorProvider};
|
||||
use std::env;
|
||||
|
||||
/// Server configuration
|
||||
@@ -9,6 +11,11 @@ pub struct Config {
|
||||
pub session_secret: String,
|
||||
pub cors_allowed_origins: Vec<String>,
|
||||
pub allow_registration: bool,
|
||||
#[cfg(feature = "smart-features")]
|
||||
pub embedding_provider: EmbeddingProvider,
|
||||
#[cfg(feature = "smart-features")]
|
||||
pub vector_provider: VectorProvider,
|
||||
pub broker_url: String,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
@@ -21,6 +28,14 @@ impl Default for Config {
|
||||
.to_string(),
|
||||
cors_allowed_origins: vec!["http://localhost:5173".to_string()],
|
||||
allow_registration: true,
|
||||
#[cfg(feature = "smart-features")]
|
||||
embedding_provider: EmbeddingProvider::FastEmbed,
|
||||
#[cfg(feature = "smart-features")]
|
||||
vector_provider: VectorProvider::Qdrant {
|
||||
url: "http://localhost:6334".to_string(),
|
||||
collection: "notes".to_string(),
|
||||
},
|
||||
broker_url: "nats://localhost:4222".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,6 +71,24 @@ impl Config {
|
||||
.map(|s| s.to_lowercase() == "true")
|
||||
.unwrap_or(true);
|
||||
|
||||
#[cfg(feature = "smart-features")]
|
||||
let embedding_provider = match env::var("EMBEDDING_PROVIDER").unwrap_or_default().as_str() {
|
||||
// Future: "ollama" => EmbeddingProvider::Ollama(...),
|
||||
_ => EmbeddingProvider::FastEmbed,
|
||||
};
|
||||
|
||||
#[cfg(feature = "smart-features")]
|
||||
let vector_provider = match env::var("VECTOR_PROVIDER").unwrap_or_default().as_str() {
|
||||
// Future: "postgres" => ...
|
||||
_ => VectorProvider::Qdrant {
|
||||
url: env::var("QDRANT_URL").unwrap_or_else(|_| "http://localhost:6334".to_string()),
|
||||
collection: env::var("QDRANT_COLLECTION").unwrap_or_else(|_| "notes".to_string()),
|
||||
},
|
||||
};
|
||||
|
||||
let broker_url =
|
||||
env::var("BROKER_URL").unwrap_or_else(|_| "nats://localhost:4222".to_string());
|
||||
|
||||
Self {
|
||||
host,
|
||||
port,
|
||||
@@ -63,6 +96,11 @@ impl Config {
|
||||
session_secret,
|
||||
cors_allowed_origins,
|
||||
allow_registration,
|
||||
#[cfg(feature = "smart-features")]
|
||||
embedding_provider,
|
||||
#[cfg(feature = "smart-features")]
|
||||
vector_provider,
|
||||
broker_url,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user