feat(kb): add with_bot_config to load embedding from bot config
All checks were successful
BotServer CI / build (push) Successful in 3m50s
All checks were successful
BotServer CI / build (push) Successful in 3m50s
- Adds KnowledgeBaseManager::with_default_config() as alias to new() - Adds KnowledgeBaseManager::with_bot_config() to load embedding_url, embedding_model, and qdrant config from bot's config.csv - Updates bootstrap to use with_bot_config with default_bot_id - Enables per-bot embedding configuration instead of global env vars
This commit is contained in:
parent
9641842e8d
commit
1132983064
2 changed files with 28 additions and 1 deletions
|
|
@ -20,6 +20,8 @@ use std::sync::Arc;
|
|||
use tokio::sync::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::core::shared::utils::DbPool;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct KnowledgeBaseManager {
|
||||
indexer: Arc<KbIndexer>,
|
||||
|
|
@ -29,6 +31,10 @@ pub struct KnowledgeBaseManager {
|
|||
|
||||
impl KnowledgeBaseManager {
|
||||
pub fn new(work_root: impl Into<std::path::PathBuf>) -> Self {
|
||||
Self::with_default_config(work_root)
|
||||
}
|
||||
|
||||
pub fn with_default_config(work_root: impl Into<std::path::PathBuf>) -> Self {
|
||||
let work_root = work_root.into();
|
||||
let embedding_config = EmbeddingConfig::from_env();
|
||||
let qdrant_config = QdrantConfig::default();
|
||||
|
|
@ -47,6 +53,27 @@ impl KnowledgeBaseManager {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_bot_config(work_root: impl Into<std::path::PathBuf>, pool: DbPool, bot_id: Uuid) -> Self {
|
||||
let work_root = work_root.into();
|
||||
let embedding_config = EmbeddingConfig::from_bot_config(&pool, &bot_id);
|
||||
info!("KB Manager using embedding config from bot {}: url={}, model={}",
|
||||
bot_id, embedding_config.embedding_url, embedding_config.embedding_model);
|
||||
let qdrant_config = QdrantConfig::from_config(pool, &bot_id);
|
||||
|
||||
let indexer = Arc::new(KbIndexer::new(embedding_config.clone(), qdrant_config));
|
||||
let processor = Arc::new(DocumentProcessor::default());
|
||||
let monitor = Arc::new(RwLock::new(KbFolderMonitor::new(
|
||||
work_root,
|
||||
embedding_config,
|
||||
)));
|
||||
|
||||
Self {
|
||||
indexer,
|
||||
processor,
|
||||
monitor,
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn index_kb_folder(
|
||||
&self,
|
||||
bot_id: Uuid,
|
||||
|
|
|
|||
|
|
@ -509,7 +509,7 @@ pub async fn create_app_state(
|
|||
);
|
||||
|
||||
#[cfg(any(feature = "research", feature = "llm"))]
|
||||
let kb_manager = Arc::new(crate::core::kb::KnowledgeBaseManager::new("work"));
|
||||
let kb_manager = Arc::new(crate::core::kb::KnowledgeBaseManager::with_bot_config("work", pool.clone(), default_bot_id));
|
||||
|
||||
#[cfg(feature = "tasks")]
|
||||
let task_engine = Arc::new(crate::tasks::TaskEngine::new(pool.clone()));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue