1package provider
2
3import (
4 "context"
5 "slices"
6 "testing"
7)
8
9func TestGPT6AstraCatalog(t *testing.T) {
10 for _, name := range []string{"openai", "openai-responses", "openai-codex", "github-copilot"} {
11 t.Run(name, func(t *testing.T) {
12 m, err := FindModel(name, "gpt-6-astra")
13 if err != nil {
14 t.Fatal(err)
15 }
16 wantContext := 272000
17 if name == "github-copilot" {
18 wantContext = 1050000
19 }
20 if m.API != APIResponses || m.ContextWindow != wantContext || m.MaxOutput != 128000 || !m.Reasoning || m.Speculative {
21 t.Fatalf("unexpected model capabilities: %+v", m)
22 }
23 if m.PriceInput != 10 || m.PriceOutput != 50 || m.PriceCacheRead != 1 || m.PriceCacheWrite != 12.5 {
24 t.Fatalf("unexpected standard prices: %+v", m)
25 }
26 if m.PriceTierInputTokens != 272000 || m.PriceInputAbove != 20 || m.PriceOutputAbove != 75 || m.PriceCacheReadAbove != 2 || m.PriceCacheWriteAbove != 25 {
27 t.Fatalf("unexpected long-context prices: %+v", m)
28 }
29 wantLevels := []string{"", "low", "medium", "high", "xhigh", "max"}
30 if got := AvailableReasoningLevels(m); !slices.Equal(got, wantLevels) {
31 t.Fatalf("reasoning levels = %q, want %q", got, wantLevels)
32 }
33 })
34 }
35}
36
37func TestGPT6AstraResponsesReasoning(t *testing.T) {
38 copilot := NewGithubCopilotClient("test-token").(*modelRouter)
39 clients := map[string]*codexClient{
40 "openai": NewOpenAIResponsesNamed("test-token", "", "openai").(*renamedClient).inner.(*codexClient),
41 "openai-responses": NewOpenAIResponsesNamed("test-token", "", "openai-responses").(*renamedClient).inner.(*codexClient),
42 "openai-codex": NewOpenAICodex("test-token", "test-account", "").(*codexClient),
43 "github-copilot": copilot.byAPI[APIResponses].(*renamedClient).inner.(*codexClient),
44 }
45 for name, client := range clients {
46 t.Run(name, func(t *testing.T) {
47 for _, effort := range []string{"", "low", "medium", "high", "xhigh", "max"} {
48 wire, err := client.buildRequest(Request{Model: "gpt-6-astra", Reasoning: effort})
49 if err != nil {
50 t.Fatal(err)
51 }
52 if wire.Model != "gpt-6-astra" {
53 t.Fatalf("wire model = %q", wire.Model)
54 }
55 if effort == "" {
56 if wire.Reasoning != nil {
57 t.Fatalf("unexpected reasoning config: %+v", wire.Reasoning)
58 }
59 } else if wire.Reasoning == nil || wire.Reasoning.Effort != effort {
60 t.Fatalf("reasoning = %+v, want %q", wire.Reasoning, effort)
61 }
62 }
63 })
64 }
65}
66
67func TestGPT6AstraCopilotDispatch(t *testing.T) {
68 router := NewGithubCopilotClient("test-token").(*modelRouter)
69 completions := &routeCaptureClient{name: "github-copilot"}
70 responses := &routeCaptureClient{name: "github-copilot"}
71 router.fallback = completions
72 router.byAPI[APIResponses] = responses
73
74 stream, err := router.Stream(context.Background(), Request{Model: "gpt-6-astra"})
75 if err != nil {
76 t.Fatal(err)
77 }
78 for range stream {
79 }
80 if !slices.Equal(responses.models, []string{"gpt-6-astra"}) || len(completions.models) != 0 {
81 t.Fatalf("Responses models = %v, Completions models = %v", responses.models, completions.models)
82 }
83}