tofu-llm 0.7.2

A command-line tool for interacting with LLMs
Documentation
use clap::Parser;
use std::error::Error;
use tofu::Config;

#[derive(Parser, Debug)]
#[command(version, about = "The Tofu LLM client")]
struct Args {
    /// Enable verbose output
    #[arg(short, long)]
    verbose: bool,

    /// Optional message string
    message: Option<String>,

    /// Modify the config file
    #[arg(short, long, alias = "configure", alias = "settings")]
    config: bool,

    /// Modify your API keys file
    #[arg(short, long, alias = "api-keys")]
    keys: bool,

    /// Choose a config profile
    #[arg(short, long)]
    profile: Option<String>,
}

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
    let args = Args::parse();

    if args.config {
        tofu::open_config()?;
        return Ok(());
    }

    if args.keys {
        tofu::open_keys()?;
        return Ok(());
    }

    // Get the selected profile from CLI argument
    let selected_profile = args.profile;
    let message = args.message;

    // Load the configuration file (multi-profile aware)
    let config_file = tofu::load_config(selected_profile.as_deref())?;

    let config = Config {
        verbose: args.verbose,
        interactive: message.is_none(),
        message,
        stream: config_file.stream,
        file: Some(config_file),
    };

    tofu::run(config).await
}