pub const DEFAULT_GLOB: &str = "**/*.md";
pub const DEFAULT_MULTI_GET_MAX_BYTES: usize = 10 * 1024;
pub const CHUNK_SIZE_TOKENS: usize = 800;
pub const CHUNK_OVERLAP_TOKENS: usize = CHUNK_SIZE_TOKENS * 15 / 100;
pub const CHUNK_SIZE_CHARS: usize = CHUNK_SIZE_TOKENS * 4;
pub const CHUNK_OVERLAP_CHARS: usize = CHUNK_OVERLAP_TOKENS * 4;
pub const EXCLUDE_DIRS: &[&str] = &[
"node_modules",
".git",
".cache",
"vendor",
"dist",
"build",
"target",
];
#[must_use]
pub fn get_default_db_path(index_name: &str) -> Option<std::path::PathBuf> {
let cache_dir = dirs::cache_dir()?;
let qmd_cache = cache_dir.join("qmd");
std::fs::create_dir_all(&qmd_cache).ok()?;
Some(qmd_cache.join(format!("{index_name}.sqlite")))
}
#[must_use]
pub fn get_config_dir() -> Option<std::path::PathBuf> {
if let Ok(dir) = std::env::var("QMD_CONFIG_DIR") {
return Some(std::path::PathBuf::from(dir));
}
let config_dir = dirs::config_dir()?;
Some(config_dir.join("qmd"))
}
#[must_use]
pub fn get_config_path(index_name: &str) -> Option<std::path::PathBuf> {
let config_dir = get_config_dir()?;
Some(config_dir.join(format!("{index_name}.yml")))
}
#[must_use]
pub fn get_model_cache_dir() -> std::path::PathBuf {
let cache_dir = dirs::cache_dir().unwrap_or_else(|| std::path::PathBuf::from("."));
let model_dir = cache_dir.join("qmd").join("models");
let _ = std::fs::create_dir_all(&model_dir);
model_dir
}