opencrabs 0.3.66

The autonomous, self-improving AI agent. Single Rust binary. Every channel. Install with: cargo install opencrabs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! `provider/model` pair parsing, shared by every non-interactive switch
//! surface (#461 family: CLI set-model, direct-arg /models on channels and
//! the TUI). The FIRST slash splits, so model names that contain slashes
//! survive intact (`openrouter/tencent/hy3:free` → `openrouter` +
//! `tencent/hy3:free`).

pub fn parse_pair(pair: &str) -> Result<(String, String), String> {
    match pair.split_once('/') {
        Some((provider, model)) if !provider.trim().is_empty() && !model.trim().is_empty() => {
            Ok((provider.trim().to_string(), model.trim().to_string()))
        }
        _ => Err(format!(
            "'{pair}' is not a provider/model pair — expected e.g. \
             openrouter/tencent/hy3:free (the first slash splits)"
        )),
    }
}