MCPcopy Index your code
hub / github.com/mudler/LocalAI / UnloadRemoteModel

Method UnloadRemoteModel

core/services/nodes/unloader.go:83–103  ·  view source on GitHub ↗

UnloadRemoteModel finds the node(s) hosting the given model and tells them to stop their backend process via NATS backend.stop event. The worker process handles: Free() → kill process. This is called by ModelLoader.deleteProcess() when process == nil (remote model).

(modelName string)

Source from the content-addressed store, hash-verified

81// The worker process handles: Free() → kill process.
82// This is called by ModelLoader.deleteProcess() when process == nil (remote model).
83func (a *RemoteUnloaderAdapter) UnloadRemoteModel(modelName string) error {
84 ctx := context.Background()
85 nodes, err := a.registry.FindNodesWithModel(ctx, modelName)
86 if err != nil || len(nodes) == 0 {
87 xlog.Debug("No remote nodes found with model", "model", modelName)
88 return nil
89 }
90
91 for _, node := range nodes {
92 xlog.Info("Sending NATS backend.stop to node", "model", modelName, "node", node.Name, "nodeID", node.ID)
93 if err := a.StopBackend(node.ID, modelName); err != nil {
94 xlog.Warn("Failed to send backend.stop", "node", node.Name, "error", err)
95 continue
96 }
97 // Remove every replica of this model on the node — the worker will
98 // handle the actual process cleanup.
99 a.registry.RemoveAllNodeModelReplicas(ctx, node.ID, modelName)
100 }
101
102 return nil
103}
104
105// InstallBackend sends a backend.install request-reply to a worker node.
106// Idempotent on the worker: if the (modelID, replica) process is already

Callers

nothing calls this directly

Calls 3

StopBackendMethod · 0.95
FindNodesWithModelMethod · 0.65

Tested by

no test coverage detected