mirror of
https://github.com/ollama/ollama.git
synced 2025-11-10 22:37:29 +01:00
engine: add remote proxy (#12307)
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -20,6 +21,7 @@ import (
|
||||
"github.com/ollama/ollama/api"
|
||||
"github.com/ollama/ollama/envconfig"
|
||||
"github.com/ollama/ollama/fs/ggml"
|
||||
"github.com/ollama/ollama/types/model"
|
||||
)
|
||||
|
||||
var stream bool = false
|
||||
@@ -615,6 +617,78 @@ func TestCreateTemplateSystem(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestCreateAndShowRemoteModel(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
var s Server
|
||||
|
||||
w := createRequest(t, s.CreateHandler, api.CreateRequest{
|
||||
Model: "test",
|
||||
From: "bob",
|
||||
RemoteHost: "https://ollama.com",
|
||||
Info: map[string]any{
|
||||
"capabilities": []string{"completion", "tools", "thinking"},
|
||||
"model_family": "gptoss",
|
||||
"context_length": 131072,
|
||||
"embedding_length": 2880,
|
||||
"quantization_level": "MXFP4",
|
||||
"parameter_size": "20.9B",
|
||||
},
|
||||
Stream: &stream,
|
||||
})
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("exected status code 200, actual %d", w.Code)
|
||||
}
|
||||
|
||||
w = createRequest(t, s.ShowHandler, api.ShowRequest{Model: "test"})
|
||||
if w.Code != http.StatusOK {
|
||||
t.Fatalf("exected status code 200, actual %d", w.Code)
|
||||
}
|
||||
|
||||
var resp api.ShowResponse
|
||||
if err := json.NewDecoder(w.Body).Decode(&resp); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
expectedDetails := api.ModelDetails{
|
||||
ParentModel: "",
|
||||
Format: "",
|
||||
Family: "gptoss",
|
||||
Families: []string{"gptoss"},
|
||||
ParameterSize: "20.9B",
|
||||
QuantizationLevel: "MXFP4",
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(resp.Details, expectedDetails) {
|
||||
t.Errorf("model details: expected %#v, actual %#v", expectedDetails, resp.Details)
|
||||
}
|
||||
|
||||
expectedCaps := []model.Capability{
|
||||
model.Capability("completion"),
|
||||
model.Capability("tools"),
|
||||
model.Capability("thinking"),
|
||||
}
|
||||
|
||||
if !slices.Equal(resp.Capabilities, expectedCaps) {
|
||||
t.Errorf("capabilities: expected %#v, actual %#v", expectedCaps, resp.Capabilities)
|
||||
}
|
||||
|
||||
v, ok := resp.ModelInfo["gptoss.context_length"]
|
||||
ctxlen := v.(float64)
|
||||
if !ok || int(ctxlen) != 131072 {
|
||||
t.Errorf("context len: expected %d, actual %d", 131072, int(ctxlen))
|
||||
}
|
||||
|
||||
v, ok = resp.ModelInfo["gptoss.embedding_length"]
|
||||
embedlen := v.(float64)
|
||||
if !ok || int(embedlen) != 2880 {
|
||||
t.Errorf("embed len: expected %d, actual %d", 2880, int(embedlen))
|
||||
}
|
||||
|
||||
fmt.Printf("resp = %#v\n", resp)
|
||||
}
|
||||
|
||||
func TestCreateLicenses(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user