Codex model list: show all models, surface fetch failures, hx models
This commit is contained in:
1 parent
aa72ab664d
commit
48a808d526
5 files changed
+117
-23
No files matched your search
@@ -61,6 +61,12 @@ enum Cmd {
|
||||
Stats { session: std::path::PathBuf },
|
||||
/// Token size of the fixed request prefix (system prompt parts, tool schemas, MCP index).
|
||||
Prefix,
|
||||
/// Model list per logged-in provider: source (live/cache/fallback), errors, ids.
|
||||
Models {
|
||||
/// Skip the cache and fetch again.
|
||||
#[arg(long)]
|
||||
refresh: bool,
|
||||
},
|
||||
/// Connect to configured MCP servers and print tools + index/eager token cost.
|
||||
Mcp,
|
||||
/// Serve lens diagnostics + LSP navigation as an MCP server over stdio.
|
||||
@@ -192,13 +198,36 @@ async fn catalog(kinds: &[Kind]) -> Vec<ModelInfo> {
|
||||
let mut v = vec![];
|
||||
for k in kinds {
|
||||
match provider(*k) {
|
||||
Ok(p) => v.extend(hx_ai::models::load(*k, p.as_ref()).await),
|
||||
Ok(p) => {
|
||||
let (m, src) = hx_ai::models::load_with(*k, p.as_ref(), false).await;
|
||||
if let hx_ai::models::Source::Failed(e, stale) = src {
|
||||
let what = if stale {
|
||||
"expired cache"
|
||||
} else {
|
||||
"built-in list"
|
||||
};
|
||||
eprintln!("[{k:?}: live model list failed ({e}); using {what}]");
|
||||
}
|
||||
v.extend(m)
|
||||
}
|
||||
Err(_) => v.extend(hx_ai::models::fallback(*k)),
|
||||
}
|
||||
}
|
||||
v
|
||||
}
|
||||
|
||||
/// `hx models`: what each provider's `/models` returns, and where the list came from.
|
||||
async fn print_models(refresh: bool) {
|
||||
for k in logged_in() {
|
||||
let Ok(p) = provider(k) else { continue };
|
||||
let (m, src) = hx_ai::models::load_with(k, p.as_ref(), refresh).await;
|
||||
println!("{k:?}: {src:?}");
|
||||
for x in m {
|
||||
println!(" {} ({} ctx)", x.id, x.context_window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// USD per million tokens. ponytail: subscription usage isn't billed per token; this is an API-equivalent estimate.
|
||||
fn pricing(model: &str) -> Option<hx_ai::Pricing> {
|
||||
let p = |input, output, cache_read, cache_write| hx_ai::Pricing {
|
||||
@@ -300,6 +329,10 @@ async fn main() -> Result<()> {
|
||||
print!("{}", hx_core::stats::sub_report(&session));
|
||||
return Ok(());
|
||||
}
|
||||
Some(Cmd::Models { refresh }) => {
|
||||
print_models(refresh).await;
|
||||
return Ok(());
|
||||
}
|
||||
Some(Cmd::Prefix) => {
|
||||
let cwd = std::env::current_dir()?;
|
||||
let cfg = Config::load(&cwd)?;
|
||||
|
||||
Reference in new issue
Block a user