File tree Expand file tree Collapse file tree
crates/rullm-cli/src/commands Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -153,16 +153,29 @@ pub async fn set_default_model(
153153 model : & str ,
154154 output_level : OutputLevel ,
155155) -> Result < ( ) > {
156- cli_config. config . default_model = Some ( model. to_string ( ) ) ;
157- cli_config. config . save ( & cli_config. config_base_path ) ?;
156+ let models_cache = load_models_cache ( cli_config) ?. unwrap_or ( ModelsCache :: new ( vec ! [ ] ) ) ;
158157
159- crate :: output:: success (
160- & format ! (
161- "Default model set to {}" ,
162- crate :: output:: format_model( model)
163- ) ,
164- output_level,
165- ) ;
158+ if models_cache. models . contains ( & model. to_string ( ) ) {
159+ cli_config. config . default_model = Some ( model. to_string ( ) ) ;
160+ cli_config. config . save ( & cli_config. config_base_path ) ?;
161+
162+ crate :: output:: success (
163+ & format ! (
164+ "Default model set to {}" ,
165+ crate :: output:: format_model( model)
166+ ) ,
167+ output_level,
168+ ) ;
169+ } else {
170+ crate :: output:: error_with_suggestion (
171+ & format ! ( "Model \" {model}\" not found in cache" ) ,
172+ & format ! (
173+ "Try running \" {} models update\" to update the cache" ,
174+ crate :: constants:: BINARY_NAME
175+ ) ,
176+ output_level,
177+ ) ;
178+ }
166179 Ok ( ( ) )
167180}
168181
You can’t perform that action at this time.
0 commit comments