summaryrefslogtreecommitdiff
path: root/internal/llm/copilot_test.go
blob: 8f153472979e718651fbbef92460453c02433e1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package llm

import "testing"

func TestBuildCopilotChatRequest_FieldsAndDefaults(t *testing.T) {
	o := Options{
		Model:       "gpt-x",
		Temperature: 0,
		MaxTokens:   123,
		Stop:        []string{"X"},
	}

	msgs := []Message{{Role: "user", Content: "q"}}
	req := buildCopilotChatRequest(o, msgs, f64p(0.5))

	if req.Model != "gpt-x" {
		t.Fatalf("model mismatch: %q", req.Model)
	}

	if req.Temperature == nil || *req.Temperature != 0.5 {
		t.Fatalf("default temp not applied")
	}

	if req.MaxTokens == nil || *req.MaxTokens != 123 {
		t.Fatalf("max_tokens not applied")
	}

	if len(req.Stop) != 1 || req.Stop[0] != "X" {
		t.Fatalf("stop not applied")
	}

	if len(req.Messages) != 1 || req.Messages[0].Content != "q" {
		t.Fatalf("messages not copied")
	}
}