mirror of
https://github.com/mudler/LocalAI.git
synced 2026-06-22 15:49:12 -04:00
LocalAI pulls models from OCI registries (via go-containerregistry), the Ollama registry, and OCI blob stores (via oras), but every request went out with the underlying library's generic User-Agent, so registry operators had no way to attribute traffic to LocalAI. Add an oci.UserAgent() helper that returns "LocalAI" (or "LocalAI/<version>" when the binary is built with a version stamp via internal.Version) and wire it into all three pull paths: - pkg/oci/image.go: remote.WithUserAgent on the go-containerregistry image and digest requests - pkg/oci/ollama.go: a User-Agent header on the Ollama manifest request - pkg/oci/blob.go: a LocalAI User-Agent on the oras blob client. This mirrors oras' auth.DefaultClient (same retry.DefaultClient policy); only the advertised User-Agent changes. Implements #6258. Assisted-by: Claude:claude-opus-4-8 golangci-lint Signed-off-by: Vijay Sai <vijaysaijnv@gmail.com>
33 lines
680 B
Go
33 lines
680 B
Go
package oci_test
|
|
|
|
import (
|
|
"github.com/mudler/LocalAI/internal"
|
|
. "github.com/mudler/LocalAI/pkg/oci"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
)
|
|
|
|
var _ = Describe("OCI", func() {
|
|
Context("UserAgent", func() {
|
|
var savedVersion string
|
|
|
|
BeforeEach(func() {
|
|
savedVersion = internal.Version
|
|
})
|
|
|
|
AfterEach(func() {
|
|
internal.Version = savedVersion
|
|
})
|
|
|
|
It("identifies as LocalAI when no version is stamped", func() {
|
|
internal.Version = ""
|
|
Expect(UserAgent()).To(Equal("LocalAI"))
|
|
})
|
|
|
|
It("appends the build version when one is stamped", func() {
|
|
internal.Version = "v3.2.1"
|
|
Expect(UserAgent()).To(Equal("LocalAI/v3.2.1"))
|
|
})
|
|
})
|
|
})
|