62 lines
1.6 KiB
Rust
62 lines
1.6 KiB
Rust
//! Command-line interface definitions.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use clap::{Args, Parser, Subcommand};
|
|
|
|
/// Main CLI configuration.
|
|
#[derive(Parser)]
|
|
#[command(version, about, long_about = None)]
|
|
#[command(propagate_version = true)]
|
|
pub struct Cli {
|
|
/// Where to read the database connection string from ('-' is stdin).
|
|
#[arg(short, long, default_value = "-")]
|
|
pub db_url: String,
|
|
|
|
/// Path to content tokenizer.
|
|
#[arg(short, long, default_value = "./tokenizer.json")]
|
|
pub tokenizer_path: PathBuf,
|
|
|
|
/// Path to ONNX model used for embeddings..
|
|
#[arg(short, long, default_value = "./model.onnx")]
|
|
pub model_path: PathBuf,
|
|
|
|
/// Maximum text chunk size when splitting up content. Documents are not updated if chunk size
|
|
/// changes.
|
|
#[arg(short, long, default_value = "500")]
|
|
pub chunk_size: usize,
|
|
|
|
#[command(subcommand)]
|
|
pub command: Commands,
|
|
}
|
|
|
|
/// Configuration for the ask command.
|
|
#[derive(Args, Clone)]
|
|
pub struct AskConfig {
|
|
/// Query to run.
|
|
#[arg(short, long)]
|
|
pub query: String,
|
|
|
|
/// Maximum number of results.
|
|
#[arg(short, long, default_value = "5")]
|
|
pub limit: usize,
|
|
|
|
/// Path to reranking model.
|
|
#[arg(short, long, default_value = "./reranking.onnx")]
|
|
pub reranking_path: PathBuf,
|
|
}
|
|
|
|
/// Configuration for the scan command.
|
|
#[derive(Args, Clone)]
|
|
pub struct ScanConfig {
|
|
/// Root directory of calibre library.
|
|
#[arg(short, long)]
|
|
pub library_path: PathBuf,
|
|
}
|
|
|
|
/// Available CLI commands.
|
|
#[derive(Subcommand)]
|
|
pub enum Commands {
|
|
Ask(AskConfig),
|
|
Scan(ScanConfig),
|
|
}
|