@@ -358,91 +358,28 @@ const LocalModelsTable = ({
358358 "'?" ,
359359 )
360360 ) {
361- try {
362- if (
363- confirm (
364- "Do you want to delete model '" +
365- row . model_id +
366- "' from your local Huggingface cache as well (if present) ?" ,
367- )
368- ) {
369- await fetch (
370- chatAPI . Endpoints . Models . Delete (
371- row . model_id ,
372- true ,
373- ) ,
374- ) ;
375- } else {
376- await fetch (
377- chatAPI . Endpoints . Models . Delete (
378- row . model_id ,
379- false ,
380- ) ,
381- ) ;
382- }
383-
384- await mutateModels ( ) ;
385-
386- try {
387- const currentFoundation =
388- experimentInfo ?. config ?. foundation ||
389- '' ;
390- const currentFilename =
391- experimentInfo ?. config
392- ?. foundation_filename || '' ;
393- const foundationId = currentFoundation
394- ? String ( currentFoundation )
395- . split ( '/' )
396- . slice ( - 1 ) [ 0 ]
397- : '' ;
398-
399- const deletedMatchesFoundation =
400- foundationId === row . model_id ||
401- currentFoundation === row . model_id ||
402- currentFilename === row . model_id ||
403- currentFilename === row . local_path ||
404- currentFoundation === row . local_path ;
405-
406- if (
407- deletedMatchesFoundation &&
408- experimentInfo ?. id
409- ) {
410- // optimistic clear in UI
411- if (
412- typeof setFoundation === 'function'
413- ) {
414- setFoundation ( null ) ;
415- }
416-
417- // batch-update backend to clear all foundation-related fields
418- await chatAPI . authenticatedFetch (
419- chatAPI . Endpoints . Experiment . UpdateConfigs (
420- experimentInfo . id ,
421- ) ,
422- {
423- method : 'POST' ,
424- headers : {
425- 'Content-Type' :
426- 'application/json' ,
427- } ,
428- body : JSON . stringify ( {
429- foundation : '' ,
430- foundation_filename : '' ,
431- foundation_model_architecture : '' ,
432- inferenceParams : '{}' ,
433- } ) ,
434- } ,
435- ) ;
436- }
437- } catch ( err ) {
438- console . error (
439- 'Error clearing foundation after model deletion' ,
440- err ,
441- ) ;
442- }
443- } catch ( e ) {
444- console . error ( 'Failed to delete model' , e ) ;
445- alert ( 'Failed to delete model' ) ;
361+ if (
362+ confirm (
363+ "Do you want to delete model '" +
364+ row . model_id +
365+ "' from your local Huggingface cache as well (if present) ?" ,
366+ )
367+ ) {
368+ await fetch (
369+ chatAPI . Endpoints . Models . Delete (
370+ row . model_id ,
371+ true ,
372+ ) ,
373+ ) ;
374+ mutateModels ( ) ;
375+ } else {
376+ await fetch (
377+ chatAPI . Endpoints . Models . Delete (
378+ row . model_id ,
379+ false ,
380+ ) ,
381+ ) ;
382+ mutateModels ( ) ;
446383 }
447384 }
448385 } }
0 commit comments