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
2 changes: 1 addition & 1 deletion backend/cpp/llama-cpp/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

LLAMA_VERSION?=f280b26983ad0fdb705a0d9ebf0503e76f2899b0
LLAMA_VERSION?=eab8ee41f889ef7823af517e8098fb8a9b3cf601
LLAMA_REPO?=https://github.com/ggerganov/llama.cpp

CMAKE_ARGS?=
Expand Down
2 changes: 1 addition & 1 deletion backend/go/stablediffusion-ggml/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ JOBS?=$(shell nproc --ignore=1)

# stablediffusion.cpp (ggml)
STABLEDIFFUSION_GGML_REPO?=https://github.com/leejet/stable-diffusion.cpp
STABLEDIFFUSION_GGML_VERSION?=97d2990807fe6d558e395f8764198d7c7e7b411c
STABLEDIFFUSION_GGML_VERSION?=50d640568388f876b0d63ee6ddb6bc86d997ec64

CMAKE_ARGS+=-DGGML_MAX_NAME=128

Expand Down
14 changes: 14 additions & 0 deletions core/http/endpoints/ollama/models_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ parameters:
Expect(resp.Details.Format).To(Equal("gguf"))
Expect(resp.Details.Families).ToNot(BeEmpty())
})

It("looks up the model when the Ollama :latest tag is included", func() {
writeConfig("chat", `
name: chat
backend: llama-cpp
template:
chat: "{{ .Input }}"
parameters:
model: Llama-3-8B-Q4_K_M.gguf
`)
resp := callShow("chat:latest")
Expect(resp.Details.Format).To(Equal("gguf"))
Expect(resp.Capabilities).To(ContainElement("completion"))
})
})

Describe("ListModelsEndpoint", func() {
Expand Down
6 changes: 6 additions & 0 deletions core/http/middleware/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ func (re *RequestExtractor) SetModelAndConfig(initializer func() schema.LocalAIR
}

modelName := input.ModelName(nil)
// Ollama-compat /api/tags appends ":latest" to untagged names.
// Strip it for lookup so the listed name works on /api/chat,
// /v1/chat/completions, and the other model-bearing endpoints.
if strings.HasSuffix(modelName, ":latest") {
modelName = strings.TrimSuffix(modelName, ":latest")
}
cfg, err := re.modelConfigLoader.LoadModelConfigFileByNameDefaultOptions(modelName, re.applicationConfig)

if err != nil {
Expand Down
14 changes: 14 additions & 0 deletions core/http/middleware/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ var _ = Describe("SetModelAndConfig middleware", func() {
Expect(resp.Error.Message).To(ContainSubstring("not found"))
Expect(resp.Error.Type).To(Equal("invalid_request_error"))
})

It("still 404s when :latest is appended to an unknown model", func() {
rec := postJSON(app, "/v1/chat/completions",
`{"model":"nonexistent-model:latest","messages":[{"role":"user","content":"hi"}]}`)

Expect(rec.Code).To(Equal(http.StatusNotFound))
})
})

Context("when the model exists as a config file", func() {
Expand All @@ -97,6 +104,13 @@ var _ = Describe("SetModelAndConfig middleware", func() {

Expect(rec.Code).To(Equal(http.StatusOK))
})

It("accepts the Ollama :latest tag that /api/tags appends", func() {
rec := postJSON(app, "/v1/chat/completions",
`{"model":"test-model:latest","messages":[{"role":"user","content":"hi"}]}`)

Expect(rec.Code).To(Equal(http.StatusOK))
})
})

Context("when the model exists as a pre-loaded config", func() {
Expand Down
8 changes: 8 additions & 0 deletions core/services/modeladmin/modeladmin_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ package modeladmin

import (
"testing"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestModelAdmin(t *testing.T) {
RegisterFailHandler(Fail)
// Several specs in this suite coordinate goroutines through
// Eventually/Consistently on unbuffered-ish channels (e.g. the
// blockingRevisionLifecycle helper). Gomega's 1s default timeout can be
// too tight on slower or loaded CI runners (notably macOS runners),
// causing spurious "Timed out after 1.005s" failures even though the
// goroutines eventually make progress. Give them more headroom.
SetDefaultEventuallyTimeout(5 * time.Second)
RunSpecs(t, "modeladmin test suite")
}
Loading
Loading