MCPcopy
hub / github.com/sammcj/gollama / handleUnloadModelsKey

Method handleUnloadModelsKey

app_model.go:660–682  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

658}
659
660func (m *AppModel) handleUnloadModelsKey() (tea.Model, tea.Cmd) {
661 return m, func() tea.Msg {
662 // get any loaded models
663 ctx := context.Background()
664 loadedModels, err := m.client.ListRunning(ctx)
665 if err != nil {
666 return genericMsg{message: fmt.Sprintf("Error listing running models: %v", err)}
667 }
668
669 // unload the models
670 var unloadedModels []string
671 for _, model := range loadedModels.Models {
672 _, err := unloadModel(m.client, model.Name)
673 if err != nil {
674 return genericMsg{message: styles.ErrorStyle().Render(fmt.Sprintf("Error unloading model %s: %v", model.Name, err))}
675 } else {
676 unloadedModels = append(unloadedModels, styles.WarningStyle().Render(model.Name))
677 logging.InfoLogger.Printf("Model %s unloaded\n", model.Name)
678 }
679 }
680 return genericMsg{message: styles.SuccessStyle().Render(fmt.Sprintf("Models unloaded: %v", unloadedModels))}
681 }
682}
683
684func (m *AppModel) handleCopyModelKey() (tea.Model, tea.Cmd) {
685 defer func() {

Callers 1

handleKeyMsgMethod · 0.95

Calls 5

ErrorStyleFunction · 0.92
WarningStyleFunction · 0.92
SuccessStyleFunction · 0.92
unloadModelFunction · 0.85
RenderMethod · 0.80

Tested by

no test coverage detected