mirror of
https://github.com/mudler/LocalAI.git
synced 2026-07-06 22:37:03 -04:00
Compare commits
2 Commits
v4.6.1
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c129ed7abd | ||
|
|
a6cf67cc6b |
@@ -3,5 +3,5 @@ protobuf
|
||||
certifi
|
||||
setuptools
|
||||
pillow
|
||||
charset-normalizer>=3.4.7
|
||||
charset-normalizer>=3.4.8
|
||||
chardet
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -58,7 +59,7 @@ func (s *chatSession) Clear() {
|
||||
}
|
||||
|
||||
func (s *chatSession) SwitchModel(model string) error {
|
||||
if !modelExists(s.models, model) {
|
||||
if !slices.Contains(s.models, model) {
|
||||
return fmt.Errorf("model %q is not available. Use /models to see installed models", model)
|
||||
}
|
||||
s.model = model
|
||||
@@ -103,18 +104,9 @@ Then start a chat session:
|
||||
b.WriteString("multiple models are available; choose one with --model:\n")
|
||||
b.WriteString(formatChatModelList(models, ""))
|
||||
return "", errors.New(b.String())
|
||||
case !modelExists(models, requested):
|
||||
case !slices.Contains(models, requested):
|
||||
return "", fmt.Errorf("model %q is not available. Use `local-ai models list` and `local-ai models install <model>`, or pass an installed model with --model", requested)
|
||||
default:
|
||||
return requested, nil
|
||||
}
|
||||
}
|
||||
|
||||
func modelExists(models []string, name string) bool {
|
||||
for _, model := range models {
|
||||
if model == name {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -49,12 +50,7 @@ type clinfoTypeProp struct {
|
||||
}
|
||||
|
||||
func (t clinfoTypeProp) isGPU() bool {
|
||||
for _, s := range t.Type {
|
||||
if s == clDeviceTypeGPU {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(t.Type, clDeviceTypeGPU)
|
||||
}
|
||||
|
||||
// clinfoOnce caches the result for the process lifetime. GPU hardware
|
||||
|
||||
Reference in New Issue
Block a user