Skip to content

Commit d40175b

Browse files
authored
Merge pull request #2189 from dgageot/implement-docker-agent-issue-2148-849958fe
Add GitHub Copilot as a provider alias
2 parents 725d97c + 7aafce0 commit d40175b

5 files changed

Lines changed: 41 additions & 60 deletions

File tree

agent-schema.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@
495495
"openai",
496496
"anthropic",
497497
"dmr",
498-
"ollama"
498+
"ollama",
499+
"github-copilot"
499500
]
500501
},
501502
"model": {

examples/github-copilot.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env docker agent run
2+
3+
agents:
4+
root:
5+
model: github-copilot/gpt-4o
6+
description: A helpful AI assistant powered by GitHub Copilot
7+
instruction: |
8+
You are a helpful AI assistant.
9+
Be helpful, accurate, and concise in your responses.

pkg/model/provider/provider.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ var Aliases = map[string]Alias{
124124
BaseURL: "https://api.minimax.io/v1",
125125
TokenEnvVar: "MINIMAX_API_KEY",
126126
},
127+
"github-copilot": {
128+
APIType: "openai",
129+
BaseURL: "https://api.githubcopilot.com",
130+
TokenEnvVar: "GITHUB_TOKEN",
131+
},
127132
}
128133

129134
// Provider defines the interface for model providers

pkg/model/provider/provider_test.go

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -29,41 +29,23 @@ func TestCatalogProviders(t *testing.T) {
2929
func TestIsCatalogProvider(t *testing.T) {
3030
t.Parallel()
3131

32-
tests := []struct {
33-
name string
34-
provider string
35-
want bool
36-
}{
37-
// Core providers
38-
{"openai is core", "openai", true},
39-
{"anthropic is core", "anthropic", true},
40-
{"google is core", "google", true},
41-
{"dmr is core", "dmr", true},
42-
{"amazon-bedrock is core", "amazon-bedrock", true},
43-
44-
// Aliases with BaseURL (should be included)
45-
{"mistral has BaseURL", "mistral", true},
46-
{"xai has BaseURL", "xai", true},
47-
{"nebius has BaseURL", "nebius", true},
48-
{"requesty has BaseURL", "requesty", true},
49-
{"ollama has BaseURL", "ollama", true},
50-
{"minimax has BaseURL", "minimax", true},
51-
52-
// Aliases without BaseURL (should be excluded)
53-
{"azure has no BaseURL", "azure", false},
54-
55-
// Unknown providers
56-
{"unknown provider", "unknown", false},
57-
{"cohere not supported", "cohere", false},
32+
// All core providers should be catalog providers
33+
for _, core := range CoreProviders {
34+
assert.True(t, IsCatalogProvider(core), "core provider %s should be a catalog provider", core)
5835
}
5936

60-
for _, tt := range tests {
61-
t.Run(tt.name, func(t *testing.T) {
62-
t.Parallel()
63-
got := IsCatalogProvider(tt.provider)
64-
assert.Equal(t, tt.want, got)
65-
})
37+
// Aliases: catalog if and only if they have a BaseURL
38+
for name, alias := range Aliases {
39+
if alias.BaseURL != "" {
40+
assert.True(t, IsCatalogProvider(name), "alias %s with BaseURL should be a catalog provider", name)
41+
} else {
42+
assert.False(t, IsCatalogProvider(name), "alias %s without BaseURL should NOT be a catalog provider", name)
43+
}
6644
}
45+
46+
// Unknown providers
47+
assert.False(t, IsCatalogProvider("unknown"))
48+
assert.False(t, IsCatalogProvider("cohere"))
6749
}
6850

6951
func TestAllProviders(t *testing.T) {

pkg/tui/dialog/model_picker_test.go

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -348,35 +348,19 @@ func TestValidateCustomModelSpec(t *testing.T) {
348348
func TestIsValidProvider(t *testing.T) {
349349
t.Parallel()
350350

351-
tests := []struct {
352-
provider string
353-
want bool
354-
}{
355-
{"openai", true},
356-
{"anthropic", true},
357-
{"google", true},
358-
{"dmr", true},
359-
{"mistral", true},
360-
{"xai", true},
361-
{"nebius", true},
362-
{"ollama", true},
363-
{"azure", true},
364-
{"requesty", true},
365-
{"minimax", true},
366-
{"OPENAI", true}, // case insensitive
367-
{"OpenAI", true}, // case insensitive
368-
{"unknown", false},
369-
{"foo", false},
370-
{"", false},
351+
// All known providers (core + aliases) should be valid
352+
for _, name := range provider.AllProviders() {
353+
assert.True(t, provider.IsKnownProvider(name), "provider %s should be known", name)
371354
}
372355

373-
for _, tt := range tests {
374-
t.Run(tt.provider, func(t *testing.T) {
375-
t.Parallel()
376-
got := provider.IsKnownProvider(tt.provider)
377-
assert.Equal(t, tt.want, got)
378-
})
379-
}
356+
// Case-insensitive
357+
assert.True(t, provider.IsKnownProvider("OPENAI"))
358+
assert.True(t, provider.IsKnownProvider("OpenAI"))
359+
360+
// Unknown providers
361+
assert.False(t, provider.IsKnownProvider("unknown"))
362+
assert.False(t, provider.IsKnownProvider("foo"))
363+
assert.False(t, provider.IsKnownProvider(""))
380364
}
381365

382366
func TestModelPickerSortingWithCatalog(t *testing.T) {

0 commit comments

Comments
 (0)