Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

server/internal/client/ollama: set User-Agent for registry client (#9775)

Blake Mizerany8294676150dd
diff --git a/server/internal/client/ollama/registry.go b/server/internal/client/ollama/registry.go
index cf05f79ae..d1d01ba46 100644
--- a/server/internal/client/ollama/registry.go
+++ b/server/internal/client/ollama/registry.go
@@ -25,6 +25,7 @@ import (
"os"
"path/filepath"
"runtime"
+ "runtime/debug"
"slices"
"strconv"
"strings"
@@ -259,6 +260,7 @@ func DefaultRegistry() (*Registry, error) {
}
var rc Registry
+ rc.UserAgent = UserAgent()
rc.Key, err = ssh.ParseRawPrivateKey(keyPEM)
if err != nil {
return nil, err
@@ -274,6 +276,16 @@ func DefaultRegistry() (*Registry, error) {
return &rc, nil
}
+func UserAgent() string {
+ buildinfo, _ := debug.ReadBuildInfo()
+ return fmt.Sprintf("ollama/%s (%s %s) Go/%s",
+ buildinfo.Main.Version,
+ runtime.GOARCH,
+ runtime.GOOS,
+ runtime.Version(),
+ )
+}
+
func (r *Registry) maxStreams() int {
return cmp.Or(r.MaxStreams, runtime.GOMAXPROCS(0))
}