Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func main() {
llamacpp.ShouldUpdateServerLock.Unlock()
}

desiredSeverVersion, ok := os.LookupEnv("LLAMACPP_SERVER_VERSION")
if ok {
llamacpp.SetDesiredServerVersion(desiredSeverVersion)
}

modelManager := models.NewManager(
log,
models.ClientConfig{
Expand Down
14 changes: 14 additions & 0 deletions pkg/inference/backends/llamacpp/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,24 @@ var (
ShouldUseGPUVariantLock sync.Mutex
ShouldUpdateServer = true
ShouldUpdateServerLock sync.Mutex
DesiredServerVersion = "latest"
DesiredServerVersionLock sync.Mutex
errLlamaCppUpToDate = errors.New("bundled llama.cpp version is up to date, no need to update")
errLlamaCppUpdateDisabled = errors.New("llama.cpp auto-updated is disabled")
)

func GetDesiredServerVersion() string {
DesiredServerVersionLock.Lock()
defer DesiredServerVersionLock.Unlock()
return DesiredServerVersion
}

func SetDesiredServerVersion(version string) {
DesiredServerVersionLock.Lock()
defer DesiredServerVersionLock.Unlock()
DesiredServerVersion = version
}

func (l *llamaCpp) downloadLatestLlamaCpp(ctx context.Context, log logging.Logger, httpClient *http.Client,
llamaCppPath, vendoredServerStoragePath, desiredVersion, desiredVariant string,
) error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/inference/backends/llamacpp/download_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func (l *llamaCpp) ensureLatestLlamaCpp(ctx context.Context, log logging.Logger, httpClient *http.Client,
llamaCppPath, vendoredServerStoragePath string,
) error {
desiredVersion := "latest"
desiredVersion := GetDesiredServerVersion()
desiredVariant := "metal"
return l.downloadLatestLlamaCpp(ctx, log, httpClient, llamaCppPath, vendoredServerStoragePath, desiredVersion,
desiredVariant)
Expand Down
2 changes: 1 addition & 1 deletion pkg/inference/backends/llamacpp/download_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (l *llamaCpp) ensureLatestLlamaCpp(ctx context.Context, log logging.Logger,
}
}
}
desiredVersion := "latest"
desiredVersion := GetDesiredServerVersion()
desiredVariant := "cpu"
if canUseCUDA11 {
desiredVariant = "cuda"
Expand Down