50 lines
1.0 KiB
Go
50 lines
1.0 KiB
Go
package gollama_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
gollama "gitea.neitzel.de/konrad/go-ollama"
|
|
)
|
|
|
|
func TestOptionSetMerge(t *testing.T) {
|
|
base := gollama.NewOptions().Temperature(0.8).TopP(0.9)
|
|
override := gollama.NewOptions().Temperature(0.2)
|
|
merged := base.Merge(override)
|
|
|
|
m, err := merged.ToMapForTest()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m["temperature"] != float64(0.2) {
|
|
t.Fatalf("temperature = %v", m["temperature"])
|
|
}
|
|
if m["top_p"] != float64(0.9) {
|
|
t.Fatalf("top_p = %v", m["top_p"])
|
|
}
|
|
}
|
|
|
|
func TestParseModelfileParameters(t *testing.T) {
|
|
params := "temperature 0.5\nnum_ctx 4096\n"
|
|
opts, err := gollama.ParseModelfileParametersForTest(params)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
m, err := opts.ToMapForTest()
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if m["temperature"] != float64(0.5) {
|
|
t.Fatalf("temperature = %v", m["temperature"])
|
|
}
|
|
if m["num_ctx"] != float64(4096) {
|
|
t.Fatalf("num_ctx = %v", m["num_ctx"])
|
|
}
|
|
}
|
|
|
|
func TestKnownOptions(t *testing.T) {
|
|
docs := gollama.KnownOptions()
|
|
if len(docs) == 0 {
|
|
t.Fatal("expected known options")
|
|
}
|
|
}
|