plainllm 1.2.0

A plain & simple LLM client
Documentation
use plainllm::client::{self, LLMConfig, Mode};

#[allow(dead_code)]
pub struct Args {
    pub api_url: String,
    pub client: client::PlainLLM,
    pub model: String,
}

#[allow(dead_code)]
/// Shared arguments for all the examples
pub fn get_client_args() -> Args {
    // Default values used when no CLI arguments are provided
    let mut api_url = "http://127.0.0.1:1234".to_string();
    let mut model = "deepseek-r1-0528-qwen3-8b".to_string();
    let mut api_key = "whatever".to_string();

    // Very small argument parser supporting:
    //  --api-url=<url>
    //  --model=<model>
    //  --api-key=<model>
    let mut iter = std::env::args().skip(1);
    while let Some(arg) = iter.next() {
        if arg == "--api-url" {
            if let Some(val) = iter.next() {
                api_url = val;
            }
        } else if let Some(val) = arg.strip_prefix("--api-url=") {
            api_url = val.to_string();
        } else if arg == "--model" {
            if let Some(val) = iter.next() {
                model = val;
            }
        } else if let Some(val) = arg.strip_prefix("--model=") {
            model = val.to_string();
        } else if arg == "--api-key" {
            if let Some(val) = iter.next() {
                api_key = val;
            }
        } else if let Some(val) = arg.strip_prefix("--api-key=") {
            api_key = val.to_string();
        }
    }

    let cfg = LLMConfig {
        mode: Mode::ChatCompletion,
    };

    let client = client::PlainLLM::new_with_config(&api_url, &api_key, cfg);

    Args {
        api_url,
        client,
        model,
    }
}

#[allow(dead_code)]
pub fn init_logger() {
    use tracing_subscriber::{fmt, prelude::*, EnvFilter};

    // Initialize with RUST_LOG env var or default to "info"
    let filter_layer =
        EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warning"));

    tracing_subscriber::registry()
        .with(filter_layer)
        .with(fmt::layer().with_target(true))
        .init();
}

#[allow(dead_code)]
fn main() {
    println!("Nothing here!")
}