fix: KB processor works with and without llm/research features
All checks were successful
BotServer CI/CD / build (push) Successful in 3m55s
All checks were successful
BotServer CI/CD / build (push) Successful in 3m55s
- Added stub start_kb_processor() for non-llm builds - Added _pending_kb_index field for non-llm builds - Extracted KB processor logic into start_kb_processor_inner() - Removed unused is_embedding_server_ready import This ensures DriveMonitor compiles and runs correctly in production where CI builds without --features llm. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
112ac51da3
commit
8e539206d4
1 changed files with 32 additions and 10 deletions
|
|
@ -1,8 +1,6 @@
|
||||||
use crate::basic::compiler::BasicCompiler;
|
use crate::basic::compiler::BasicCompiler;
|
||||||
use crate::core::config::ConfigManager;
|
use crate::core::config::ConfigManager;
|
||||||
#[cfg(any(feature = "research", feature = "llm"))]
|
#[cfg(any(feature = "research", feature = "llm"))]
|
||||||
use crate::core::kb::embedding_generator::is_embedding_server_ready;
|
|
||||||
#[cfg(any(feature = "research", feature = "llm"))]
|
|
||||||
use crate::core::kb::KnowledgeBaseManager;
|
use crate::core::kb::KnowledgeBaseManager;
|
||||||
use crate::core::shared::memory_monitor::{log_jemalloc_stats, MemoryStats};
|
use crate::core::shared::memory_monitor::{log_jemalloc_stats, MemoryStats};
|
||||||
use crate::core::shared::message_types::MessageType;
|
use crate::core::shared::message_types::MessageType;
|
||||||
|
|
@ -56,6 +54,8 @@ pub struct DriveMonitor {
|
||||||
files_being_indexed: Arc<TokioRwLock<HashSet<String>>>,
|
files_being_indexed: Arc<TokioRwLock<HashSet<String>>>,
|
||||||
#[cfg(any(feature = "research", feature = "llm"))]
|
#[cfg(any(feature = "research", feature = "llm"))]
|
||||||
pending_kb_index: Arc<TokioRwLock<HashSet<String>>>,
|
pending_kb_index: Arc<TokioRwLock<HashSet<String>>>,
|
||||||
|
#[cfg(not(any(feature = "research", feature = "llm")))]
|
||||||
|
_pending_kb_index: Arc<TokioRwLock<HashSet<String>>>,
|
||||||
}
|
}
|
||||||
impl DriveMonitor {
|
impl DriveMonitor {
|
||||||
fn normalize_config_value(value: &str) -> String {
|
fn normalize_config_value(value: &str) -> String {
|
||||||
|
|
@ -86,6 +86,8 @@ impl DriveMonitor {
|
||||||
files_being_indexed: Arc::new(TokioRwLock::new(HashSet::new())),
|
files_being_indexed: Arc::new(TokioRwLock::new(HashSet::new())),
|
||||||
#[cfg(any(feature = "research", feature = "llm"))]
|
#[cfg(any(feature = "research", feature = "llm"))]
|
||||||
pending_kb_index: Arc::new(TokioRwLock::new(HashSet::new())),
|
pending_kb_index: Arc::new(TokioRwLock::new(HashSet::new())),
|
||||||
|
#[cfg(not(any(feature = "research", feature = "llm")))]
|
||||||
|
_pending_kb_index: Arc::new(TokioRwLock::new(HashSet::new())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,15 +225,29 @@ impl DriveMonitor {
|
||||||
/// Only one instance runs per bot - this is spawned once from start_monitoring
|
/// Only one instance runs per bot - this is spawned once from start_monitoring
|
||||||
#[cfg(any(feature = "research", feature = "llm"))]
|
#[cfg(any(feature = "research", feature = "llm"))]
|
||||||
pub fn start_kb_processor(&self) {
|
pub fn start_kb_processor(&self) {
|
||||||
let kb_manager = Arc::clone(&self.kb_manager);
|
Self::start_kb_processor_inner(
|
||||||
let bot_id = self.bot_id;
|
Arc::clone(&self.kb_manager),
|
||||||
let bot_name = self.bucket_name.strip_suffix(".gbai").unwrap_or(&self.bucket_name).to_string();
|
self.bot_id,
|
||||||
let work_root = self.work_root.clone();
|
self.bucket_name.strip_suffix(".gbai").unwrap_or(&self.bucket_name).to_string(),
|
||||||
let pending_kb_index = Arc::clone(&self.pending_kb_index);
|
self.work_root.clone(),
|
||||||
let files_being_indexed = Arc::clone(&self.files_being_indexed);
|
Arc::clone(&self.pending_kb_index),
|
||||||
let file_states = Arc::clone(&self.file_states);
|
Arc::clone(&self.files_being_indexed),
|
||||||
let is_processing = Arc::clone(&self.is_processing);
|
Arc::clone(&self.file_states),
|
||||||
|
Arc::clone(&self.is_processing),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "research", feature = "llm"))]
|
||||||
|
fn start_kb_processor_inner(
|
||||||
|
kb_manager: Arc<KnowledgeBaseManager>,
|
||||||
|
bot_id: uuid::Uuid,
|
||||||
|
bot_name: String,
|
||||||
|
work_root: PathBuf,
|
||||||
|
pending_kb_index: Arc<TokioRwLock<HashSet<String>>>,
|
||||||
|
files_being_indexed: Arc<TokioRwLock<HashSet<String>>>,
|
||||||
|
file_states: Arc<tokio::sync::RwLock<HashMap<String, FileState>>>,
|
||||||
|
is_processing: Arc<AtomicBool>,
|
||||||
|
) {
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
trace!("[KB_PROCESSOR] Starting for bot {} (bucket: {})", bot_name, bot_id);
|
trace!("[KB_PROCESSOR] Starting for bot {} (bucket: {})", bot_name, bot_id);
|
||||||
|
|
||||||
|
|
@ -338,6 +354,12 @@ impl DriveMonitor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Stub for production builds without llm/research features
|
||||||
|
#[cfg(not(any(feature = "research", feature = "llm")))]
|
||||||
|
pub fn start_kb_processor(&self) {
|
||||||
|
// KB indexing not available in this build
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn start_monitoring(&self) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
pub async fn start_monitoring(&self) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
trace!("start_monitoring ENTER");
|
trace!("start_monitoring ENTER");
|
||||||
let start_mem = MemoryStats::current();
|
let start_mem = MemoryStats::current();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue