chore: initialize cli autoresearch segment
This commit is contained in:
1 parent
4cda0eef8e
commit
9555a029b9
8 files changed
+280
-104
No files matched your search
@@ -0,0 +1,14 @@
|
||||
[package]
|
||||
name = "localllm-cli"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
authors.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "localllm"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
@@ -0,0 +1,160 @@
|
||||
use clap::{Args, Parser, Subcommand, ValueEnum};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
|
||||
enum OutputFormat {
|
||||
Text,
|
||||
Json,
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "localllm", about = "Manage the local LLM backend")]
|
||||
struct Cli {
|
||||
#[arg(long, global = true, default_value = "http://127.0.0.1:8080")]
|
||||
server: String,
|
||||
|
||||
#[arg(long, global = true)]
|
||||
api_key: Option<String>,
|
||||
|
||||
#[arg(long, global = true, value_enum, default_value_t = OutputFormat::Text)]
|
||||
format: OutputFormat,
|
||||
|
||||
#[command(subcommand)]
|
||||
command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum Commands {
|
||||
Status,
|
||||
Models(ModelsCommand),
|
||||
}
|
||||
|
||||
#[derive(Debug, Args)]
|
||||
struct ModelsCommand {
|
||||
#[command(subcommand)]
|
||||
command: ModelsSubcommand,
|
||||
}
|
||||
|
||||
#[derive(Debug, Subcommand)]
|
||||
enum ModelsSubcommand {
|
||||
List,
|
||||
}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
let cli = Cli::parse();
|
||||
println!("CLI scaffold ready for {:?} at {}", cli.command, cli.server);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::Cli;
|
||||
use clap::Parser;
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_status_command_supports_global_output_flags() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "--format", "json", "status"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_models_list_command_is_available() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "models", "list"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_models_scan_command_is_available() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "models", "scan"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_models_load_command_accepts_model_and_alias() {
|
||||
let parsed = Cli::try_parse_from([
|
||||
"localllm",
|
||||
"models",
|
||||
"load",
|
||||
"./models/qwen.gguf",
|
||||
"--alias",
|
||||
"qwen-coder",
|
||||
]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_models_watch_command_is_available() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "models", "watch"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_models_download_command_accepts_hf_repo() {
|
||||
let parsed = Cli::try_parse_from([
|
||||
"localllm",
|
||||
"models",
|
||||
"download",
|
||||
"Qwen/Qwen2.5-Coder-7B-Instruct-GGUF",
|
||||
]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_auth_enable_command_supports_mode_and_key() {
|
||||
let parsed = Cli::try_parse_from([
|
||||
"localllm",
|
||||
"auth",
|
||||
"enable",
|
||||
"--mode",
|
||||
"protected",
|
||||
"--api-key",
|
||||
"secret",
|
||||
]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_config_set_command_supports_key_value_updates() {
|
||||
let parsed =
|
||||
Cli::try_parse_from(["localllm", "config", "set", "default_model", "qwen-coder"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_bench_throughput_command_accepts_sample_controls() {
|
||||
let parsed = Cli::try_parse_from([
|
||||
"localllm",
|
||||
"bench",
|
||||
"throughput",
|
||||
"--samples",
|
||||
"5",
|
||||
"--prompt-tokens",
|
||||
"256",
|
||||
"--completion-tokens",
|
||||
"128",
|
||||
]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_logs_command_is_available() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "logs"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[ignore = "autoresearch benchmark"]
|
||||
fn cli_surface_doctor_command_is_available() {
|
||||
let parsed = Cli::try_parse_from(["localllm", "doctor"]);
|
||||
assert!(parsed.is_ok());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user