v0.4.8 de90baf

gpt6_astra_test.go RawHistoryFolder

1package provider
2
3import (
4	"context"
5	"slices"
6	"testing"
7)
8
9func TestGPT6SolAndLunaCatalog(t *testing.T) {
10	models := []struct {
11		id         string
12		input      float64
13		output     float64
14		cacheRead  float64
15		cacheWrite float64
16		inputAbove float64
17		outAbove   float64
18		readAbove  float64
19		writeAbove float64
20	}{
21		{"gpt-6-sol", 2, 10, 0.2, 2.5, 4, 15, 0.4, 5},
22		{"gpt-6-luna", 0.1, 0.5, 0.01, 0.125, 0.2, 0.75, 0.02, 0.25},
23	}
24	for _, model := range models {
25		for _, name := range []string{"openai", "openai-responses", "openai-codex", "github-copilot"} {
26			t.Run(name+"/"+model.id, func(t *testing.T) {
27				m, err := FindModel(name, model.id)
28				if err != nil {
29					t.Fatal(err)
30				}
31				wantContext := 272000
32				if name == "github-copilot" {
33					wantContext = 1000000
34				}
35				if m.API != APIResponses || m.ContextWindow != wantContext || m.MaxOutput != 128000 || !m.Reasoning || m.Speculative {
36					t.Fatalf("unexpected model capabilities: %+v", m)
37				}
38				if m.PriceInput != model.input || m.PriceOutput != model.output || m.PriceCacheRead != model.cacheRead || m.PriceCacheWrite != model.cacheWrite {
39					t.Fatalf("unexpected standard prices: %+v", m)
40				}
41				if m.PriceTierInputTokens != 272000 || m.PriceInputAbove != model.inputAbove || m.PriceOutputAbove != model.outAbove || m.PriceCacheReadAbove != model.readAbove || m.PriceCacheWriteAbove != model.writeAbove {
42					t.Fatalf("unexpected long-context prices: %+v", m)
43				}
44				wantLevels := []string{"", "low", "medium", "high", "xhigh", "max"}
45				if got := AvailableReasoningLevels(m); !slices.Equal(got, wantLevels) {
46					t.Fatalf("reasoning levels = %q, want %q", got, wantLevels)
47				}
48			})
49		}
50	}
51}
52
53func TestGPT6SolAndLunaResponsesReasoning(t *testing.T) {
54	copilot := NewGithubCopilotClient("test-token").(*copilotClient).router
55	clients := map[string]*codexClient{
56		"openai":           NewOpenAIResponsesNamed("test-token", "", "openai").(*renamedClient).inner.(*codexClient),
57		"openai-responses": NewOpenAIResponsesNamed("test-token", "", "openai-responses").(*renamedClient).inner.(*codexClient),
58		"openai-codex":     NewOpenAICodex("test-token", "test-account", "").(*codexClient),
59		"github-copilot":   copilot.byAPI[APIResponses].(*codexClient),
60	}
61	for name, client := range clients {
62		for _, model := range []string{"gpt-6-sol", "gpt-6-luna"} {
63			t.Run(name+"/"+model, func(t *testing.T) {
64				wire, err := client.buildRequest(Request{Model: model, Reasoning: "max"})
65				if err != nil {
66					t.Fatal(err)
67				}
68				if wire.Model != model || wire.Reasoning == nil || wire.Reasoning.Effort != "max" {
69					t.Fatalf("unexpected request: %+v", wire)
70				}
71			})
72		}
73	}
74}
75
76func TestGPT6SolAndLunaCopilotDispatch(t *testing.T) {
77	router := NewGithubCopilotClient("test-token").(*copilotClient).router
78	completions := &routeCaptureClient{name: "github-copilot"}
79	responses := &routeCaptureClient{name: "github-copilot"}
80	router.fallback = completions
81	router.byAPI[APIResponses] = responses
82
83	for _, model := range []string{"gpt-6-sol", "gpt-6-luna"} {
84		stream, err := router.Stream(context.Background(), Request{Model: model})
85		if err != nil {
86			t.Fatal(err)
87		}
88		for range stream {
89		}
90	}
91	if !slices.Equal(responses.models, []string{"gpt-6-sol", "gpt-6-luna"}) || len(completions.models) != 0 {
92		t.Fatalf("Responses models = %v, Completions models = %v", responses.models, completions.models)
93	}
94}
95
96func TestGPT6AstraCatalog(t *testing.T) {
97	for _, name := range []string{"openai", "openai-responses", "openai-codex", "github-copilot"} {
98		t.Run(name, func(t *testing.T) {
99			m, err := FindModel(name, "gpt-6-astra")
100			if err != nil {
101				t.Fatal(err)
102			}
103			wantContext := 272000
104			if name == "github-copilot" {
105				wantContext = 1050000
106			}
107			if m.API != APIResponses || m.ContextWindow != wantContext || m.MaxOutput != 128000 || !m.Reasoning || m.Speculative {
108				t.Fatalf("unexpected model capabilities: %+v", m)
109			}
110			if m.PriceInput != 10 || m.PriceOutput != 50 || m.PriceCacheRead != 1 || m.PriceCacheWrite != 12.5 {
111				t.Fatalf("unexpected standard prices: %+v", m)
112			}
113			if m.PriceTierInputTokens != 272000 || m.PriceInputAbove != 20 || m.PriceOutputAbove != 75 || m.PriceCacheReadAbove != 2 || m.PriceCacheWriteAbove != 25 {
114				t.Fatalf("unexpected long-context prices: %+v", m)
115			}
116			wantLevels := []string{"", "low", "medium", "high", "xhigh", "max"}
117			if got := AvailableReasoningLevels(m); !slices.Equal(got, wantLevels) {
118				t.Fatalf("reasoning levels = %q, want %q", got, wantLevels)
119			}
120		})
121	}
122}
123
124func TestGPT6AstraResponsesReasoning(t *testing.T) {
125	copilot := NewGithubCopilotClient("test-token").(*copilotClient).router
126	clients := map[string]*codexClient{
127		"openai":           NewOpenAIResponsesNamed("test-token", "", "openai").(*renamedClient).inner.(*codexClient),
128		"openai-responses": NewOpenAIResponsesNamed("test-token", "", "openai-responses").(*renamedClient).inner.(*codexClient),
129		"openai-codex":     NewOpenAICodex("test-token", "test-account", "").(*codexClient),
130		"github-copilot":   copilot.byAPI[APIResponses].(*codexClient),
131	}
132	for name, client := range clients {
133		t.Run(name, func(t *testing.T) {
134			for _, effort := range []string{"", "low", "medium", "high", "xhigh", "max"} {
135				wire, err := client.buildRequest(Request{Model: "gpt-6-astra", Reasoning: effort})
136				if err != nil {
137					t.Fatal(err)
138				}
139				if wire.Model != "gpt-6-astra" {
140					t.Fatalf("wire model = %q", wire.Model)
141				}
142				if effort == "" {
143					if wire.Reasoning != nil {
144						t.Fatalf("unexpected reasoning config: %+v", wire.Reasoning)
145					}
146				} else if wire.Reasoning == nil || wire.Reasoning.Effort != effort {
147					t.Fatalf("reasoning = %+v, want %q", wire.Reasoning, effort)
148				}
149			}
150		})
151	}
152}
153
154func TestGPT6AstraCopilotDispatch(t *testing.T) {
155	router := NewGithubCopilotClient("test-token").(*copilotClient).router
156	completions := &routeCaptureClient{name: "github-copilot"}
157	responses := &routeCaptureClient{name: "github-copilot"}
158	router.fallback = completions
159	router.byAPI[APIResponses] = responses
160
161	stream, err := router.Stream(context.Background(), Request{Model: "gpt-6-astra"})
162	if err != nil {
163		t.Fatal(err)
164	}
165	for range stream {
166	}
167	if !slices.Equal(responses.models, []string{"gpt-6-astra"}) || len(completions.models) != 0 {
168		t.Fatalf("Responses models = %v, Completions models = %v", responses.models, completions.models)
169	}
170}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 477

↑↓ moveenter openesc close