Enha: atomic global vars instead of mutexes
This commit is contained in:
@@ -22,7 +22,7 @@ func showModelSelectionPopup() {
|
||||
models, err := fetchLCPModelsWithLoadStatus()
|
||||
if err != nil {
|
||||
logger.Error("failed to fetch models with load status", "error", err)
|
||||
return LocalModels
|
||||
return LocalModels.Load().([]string)
|
||||
}
|
||||
return models
|
||||
}
|
||||
@@ -30,7 +30,8 @@ func showModelSelectionPopup() {
|
||||
modelList := getModelListForAPI(cfg.CurrentAPI)
|
||||
// Check for empty options list
|
||||
if len(modelList) == 0 {
|
||||
logger.Warn("empty model list for", "api", cfg.CurrentAPI, "localModelsLen", len(LocalModels), "orModelsLen", len(ORFreeModels))
|
||||
localModels := LocalModels.Load().([]string)
|
||||
logger.Warn("empty model list for", "api", cfg.CurrentAPI, "localModelsLen", len(localModels), "orModelsLen", len(ORFreeModels))
|
||||
var message string
|
||||
switch {
|
||||
case strings.Contains(cfg.CurrentAPI, "openrouter.ai"):
|
||||
@@ -150,9 +151,7 @@ func showAPILinkSelectionPopup() {
|
||||
}
|
||||
// Assume local llama.cpp
|
||||
refreshLocalModelsIfEmpty()
|
||||
localModelsMu.RLock()
|
||||
defer localModelsMu.RUnlock()
|
||||
return LocalModels
|
||||
return LocalModels.Load().([]string)
|
||||
}
|
||||
newModelList := getModelListForAPI(cfg.CurrentAPI)
|
||||
// Ensure chatBody.Model is in the new list; if not, set to first available model
|
||||
|
||||
Reference in New Issue
Block a user