File tree Expand file tree Collapse file tree 3 files changed +13
-24
lines changed
Expand file tree Collapse file tree 3 files changed +13
-24
lines changed Original file line number Diff line number Diff line change @@ -150,18 +150,17 @@ public void RefreshCatalog()
150150
151151 public async Task < ModelInfo ? > GetModelInfoAsync ( string aliasOrModelId , DeviceType ? device = null , CancellationToken ct = default )
152152 {
153- // Resolve directly from the cached list (mirrors Python behavior)
154153 var catalog = await ListCatalogModelsAsync ( ct ) ;
155154 if ( catalog . Count == 0 || string . IsNullOrWhiteSpace ( aliasOrModelId ) )
156155 {
157156 return null ;
158157 }
159158
160- // 1) If looks like a full ID (has ':'), match by ID exactly
161- if ( aliasOrModelId . Contains ( ':' ) )
159+ // 1) Try to match by full ID exactly (with or without ':' for backwards compatibility)
160+ var exact = catalog . FirstOrDefault ( m =>
161+ m . ModelId . Equals ( aliasOrModelId , StringComparison . OrdinalIgnoreCase ) ) ;
162+ if ( exact != null )
162163 {
163- var exact = catalog . FirstOrDefault ( m =>
164- m . ModelId . Equals ( aliasOrModelId , StringComparison . OrdinalIgnoreCase ) ) ;
165164 return exact ;
166165 }
167166
@@ -193,7 +192,7 @@ public void RefreshCatalog()
193192 aliasMatches = aliasMatches . Where ( m => m . Runtime . DeviceType == device ) ;
194193 }
195194
196- // Catalog/list is assumed pre-sorted by service similar to Python comment :
195+ // Catalog/list is assumed pre-sorted by service:
197196 // NPU → non-generic-GPU → generic-GPU → non-generic-CPU → CPU
198197 var candidate = aliasMatches . FirstOrDefault ( ) ;
199198 if ( candidate == null ) return null ;
Original file line number Diff line number Diff line change @@ -157,16 +157,10 @@ export class FoundryLocalManager {
157157 const catalog = await this . listCatalogModels ( )
158158 const key = aliasOrModelId . toLowerCase ( )
159159
160- // 1) Full ID with version
161- if ( aliasOrModelId . includes ( ':' ) ) {
162- const exact = catalog . find ( ( m ) => m . id . toLowerCase ( ) === key )
163- if ( exact ) {
164- return exact
165- }
166- if ( throwOnNotFound ) {
167- throw new Error ( `Model ${ aliasOrModelId } not found in the catalog.` )
168- }
169- return null
160+ // 1) Full ID match (with or without ':' for backwards compatibility)
161+ const exact = catalog . find ( ( m ) => m . id . toLowerCase ( ) === key )
162+ if ( exact ) {
163+ return exact
170164 }
171165
172166 // 2) ID prefix → pick highest version
Original file line number Diff line number Diff line change @@ -182,14 +182,10 @@ def get_model_info(
182182 catalog = self .list_catalog_models ()
183183 key = alias_or_model_id .lower ()
184184
185- # 1) If it looks like a full ID (has ':'), match by ID exactly
186- if ":" in alias_or_model_id :
187- model_info = next ((m for m in catalog if m .id .lower () == key ), None )
188- if model_info is not None :
189- return model_info
190- if raise_on_not_found :
191- raise ValueError (f"Model { alias_or_model_id } not found in the catalog." )
192- return None
185+ # 1) Try to match by full ID exactly (with or without ':' for backwards compatibility)
186+ model_info = next ((m for m in catalog if m .id .lower () == key ), None )
187+ if model_info is not None :
188+ return model_info
193189
194190 # 2) Try to match by ID prefix "<id>:" and pick the highest version
195191 prefix = f"{ key } :"
You can’t perform that action at this time.
0 commit comments