v0.4.3 2a19df1

openai_url_test.go RawHistoryFolder

1package provider
2
3import "testing"
4
5// TestChatCompletionsURL pins the endpoint built for OpenAI-compatible
6// providers. The regression that motivated it: Z.AI's coding-plan base
7// carries a "/v4" version segment, so blindly appending
8// "/v1/chat/completions" produced ".../paas/v4/v1/chat/completions"
9// and a 404. Any base that already ends in a version segment must get
10// "/chat/completions" appended directly.
11func TestChatCompletionsURL(t *testing.T) {
12	cases := []struct {
13		name    string
14		baseURL string
15		want    string
16	}{
17		{
18			name:    "bare host gets conventional /v1 path",
19			baseURL: "https://api.openai.com",
20			want:    "https://api.openai.com/v1/chat/completions",
21		},
22		{
23			name:    "v1 base is not doubled",
24			baseURL: "https://api.moonshot.ai/v1",
25			want:    "https://api.moonshot.ai/v1/chat/completions",
26		},
27		{
28			name:    "zai coding plan v4 base is not given a spurious /v1",
29			baseURL: "https://api.z.ai/api/coding/paas/v4",
30			want:    "https://api.z.ai/api/coding/paas/v4/chat/completions",
31		},
32	}
33	for _, tc := range cases {
34		t.Run(tc.name, func(t *testing.T) {
35			if got := chatCompletionsURL(tc.baseURL); got != tc.want {
36				t.Errorf("chatCompletionsURL(%q) = %q, want %q", tc.baseURL, got, tc.want)
37			}
38		})
39	}
40}
41
42func TestGithubCopilotChatCompletionsURL(t *testing.T) {
43	copilot, ok := NewGithubCopilotClient("test-token").(*copilotClient)
44	if !ok {
45		t.Fatal("NewGithubCopilotClient did not return a copilotClient")
46	}
47	client, ok := copilot.router.fallback.(*openaiClient)
48	if !ok {
49		t.Fatal("GitHub Copilot router fallback is not an openaiClient")
50	}
51
52	const want = "https://api.individual.githubcopilot.com/chat/completions"
53	if got := client.chatCompletionsURL(); got != want {
54		t.Errorf("GitHub Copilot chat completions URL = %q, want %q", got, want)
55	}
56}

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 476

↑↓ moveenter openesc close