summaryrefslogtreecommitdiff
path: root/internal/llm/ollama_test.go
blob: 4ad6fdf32881d9855446a591af7026e8ccc51028 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package llm

import "testing"

func TestBuildOllamaRequest_OptionsAndStream(t *testing.T) {
    o := Options{Model: "codemodel", Temperature: 0, MaxTokens: 256, Stop: []string{"STOP"}}
    msgs := []Message{{Role: "user", Content: "hello"}}
    req := buildOllamaRequest(o, msgs, f64p(0.2), false)
    if req.Model != "codemodel" || req.Stream { t.Fatalf("model/stream mismatch: %+v", req) }
    if req.Options == nil { t.Fatalf("expected options map") }
    if req.Options.(map[string]any)["temperature"].(float64) != 0.2 { t.Fatalf("default temp not applied") }
    if req.Options.(map[string]any)["num_predict"].(int) != 256 { t.Fatalf("num_predict not applied") }
    if req.Options.(map[string]any)["stop"].([]string)[0] != "STOP" { t.Fatalf("stop not applied") }

    req2 := buildOllamaRequest(o, msgs, f64p(0.2), true)
    if !req2.Stream { t.Fatalf("expected stream=true") }
}