feat: init

This commit is contained in:
zhenyi
2026-06-07 11:30:56 +08:00
commit 563381c1ca
361 changed files with 41327 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
use crate::config::AppConfig;
use crate::error::AppResult;
impl AppConfig {
pub fn qdrant_url(&self) -> AppResult<Option<String>> {
self.get_env::<String>("APP_QDRANT_URL")
}
pub fn qdrant_cluster_nodes(&self) -> AppResult<Vec<String>> {
match self.get_env::<String>("APP_QDRANT_CLUSTER_NODES")? {
Some(s) if !s.is_empty() => Ok(s
.split(',')
.map(|u| u.trim().to_string())
.filter(|u| !u.is_empty())
.collect()),
_ => Ok(Vec::new()),
}
}
pub fn qdrant_api_key(&self) -> AppResult<Option<String>> {
self.get_env::<String>("APP_QDRANT_API_KEY")
}
pub fn qdrant_collection(&self) -> AppResult<Option<String>> {
self.get_env::<String>("APP_QDRANT_COLLECTION")
}
pub fn qdrant_vector_size(&self) -> AppResult<u32> {
self.get_env_or("APP_QDRANT_VECTOR_SIZE", 1536)
}
pub fn qdrant_distance(&self) -> AppResult<String> {
self.get_env_or("APP_QDRANT_DISTANCE", "Cosine".to_string())
}
pub fn qdrant_max_connections(&self) -> AppResult<u32> {
self.get_env_or("APP_QDRANT_MAX_CONNECTIONS", 10)
}
pub fn qdrant_idle_timeout(&self) -> AppResult<u64> {
self.get_env_or("APP_QDRANT_IDLE_TIMEOUT", 300)
}
pub fn qdrant_connection_timeout(&self) -> AppResult<u64> {
self.get_env_or("APP_QDRANT_CONNECTION_TIMEOUT", 10)
}
pub fn qdrant_max_retries(&self) -> AppResult<u32> {
self.get_env_or("APP_QDRANT_MAX_RETRIES", 3)
}
pub fn qdrant_tls_enabled(&self) -> AppResult<bool> {
self.get_env_or("APP_QDRANT_TLS_ENABLED", true)
}
pub fn qdrant_search_limit(&self) -> AppResult<u32> {
self.get_env_or("APP_QDRANT_SEARCH_LIMIT", 10)
}
pub fn qdrant_score_threshold(&self) -> AppResult<f64> {
self.get_env_or("APP_QDRANT_SCORE_THRESHOLD", 0.7)
}
}