Skip to content

Commit 34cdf6a

Browse files
author
Benedikt Koehler
committed
Make /model list available providers
1 parent f026ddc commit 34cdf6a

2 files changed

Lines changed: 67 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
jobs:
9+
build:
10+
strategy:
11+
matrix:
12+
include:
13+
- os: ubuntu-latest
14+
target: x86_64-unknown-linux-gnu
15+
bin: nanocode
16+
- os: windows-latest
17+
target: x86_64-pc-windows-msvc
18+
bin: nanocode.exe
19+
- os: macos-14
20+
target: aarch64-apple-darwin
21+
bin: nanocode
22+
runs-on: ${{ matrix.os }}
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: dtolnay/rust-toolchain@stable
26+
with:
27+
targets: ${{ matrix.target }}
28+
- run: cargo build --release --target ${{ matrix.target }}
29+
- run: |
30+
mkdir -p dist
31+
cp target/${{ matrix.target }}/release/${{ matrix.bin }} dist/
32+
- uses: actions/upload-artifact@v4
33+
with:
34+
name: ${{ matrix.target }}
35+
path: dist/*
36+
release:
37+
needs: build
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/download-artifact@v4
41+
with:
42+
path: dist
43+
- uses: softprops/action-gh-release@v2
44+
with:
45+
files: dist/**/*

src/main.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn main() {
6969
print_header(&model_label, chatbot_label.as_deref());
7070
println!();
7171
}
72-
None => print_error("LLM error: /model requires both OPENROUTER_API_KEY and HYBRIDAI_API_KEY"),
72+
None => print_error("LLM error: No providers available"),
7373
}
7474
continue;
7575
}
@@ -431,15 +431,28 @@ fn build_orbit_frame(step: usize) -> String {
431431
}
432432

433433
fn select_provider(current: &Provider) -> Option<ProviderConfig> {
434-
let open = load_openrouter()?;
435-
let hybrid = load_hybrid()?;
436-
let options = vec![
437-
format!("OpenRouter: {}", open.model),
438-
format!("HybridAI: {}", hybrid.model),
439-
];
440-
let initial = if matches!(current, Provider::OpenRouter) { 0 } else { 1 };
434+
let mut options = Vec::new();
435+
let mut configs = Vec::new();
436+
if let Some(open) = load_openrouter() {
437+
options.push(format!("OpenRouter: {}", open.model));
438+
configs.push(open);
439+
}
440+
if let Some(hybrid) = load_hybrid() {
441+
options.push(format!("HybridAI: {}", hybrid.model));
442+
configs.push(hybrid);
443+
}
444+
if options.is_empty() { return None; }
445+
if options.len() == 1 {
446+
let next = configs.into_iter().next();
447+
if let Some(ref cfg) = next { let _ = persist_model_config(cfg); }
448+
return next;
449+
}
450+
let initial = match current {
451+
Provider::OpenRouter => options.iter().position(|o| o.starts_with("OpenRouter")).unwrap_or(0),
452+
Provider::HybridAI => options.iter().position(|o| o.starts_with("HybridAI")).unwrap_or(0),
453+
};
441454
let selected = select_menu("Select provider", &options, Some(initial))?;
442-
let next = match selected { 0 => Some(open), 1 => Some(hybrid), _ => None };
455+
let next = configs.into_iter().nth(selected);
443456
if let Some(ref cfg) = next { let _ = persist_model_config(cfg); }
444457
next
445458
}

0 commit comments

Comments
 (0)