Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions coderd/ai_providers.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ func (api *API) aiProvidersCreate(rw http.ResponseWriter, r *http.Request) {
Type: database.AIProviderType(req.Type),
Name: req.Name,
DisplayName: sql.NullString{String: req.DisplayName, Valid: req.DisplayName != ""},
Icon: req.Icon,
Enabled: req.Enabled,
BaseUrl: req.BaseURL,
Settings: settings,
Expand Down Expand Up @@ -363,6 +364,7 @@ func (api *API) aiProvidersUpdate(rw http.ResponseWriter, r *http.Request) {
ID: old.ID,
Type: old.Type,
DisplayName: displayName,
Icon: ptr.NilToDefault(req.Icon, old.Icon),
Enabled: ptr.NilToDefault(req.Enabled, old.Enabled),
BaseUrl: ptr.NilToDefault(req.BaseURL, old.BaseUrl),
Settings: settings,
Expand Down
1 change: 1 addition & 0 deletions coderd/ai_providers_backfill.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func BackfillBedrockProviderType(ctx context.Context, db database.Store, logger
ID: provider.ID,
Type: database.AIProviderTypeBedrock,
DisplayName: provider.DisplayName,
Icon: provider.Icon,
Enabled: provider.Enabled,
BaseUrl: provider.BaseUrl,
Settings: provider.Settings,
Expand Down
1 change: 1 addition & 0 deletions coderd/ai_providers_migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func SeedAIProvidersFromEnv(
Type: dp.Type,
Name: dp.Name,
DisplayName: sql.NullString{String: dp.Name, Valid: true},
Icon: "",
Enabled: true,
BaseUrl: dp.BaseURL,
Settings: settings,
Expand Down
1 change: 1 addition & 0 deletions coderd/ai_providers_migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@ func TestSeedAIProvidersFromEnv(t *testing.T) {
ID: row.ID,
Type: database.AIProviderTypeAnthropic,
DisplayName: row.DisplayName,
Icon: row.Icon,
Enabled: row.Enabled,
BaseUrl: row.BaseUrl,
Settings: row.Settings,
Expand Down
5 changes: 5 additions & 0 deletions coderd/ai_providers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ func TestAIProvidersCRUD(t *testing.T) {
Type: codersdk.AIProviderTypeAnthropic,
Name: "primary-anthropic",
DisplayName: "Primary Anthropic",
Icon: "https://example.com/anthropic.svg",
Enabled: true,
BaseURL: "https://api.anthropic.com/",
Settings: codersdk.AIProviderSettings{
Expand All @@ -105,6 +106,7 @@ func TestAIProvidersCRUD(t *testing.T) {
require.Equal(t, req.Type, created.Type)
require.Equal(t, req.Name, created.Name)
require.Equal(t, req.DisplayName, created.DisplayName)
require.Equal(t, req.Icon, created.Icon)
require.Equal(t, req.Enabled, created.Enabled)
require.Equal(t, req.BaseURL, created.BaseURL)
require.NotNil(t, created.Settings.Bedrock)
Expand All @@ -128,10 +130,12 @@ func TestAIProvidersCRUD(t *testing.T) {

// Update.
newDisplay := "Updated Display"
newIcon := "🦜"
newURL := "https://api.anthropic.com/v1"
disabled := false
updated, err := client.UpdateAIProvider(ctx, created.Name, codersdk.UpdateAIProviderRequest{
DisplayName: &newDisplay,
Icon: &newIcon,
BaseURL: &newURL,
Enabled: &disabled,
Settings: &codersdk.AIProviderSettings{
Expand All @@ -143,6 +147,7 @@ func TestAIProvidersCRUD(t *testing.T) {
})
require.NoError(t, err)
require.Equal(t, newDisplay, updated.DisplayName)
require.Equal(t, newIcon, updated.Icon)
require.Equal(t, newURL, updated.BaseURL)
require.False(t, updated.Enabled)
require.NotNil(t, updated.Settings.Bedrock)
Expand Down
9 changes: 9 additions & 0 deletions coderd/apidoc/docs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions coderd/apidoc/swagger.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions coderd/database/db2sdk/db2sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func AIProvider(row database.AIProvider, keys []database.AIProviderKey) (codersd
Type: codersdk.AIProviderType(row.Type),
Name: row.Name,
DisplayName: display,
Icon: row.Icon,
Enabled: row.Enabled,
BaseURL: row.BaseUrl,
APIKeys: maskAIProviderKeys(keys),
Expand Down
2 changes: 2 additions & 0 deletions coderd/database/dbauthz/dbauthz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6848,6 +6848,7 @@ func (s *MethodTestSuite) TestAIBridge() {
ID: uuid.New(),
Type: database.AIProviderTypeOpenai,
Name: "test-provider",
Icon: "",
Enabled: true,
BaseUrl: "https://api.example.com/",
}
Expand All @@ -6860,6 +6861,7 @@ func (s *MethodTestSuite) TestAIBridge() {
arg := database.UpdateAIProviderParams{
ID: provider.ID,
Type: provider.Type,
Icon: provider.Icon,
Enabled: true,
BaseUrl: "https://api.example.com/",
}
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dbgen/dbgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ func AIProvider(t testing.TB, db database.Store, seed database.AIProvider, munge
Type: provType,
Name: name,
DisplayName: displayName,
Icon: seed.Icon,
Enabled: takeFirst(seed.Enabled, true),
// Use an unsupported scheme so leaked test provider calls fail immediately without retries.
BaseUrl: takeFirst(seed.BaseUrl, "invalid://test.invalid/"),
Expand Down
1 change: 1 addition & 0 deletions coderd/database/dump.sql

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions coderd/database/migrations/000539_ai_provider_icons.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE ai_providers
DROP COLUMN icon;
2 changes: 2 additions & 0 deletions coderd/database/migrations/000539_ai_provider_icons.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE ai_providers
ADD COLUMN icon text NOT NULL DEFAULT '';
1 change: 1 addition & 0 deletions coderd/database/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 29 additions & 15 deletions coderd/database/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions coderd/database/queries/ai_providers.sql
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ INSERT INTO ai_providers (
type,
name,
display_name,
icon,
enabled,
base_url,
settings,
Expand All @@ -54,6 +55,7 @@ INSERT INTO ai_providers (
@type::ai_provider_type,
@name::text,
sqlc.narg('display_name')::text,
@icon::text,
@enabled::boolean,
@base_url::text,
sqlc.narg('settings')::text,
Expand All @@ -68,6 +70,7 @@ UPDATE
SET
type = @type::ai_provider_type,
display_name = sqlc.narg('display_name')::text,
icon = @icon::text,
enabled = @enabled::boolean,
base_url = @base_url::text,
settings = sqlc.narg('settings')::text,
Expand Down
Loading
Loading