feat: init
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user