pub mod cache;
pub mod chunking;
pub mod config;
pub mod embedding;
pub mod handlers;
pub mod models;
pub mod utils;
pub use cache::{cache_result, get_from_cache, initialize_db_pool};
pub use chunking::{ContentChunker, LLMConceptChunker, LLMConfig, LLMIntrospectionChunker, WordChunker};
pub use config::ServerConfig;
pub use embedding::{get_embedding_model, initialize_models, Embedder, FastEmbedder, SUPPORTED_MODELS};
pub use handlers::{embed_text, list_supported_features, process_url};
pub use models::{get_default_config, AppState, Config, InputData, InputDataText, ProcessedContent};
pub use utils::{fetch_content, generate_hash};
use std::collections::HashMap;
use std::sync::Arc;
pub fn initialize_chunkers(
llm_config: Option<&LLMConfig>,
) -> HashMap<String, Box<dyn ContentChunker + Send + Sync>> {
let mut chunkers: HashMap<String, Box<dyn ContentChunker + Send + Sync>> = HashMap::new();
let word_chunker = WordChunker;
chunkers.insert(word_chunker.name().to_string(), Box::new(word_chunker));
if let Some(config) = llm_config {
match chunking::llm::create_llm_client(config) {
Ok(client) => {
let client = Arc::from(client);
let concept_chunker = LLMConceptChunker::new(Arc::clone(&client));
chunkers.insert(concept_chunker.name().to_string(), Box::new(concept_chunker));
let introspection_chunker = LLMIntrospectionChunker::new(Arc::clone(&client));
chunkers.insert(
introspection_chunker.name().to_string(),
Box::new(introspection_chunker),
);
println!("LLM chunkers initialized successfully");
}
Err(e) => {
eprintln!("Failed to initialize LLM client: {e}. LLM chunkers disabled.");
}
}
} else {
println!("LLM not configured. Only word chunking available.");
}
chunkers
}