@@ -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
433433fn 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