refactor!: remove the AI Gateway provider list route (#32651)
Relates to AIGOV-824 Stacked on #32650. `GET /api/v2/ai-gateway/providers` was added in #28966, in September, and first shipped in v2.38.0. It was a fix for the provider filter on the AI Gateway sessions page. That filter called `GET /api/v2/ai/providers`, which only owners could read, so the dropdown was empty for auditors. Rather than open up the provider config, #28966 added a second route that returns just the `name`, `type`, `display_name` and `icon` of every provider, deleted ones included, to anyone who can read sessions, i.e. owners and auditors. Now that `GET /api/v2/ai/providers` answers every signed-in user with those same fields (#32650), the second route has no caller that it alone can serve. Jake, who added it, and I agree that we should remove it rather than keep two routes that list providers, so this PR does that. The one thing only the old route did was return deleted providers, so that sessions and spend recorded under a provider that has since been deleted keep their label. So, `GET /api/v2/ai/providers` gains an `include_deleted` query parameter. A deleted provider can share its name with a live one, so each name appears once, as its live provider if there is one, otherwise the most recently updated deleted one. Unlike the old route, any caller can pass it, so members can now see the names of deleted providers. A deleted provider comes back without its configuration, for owners too. The sessions provider filter and the Spend page now call `GET /api/v2/ai/providers?include_deleted=true`, and show the same thing as before. `codersdk.AIBridgeProvider`, `Client.AIBridgeListProviders` and the `GetAIProviderFilterOptions` query go with the route. ## For changelog - `GET /api/v2/ai-gateway/providers` has been removed (#32651) > `GET /api/v2/ai-gateway/providers` has been removed, along with `codersdk.AIBridgeProvider` and `Client.AIBridgeListProviders` in the Go SDK. It listed providers only for users who can read AI Gateway sessions, i.e. owners and auditors. `GET /api/v2/ai/providers` replaces it, and now answers every signed-in user. Owners still get each provider's full configuration from it, and everyone else gets the same list with an empty `base_url`, an empty `api_keys` array, `null` `settings` and no `status`. > > Migration: Call `GET /api/v2/ai/providers?include_deleted=true` instead. Each provider keeps its `name`, `type`, `display_name` and `icon` fields, and `display_name` now holds the provider name when no display name is set. In the Go SDK, `Client.AIProviders` now takes a `codersdk.AIProvidersFilter`. Set its `IncludeDeleted` field to list deleted providers too. An API token with an allow list needs `ai_provider` in that list to call `GET /api/v2/ai/providers`, where the removed route needed `aibridge_interception`.
This commit is contained in:
1 parent
fd74a160ec
commit
ac92143dbe
34 files changed
+194
-610
No files matched your search
+12
-1
@@ -51,12 +51,23 @@ func aiProvidersHandler(api *API, middlewares ...func(http.Handler) http.Handler
|
||||
// @Security CoderSessionToken
|
||||
// @Produce json
|
||||
// @Tags AI Providers
|
||||
// @Param include_deleted query bool false "Include deleted providers, which are returned without configuration. Each name appears once: its live provider if one exists, otherwise the most recently updated deleted one."
|
||||
// @Success 200 {array} codersdk.AIProvider
|
||||
// @Router /api/v2/ai/providers [get]
|
||||
func (api *API) aiProvidersList(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
summaries, err := api.Database.GetAIProviderSummaries(ctx)
|
||||
parser := httpapi.NewQueryParamParser()
|
||||
includeDeleted := parser.Boolean(r.URL.Query(), false, "include_deleted")
|
||||
if len(parser.Errors) > 0 {
|
||||
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
|
||||
Message: "Invalid query parameters.",
|
||||
Validations: parser.Errors,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
summaries, err := api.Database.GetAIProviderSummaries(ctx, includeDeleted)
|
||||
if dbauthz.IsNotAuthorizedError(err) {
|
||||
httpapi.Forbidden(rw)
|
||||
return
|
||||
|
||||
@@ -180,7 +180,7 @@ func TestAIProvidersBedrockProfileResolution(t *testing.T) {
|
||||
// The write is rejected: a stored ARN with no resolution would be
|
||||
// served as its own identity.
|
||||
//nolint:gocritic // Owner role is the audience for this endpoint.
|
||||
providers, err := client.AIProviders(ctx)
|
||||
providers, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, providers)
|
||||
})
|
||||
|
||||
@@ -15,6 +15,7 @@ import (
|
||||
"github.com/coder/coder/v2/coderd/database"
|
||||
"github.com/coder/coder/v2/coderd/database/db2sdk"
|
||||
"github.com/coder/coder/v2/coderd/database/dbauthz"
|
||||
"github.com/coder/coder/v2/coderd/rbac"
|
||||
"github.com/coder/coder/v2/codersdk"
|
||||
"github.com/coder/coder/v2/testutil"
|
||||
"github.com/coder/serpent"
|
||||
@@ -40,10 +41,10 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
memberClient, _ := coderdtest.CreateAnotherUser(t, client, firstUser.OrganizationID)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
//nolint:gocritic // Owners get the full view, which is built separately.
|
||||
got, err := client.AIProviders(ctx)
|
||||
got, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []codersdk.AIProvider{}, got)
|
||||
got, err = memberClient.AIProviders(ctx)
|
||||
got, err = memberClient.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []codersdk.AIProvider{}, got)
|
||||
})
|
||||
@@ -129,7 +130,7 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
require.Equal(t, created.ID, gotByName.ID)
|
||||
|
||||
// List.
|
||||
list, err := client.AIProviders(ctx)
|
||||
list, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, list, 1)
|
||||
require.Equal(t, created.ID, list[0].ID)
|
||||
@@ -162,7 +163,7 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
require.Equal(t, "anthropic.claude-3-5-sonnet", updated.Settings.Bedrock.Model)
|
||||
|
||||
memberClient, _ := coderdtest.CreateAnotherUser(t, client, firstUser.OrganizationID)
|
||||
memberList, err := memberClient.AIProviders(ctx)
|
||||
memberList, err := memberClient.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
withoutConfig := updated
|
||||
withoutConfig.BaseURL = ""
|
||||
@@ -181,7 +182,7 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
require.Contains(t, sdkErr.Message, "Resource not found")
|
||||
|
||||
// List excludes the deleted provider.
|
||||
list, err = client.AIProviders(ctx)
|
||||
list, err = client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Empty(t, list)
|
||||
|
||||
@@ -509,7 +510,7 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
list, err := client.AIProviders(ctx)
|
||||
list, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, list, 1)
|
||||
require.Equal(t, live.ID, list[0].ID)
|
||||
@@ -517,6 +518,43 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
require.Equal(t, live.APIKeys[0].ID, list[0].APIKeys[0].ID)
|
||||
})
|
||||
|
||||
t.Run("ListIncludeDeleted", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ownerClient := coderdtest.New(t, nil)
|
||||
firstUser := coderdtest.CreateFirstUser(t, ownerClient)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
create := func(name string) codersdk.AIProvider {
|
||||
//nolint:gocritic // Only owners can create providers.
|
||||
provider, err := ownerClient.CreateAIProvider(ctx, codersdk.CreateAIProviderRequest{
|
||||
Type: codersdk.AIProviderTypeOpenAI,
|
||||
Name: name,
|
||||
Enabled: true,
|
||||
BaseURL: "https://api.openai.com/v1",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
return provider
|
||||
}
|
||||
gone := create("list-gone")
|
||||
require.NoError(t, ownerClient.DeleteAIProvider(ctx, gone.ID.String()))
|
||||
reusedBefore := create("list-reused")
|
||||
require.NoError(t, ownerClient.DeleteAIProvider(ctx, reusedBefore.ID.String()))
|
||||
reused := create("list-reused")
|
||||
|
||||
auditorClient, _ := coderdtest.CreateAnotherUser(t, ownerClient, firstUser.OrganizationID, rbac.RoleAuditor())
|
||||
for _, client := range []*codersdk.Client{ownerClient, auditorClient} {
|
||||
got, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{IncludeDeleted: true})
|
||||
require.NoError(t, err)
|
||||
|
||||
require.Len(t, got, 2)
|
||||
require.Equal(t, gone.ID, got[0].ID)
|
||||
require.True(t, got[0].Deleted)
|
||||
require.Empty(t, got[0].BaseURL)
|
||||
require.Equal(t, reused.ID, got[1].ID)
|
||||
require.False(t, got[1].Deleted)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("LookupInvalidName", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
client := coderdtest.New(t, nil)
|
||||
@@ -547,7 +585,7 @@ func TestAIProvidersCRUD(t *testing.T) {
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
anon := codersdk.New(ownerClient.URL)
|
||||
_, err := anon.AIProviders(ctx)
|
||||
_, err := anon.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.Error(t, err)
|
||||
var sdkErr *codersdk.Error
|
||||
require.ErrorAs(t, err, &sdkErr)
|
||||
@@ -2233,7 +2271,7 @@ func TestAIProviderHostnameCollisionWarnings(t *testing.T) {
|
||||
require.Nil(t, winner.Status, "first provider in database order should not get a warning on get")
|
||||
|
||||
//nolint:gocritic // Owner role is the audience for this endpoint.
|
||||
providers, err := client.AIProviders(ctx)
|
||||
providers, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
require.Len(t, providers, 2)
|
||||
var firstListed, secondListed codersdk.AIProvider
|
||||
@@ -2349,7 +2387,7 @@ func TestAIProviderHostnameCollisionWarnings(t *testing.T) {
|
||||
require.Nil(t, second.Status)
|
||||
|
||||
//nolint:gocritic // Owner role is the audience for this endpoint.
|
||||
providers, err := client.AIProviders(ctx)
|
||||
providers, err := client.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
for _, provider := range providers {
|
||||
require.Nil(t, provider.Status)
|
||||
|
||||
Generated
+11
-45
@@ -2722,34 +2722,6 @@ const docTemplate = `{
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/ai-gateway/providers": {
|
||||
"get": {
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"tags": [
|
||||
"AI Gateway"
|
||||
],
|
||||
"summary": "List AI Gateway providers",
|
||||
"operationId": "list-ai-gateway-providers",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeProvider"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"CoderSessionToken": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/ai-gateway/serve": {
|
||||
"get": {
|
||||
"tags": [
|
||||
@@ -2885,6 +2857,14 @@ const docTemplate = `{
|
||||
],
|
||||
"summary": "List AI providers",
|
||||
"operationId": "list-ai-providers",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Include deleted providers, which are returned without configuration. Each name appears once: its live provider if one exists, otherwise the most recently updated deleted one.",
|
||||
"name": "include_deleted",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
@@ -20167,23 +20147,6 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProvider": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"$ref": "#/definitions/codersdk.AIProviderType"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -20749,6 +20712,9 @@ const docTemplate = `{
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"deleted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
Generated
+11
-41
@@ -2461,30 +2461,6 @@
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/ai-gateway/providers": {
|
||||
"get": {
|
||||
"produces": ["application/json"],
|
||||
"tags": ["AI Gateway"],
|
||||
"summary": "List AI Gateway providers",
|
||||
"operationId": "list-ai-gateway-providers",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/codersdk.AIBridgeProvider"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"security": [
|
||||
{
|
||||
"CoderSessionToken": []
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"/api/v2/ai-gateway/serve": {
|
||||
"get": {
|
||||
"tags": ["Enterprise"],
|
||||
@@ -2606,6 +2582,14 @@
|
||||
"tags": ["AI Providers"],
|
||||
"summary": "List AI providers",
|
||||
"operationId": "list-ai-providers",
|
||||
"parameters": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"description": "Include deleted providers, which are returned without configuration. Each name appears once: its live provider if one exists, otherwise the most recently updated deleted one.",
|
||||
"name": "include_deleted",
|
||||
"in": "query"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
@@ -18025,23 +18009,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProvider": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"icon": {
|
||||
"type": "string"
|
||||
},
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": {
|
||||
"$ref": "#/definitions/codersdk.AIProviderType"
|
||||
}
|
||||
}
|
||||
},
|
||||
"codersdk.AIBridgeProxyConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -18599,6 +18566,9 @@
|
||||
"type": "string",
|
||||
"format": "date-time"
|
||||
},
|
||||
"deleted": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -58,6 +58,7 @@ func AIProvider(row database.AIProvider, keys []database.AIProviderKey) (codersd
|
||||
DisplayName: aiProviderDisplayName(row.Name, row.DisplayName),
|
||||
Icon: row.Icon,
|
||||
Enabled: row.Enabled,
|
||||
Deleted: row.Deleted,
|
||||
BaseURL: row.BaseUrl,
|
||||
APIKeys: maskAIProviderKeys(keys),
|
||||
CreatedAt: row.CreatedAt,
|
||||
@@ -81,6 +82,7 @@ func AIProviderFromSummary(row database.GetAIProviderSummariesRow) codersdk.AIPr
|
||||
DisplayName: aiProviderDisplayName(row.Name, row.DisplayName),
|
||||
Icon: row.Icon,
|
||||
Enabled: row.Enabled,
|
||||
Deleted: row.Deleted,
|
||||
APIKeys: []codersdk.AIProviderKey{},
|
||||
CreatedAt: row.CreatedAt,
|
||||
UpdatedAt: row.UpdatedAt,
|
||||
|
||||
@@ -3114,18 +3114,6 @@ func (q *querier) GetAIProviderByName(ctx context.Context, name string) (databas
|
||||
return q.db.GetAIProviderByName(ctx, name)
|
||||
}
|
||||
|
||||
func (q *querier) GetAIProviderFilterOptions(ctx context.Context) ([]database.GetAIProviderFilterOptionsRow, error) {
|
||||
// This query returns display metadata only (name, type, display name,
|
||||
// icon), never configuration or secrets. It exists so callers who can
|
||||
// read AI Gateway interceptions deployment-wide (owners and auditors)
|
||||
// can label the provider_name values they already see on those
|
||||
// interceptions, so it is gated on interception read, not AIProvider read.
|
||||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceAibridgeInterception); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q.db.GetAIProviderFilterOptions(ctx)
|
||||
}
|
||||
|
||||
func (q *querier) GetAIProviderKeyByID(ctx context.Context, id uuid.UUID) (database.AIProviderKey, error) {
|
||||
if err := q.authorizeContext(ctx, policy.ActionReadSecret, rbac.ResourceAIProvider); err != nil {
|
||||
return database.AIProviderKey{}, err
|
||||
@@ -3165,11 +3153,11 @@ func (q *querier) GetAIProviderKeysByProviderIDs(ctx context.Context, providerID
|
||||
return q.db.GetAIProviderKeysByProviderIDs(ctx, providerIDs)
|
||||
}
|
||||
|
||||
func (q *querier) GetAIProviderSummaries(ctx context.Context) ([]database.GetAIProviderSummariesRow, error) {
|
||||
func (q *querier) GetAIProviderSummaries(ctx context.Context, includeDeleted bool) ([]database.GetAIProviderSummariesRow, error) {
|
||||
if err := q.authorizeContext(ctx, policy.ActionRead, rbac.ResourceAIProvider); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q.db.GetAIProviderSummaries(ctx)
|
||||
return q.db.GetAIProviderSummaries(ctx, includeDeleted)
|
||||
}
|
||||
|
||||
func (q *querier) GetAIProviders(ctx context.Context, arg database.GetAIProvidersParams) ([]database.AIProvider, error) {
|
||||
|
||||
@@ -7985,15 +7985,8 @@ func (s *MethodTestSuite) TestAIBridge() {
|
||||
s.Run("GetAIProviderSummaries", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
|
||||
summaryA := testutil.Fake(s.T(), faker, database.GetAIProviderSummariesRow{})
|
||||
summaryB := testutil.Fake(s.T(), faker, database.GetAIProviderSummariesRow{})
|
||||
dbm.EXPECT().GetAIProviderSummaries(gomock.Any()).Return([]database.GetAIProviderSummariesRow{summaryA, summaryB}, nil).AnyTimes()
|
||||
check.Args().Asserts(rbac.ResourceAIProvider, policy.ActionRead).Returns([]database.GetAIProviderSummariesRow{summaryA, summaryB})
|
||||
}))
|
||||
s.Run("GetAIProviderFilterOptions", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
|
||||
options := []database.GetAIProviderFilterOptionsRow{
|
||||
testutil.Fake(s.T(), faker, database.GetAIProviderFilterOptionsRow{}),
|
||||
}
|
||||
dbm.EXPECT().GetAIProviderFilterOptions(gomock.Any()).Return(options, nil).AnyTimes()
|
||||
check.Args().Asserts(rbac.ResourceAibridgeInterception, policy.ActionRead).Returns(options)
|
||||
dbm.EXPECT().GetAIProviderSummaries(gomock.Any(), false).Return([]database.GetAIProviderSummariesRow{summaryA, summaryB}, nil).AnyTimes()
|
||||
check.Args(false).Asserts(rbac.ResourceAIProvider, policy.ActionRead).Returns([]database.GetAIProviderSummariesRow{summaryA, summaryB})
|
||||
}))
|
||||
s.Run("GetAIProviders", s.Mocked(func(dbm *dbmock.MockStore, faker *gofakeit.Faker, check *expects) {
|
||||
providerA := testutil.Fake(s.T(), faker, database.AIProvider{})
|
||||
|
||||
+2
-10
@@ -1280,14 +1280,6 @@ func (m queryMetricsStore) GetAIProviderByName(ctx context.Context, name string)
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m queryMetricsStore) GetAIProviderFilterOptions(ctx context.Context) ([]database.GetAIProviderFilterOptionsRow, error) {
|
||||
start := time.Now()
|
||||
r0, r1 := m.s.GetAIProviderFilterOptions(ctx)
|
||||
m.queryLatencies.WithLabelValues("GetAIProviderFilterOptions").Observe(time.Since(start).Seconds())
|
||||
m.queryCounts.WithLabelValues(httpmw.ExtractHTTPRoute(ctx), httpmw.ExtractHTTPMethod(ctx), "GetAIProviderFilterOptions").Inc()
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m queryMetricsStore) GetAIProviderKeyByID(ctx context.Context, id uuid.UUID) (database.AIProviderKey, error) {
|
||||
start := time.Now()
|
||||
r0, r1 := m.s.GetAIProviderKeyByID(ctx, id)
|
||||
@@ -1328,9 +1320,9 @@ func (m queryMetricsStore) GetAIProviderKeysByProviderIDs(ctx context.Context, p
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
func (m queryMetricsStore) GetAIProviderSummaries(ctx context.Context) ([]database.GetAIProviderSummariesRow, error) {
|
||||
func (m queryMetricsStore) GetAIProviderSummaries(ctx context.Context, includeDeleted bool) ([]database.GetAIProviderSummariesRow, error) {
|
||||
start := time.Now()
|
||||
r0, r1 := m.s.GetAIProviderSummaries(ctx)
|
||||
r0, r1 := m.s.GetAIProviderSummaries(ctx, includeDeleted)
|
||||
m.queryLatencies.WithLabelValues("GetAIProviderSummaries").Observe(time.Since(start).Seconds())
|
||||
m.queryCounts.WithLabelValues(httpmw.ExtractHTTPRoute(ctx), httpmw.ExtractHTTPMethod(ctx), "GetAIProviderSummaries").Inc()
|
||||
return r0, r1
|
||||
|
||||
Generated
+4
-19
@@ -2245,21 +2245,6 @@ func (mr *MockStoreMockRecorder) GetAIProviderByName(ctx, name any) *gomock.Call
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAIProviderByName", reflect.TypeOf((*MockStore)(nil).GetAIProviderByName), ctx, name)
|
||||
}
|
||||
|
||||
// GetAIProviderFilterOptions mocks base method.
|
||||
func (m *MockStore) GetAIProviderFilterOptions(ctx context.Context) ([]database.GetAIProviderFilterOptionsRow, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAIProviderFilterOptions", ctx)
|
||||
ret0, _ := ret[0].([]database.GetAIProviderFilterOptionsRow)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAIProviderFilterOptions indicates an expected call of GetAIProviderFilterOptions.
|
||||
func (mr *MockStoreMockRecorder) GetAIProviderFilterOptions(ctx any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAIProviderFilterOptions", reflect.TypeOf((*MockStore)(nil).GetAIProviderFilterOptions), ctx)
|
||||
}
|
||||
|
||||
// GetAIProviderKeyByID mocks base method.
|
||||
func (m *MockStore) GetAIProviderKeyByID(ctx context.Context, id uuid.UUID) (database.AIProviderKey, error) {
|
||||
m.ctrl.T.Helper()
|
||||
@@ -2336,18 +2321,18 @@ func (mr *MockStoreMockRecorder) GetAIProviderKeysByProviderIDs(ctx, providerIds
|
||||
}
|
||||
|
||||
// GetAIProviderSummaries mocks base method.
|
||||
func (m *MockStore) GetAIProviderSummaries(ctx context.Context) ([]database.GetAIProviderSummariesRow, error) {
|
||||
func (m *MockStore) GetAIProviderSummaries(ctx context.Context, includeDeleted bool) ([]database.GetAIProviderSummariesRow, error) {
|
||||
m.ctrl.T.Helper()
|
||||
ret := m.ctrl.Call(m, "GetAIProviderSummaries", ctx)
|
||||
ret := m.ctrl.Call(m, "GetAIProviderSummaries", ctx, includeDeleted)
|
||||
ret0, _ := ret[0].([]database.GetAIProviderSummariesRow)
|
||||
ret1, _ := ret[1].(error)
|
||||
return ret0, ret1
|
||||
}
|
||||
|
||||
// GetAIProviderSummaries indicates an expected call of GetAIProviderSummaries.
|
||||
func (mr *MockStoreMockRecorder) GetAIProviderSummaries(ctx any) *gomock.Call {
|
||||
func (mr *MockStoreMockRecorder) GetAIProviderSummaries(ctx, includeDeleted any) *gomock.Call {
|
||||
mr.mock.ctrl.T.Helper()
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAIProviderSummaries", reflect.TypeOf((*MockStore)(nil).GetAIProviderSummaries), ctx)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAIProviderSummaries", reflect.TypeOf((*MockStore)(nil).GetAIProviderSummaries), ctx, includeDeleted)
|
||||
}
|
||||
|
||||
// GetAIProviders mocks base method.
|
||||
|
||||
Generated
+1
-6
@@ -376,11 +376,6 @@ type sqlcQuerier interface {
|
||||
// between validation and writing the model config reference.
|
||||
GetAIProviderByIDForReferenceLock(ctx context.Context, id uuid.UUID) (AIProvider, error)
|
||||
GetAIProviderByName(ctx context.Context, name string) (AIProvider, error)
|
||||
// Returns the display metadata AI Gateway session viewers need to filter
|
||||
// interceptions by provider_name. Soft-deleted and disabled rows are
|
||||
// included because interceptions keep referencing them. When a name has
|
||||
// been reused, the live row wins so current metadata is shown.
|
||||
GetAIProviderFilterOptions(ctx context.Context) ([]GetAIProviderFilterOptionsRow, error)
|
||||
GetAIProviderKeyByID(ctx context.Context, id uuid.UUID) (AIProviderKey, error)
|
||||
// Returns the provider IDs that have at least one provider-scoped key.
|
||||
GetAIProviderKeyPresence(ctx context.Context, providerIds []uuid.UUID) ([]uuid.UUID, error)
|
||||
@@ -398,7 +393,7 @@ type sqlcQuerier interface {
|
||||
// Returns all keys for the requested providers, ordered by provider then created_at ASC
|
||||
// so callers can select the oldest non-empty key per provider without issuing N queries.
|
||||
GetAIProviderKeysByProviderIDs(ctx context.Context, providerIds []uuid.UUID) ([]AIProviderKey, error)
|
||||
GetAIProviderSummaries(ctx context.Context) ([]GetAIProviderSummariesRow, error)
|
||||
GetAIProviderSummaries(ctx context.Context, includeDeleted bool) ([]GetAIProviderSummariesRow, error)
|
||||
// Returns AI provider rows. Soft-deleted and disabled rows are excluded
|
||||
// unless include_deleted or include_disabled is set.
|
||||
GetAIProviders(ctx context.Context, arg GetAIProvidersParams) ([]AIProvider, error)
|
||||
|
||||
Generated
+10
-58
@@ -660,75 +660,25 @@ func (q *sqlQuerier) GetAIProviderByName(ctx context.Context, name string) (AIPr
|
||||
return i, err
|
||||
}
|
||||
|
||||
const getAIProviderFilterOptions = `-- name: GetAIProviderFilterOptions :many
|
||||
SELECT DISTINCT ON (name)
|
||||
name,
|
||||
type,
|
||||
display_name,
|
||||
icon
|
||||
FROM
|
||||
ai_providers
|
||||
ORDER BY
|
||||
name ASC,
|
||||
deleted ASC,
|
||||
updated_at DESC
|
||||
`
|
||||
|
||||
type GetAIProviderFilterOptionsRow struct {
|
||||
Name string `db:"name" json:"name"`
|
||||
Type AIProviderType `db:"type" json:"type"`
|
||||
DisplayName sql.NullString `db:"display_name" json:"display_name"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
}
|
||||
|
||||
// Returns the display metadata AI Gateway session viewers need to filter
|
||||
// interceptions by provider_name. Soft-deleted and disabled rows are
|
||||
// included because interceptions keep referencing them. When a name has
|
||||
// been reused, the live row wins so current metadata is shown.
|
||||
func (q *sqlQuerier) GetAIProviderFilterOptions(ctx context.Context) ([]GetAIProviderFilterOptionsRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAIProviderFilterOptions)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []GetAIProviderFilterOptionsRow
|
||||
for rows.Next() {
|
||||
var i GetAIProviderFilterOptionsRow
|
||||
if err := rows.Scan(
|
||||
&i.Name,
|
||||
&i.Type,
|
||||
&i.DisplayName,
|
||||
&i.Icon,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
const getAIProviderSummaries = `-- name: GetAIProviderSummaries :many
|
||||
SELECT
|
||||
SELECT DISTINCT ON (name)
|
||||
id,
|
||||
type,
|
||||
name,
|
||||
display_name,
|
||||
icon,
|
||||
enabled,
|
||||
deleted,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
ai_providers
|
||||
WHERE
|
||||
NOT deleted
|
||||
$1::boolean OR NOT deleted
|
||||
ORDER BY
|
||||
name ASC
|
||||
name ASC,
|
||||
deleted ASC,
|
||||
updated_at DESC
|
||||
`
|
||||
|
||||
type GetAIProviderSummariesRow struct {
|
||||
@@ -738,12 +688,13 @@ type GetAIProviderSummariesRow struct {
|
||||
DisplayName sql.NullString `db:"display_name" json:"display_name"`
|
||||
Icon string `db:"icon" json:"icon"`
|
||||
Enabled bool `db:"enabled" json:"enabled"`
|
||||
Deleted bool `db:"deleted" json:"deleted"`
|
||||
CreatedAt time.Time `db:"created_at" json:"created_at"`
|
||||
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) GetAIProviderSummaries(ctx context.Context) ([]GetAIProviderSummariesRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAIProviderSummaries)
|
||||
func (q *sqlQuerier) GetAIProviderSummaries(ctx context.Context, includeDeleted bool) ([]GetAIProviderSummariesRow, error) {
|
||||
rows, err := q.db.QueryContext(ctx, getAIProviderSummaries, includeDeleted)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -758,6 +709,7 @@ func (q *sqlQuerier) GetAIProviderSummaries(ctx context.Context) ([]GetAIProvide
|
||||
&i.DisplayName,
|
||||
&i.Icon,
|
||||
&i.Enabled,
|
||||
&i.Deleted,
|
||||
&i.CreatedAt,
|
||||
&i.UpdatedAt,
|
||||
); err != nil {
|
||||
|
||||
@@ -40,34 +40,20 @@ ORDER BY
|
||||
name ASC;
|
||||
|
||||
-- name: GetAIProviderSummaries :many
|
||||
SELECT
|
||||
SELECT DISTINCT ON (name)
|
||||
id,
|
||||
type,
|
||||
name,
|
||||
display_name,
|
||||
icon,
|
||||
enabled,
|
||||
deleted,
|
||||
created_at,
|
||||
updated_at
|
||||
FROM
|
||||
ai_providers
|
||||
WHERE
|
||||
NOT deleted
|
||||
ORDER BY
|
||||
name ASC;
|
||||
|
||||
-- name: GetAIProviderFilterOptions :many
|
||||
-- Returns the display metadata AI Gateway session viewers need to filter
|
||||
-- interceptions by provider_name. Soft-deleted and disabled rows are
|
||||
-- included because interceptions keep referencing them. When a name has
|
||||
-- been reused, the live row wins so current metadata is shown.
|
||||
SELECT DISTINCT ON (name)
|
||||
name,
|
||||
type,
|
||||
display_name,
|
||||
icon
|
||||
FROM
|
||||
ai_providers
|
||||
@include_deleted::boolean OR NOT deleted
|
||||
ORDER BY
|
||||
name ASC,
|
||||
deleted ASC,
|
||||
|
||||
+3
-2
@@ -8214,6 +8214,7 @@ func convertAIProviderSummary(provider database.GetAIProviderSummariesRow) coder
|
||||
DisplayName: displayName,
|
||||
Icon: provider.Icon,
|
||||
Enabled: provider.Enabled,
|
||||
Deleted: provider.Deleted,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8230,7 +8231,7 @@ func (api *API) listUserAIProviderKeyConfigs(rw http.ResponseWriter, r *http.Req
|
||||
targetUser := httpmw.UserParam(r)
|
||||
//nolint:gocritic // Users can list limited provider metadata to manage their own AI provider keys.
|
||||
metadataCtx := dbauthz.AsAIProviderMetadataReader(ctx)
|
||||
providers, err := api.Database.GetAIProviderSummaries(metadataCtx)
|
||||
providers, err := api.Database.GetAIProviderSummaries(metadataCtx, false)
|
||||
if err != nil {
|
||||
api.Logger.Error(ctx, "failed to list user AI provider configs", slog.Error(err), slog.F("user_id", targetUser.ID))
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{Message: "Failed to list AI providers."})
|
||||
@@ -8312,7 +8313,7 @@ func (api *API) upsertUserAIProviderKey(rw http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
//nolint:gocritic // Users can attach their own key to an enabled provider without AI provider admin permissions.
|
||||
metadataCtx := dbauthz.AsAIProviderMetadataReader(ctx)
|
||||
providers, err := api.Database.GetAIProviderSummaries(metadataCtx)
|
||||
providers, err := api.Database.GetAIProviderSummaries(metadataCtx, false)
|
||||
if err != nil {
|
||||
api.Logger.Error(ctx, "failed to get AI provider", slog.Error(err), slog.F("ai_provider_id", providerID))
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{Message: "Failed to get AI provider."})
|
||||
|
||||
@@ -15374,7 +15374,7 @@ func enableUserChatProviderKey(
|
||||
t.Helper()
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
providers, err := adminClient.AIProviders(ctx)
|
||||
providers, err := adminClient.AIProviders(ctx, codersdk.AIProvidersFilter{})
|
||||
require.NoError(t, err)
|
||||
|
||||
var provider codersdk.AIProvider
|
||||
|
||||
@@ -580,32 +580,6 @@ func (c *Client) AIBridgeListClients(ctx context.Context) ([]string, error) {
|
||||
return clients, ReadBodyAsJSON(res, &clients)
|
||||
}
|
||||
|
||||
// AIBridgeProvider is the display metadata for a configured AI provider,
|
||||
// used to filter AI Gateway sessions by provider_name. It carries no
|
||||
// configuration so it can be served to anyone who can read sessions.
|
||||
type AIBridgeProvider struct {
|
||||
Name string `json:"name"`
|
||||
Type AIProviderType `json:"type"`
|
||||
DisplayName string `json:"display_name"`
|
||||
Icon string `json:"icon"`
|
||||
}
|
||||
|
||||
// AIBridgeListProviders returns the providers available for filtering AI
|
||||
// Gateway sessions, including disabled and deleted ones that past sessions
|
||||
// may still reference.
|
||||
func (c *Client) AIBridgeListProviders(ctx context.Context) ([]AIBridgeProvider, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/ai-gateway/providers", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer res.Body.Close()
|
||||
if res.StatusCode != http.StatusOK {
|
||||
return nil, ReadBodyAsError(res)
|
||||
}
|
||||
var providers []AIBridgeProvider
|
||||
return providers, ReadBodyAsJSON(res, &providers)
|
||||
}
|
||||
|
||||
// AIGatewayRetention is how long AI Gateway data, such as interceptions and
|
||||
// token usage, is kept before it is purged.
|
||||
type AIGatewayRetention struct {
|
||||
|
||||
+10
-4
@@ -8,6 +8,7 @@ import (
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -245,6 +246,7 @@ type AIProvider struct {
|
||||
DisplayName string `json:"display_name"`
|
||||
Icon string `json:"icon"`
|
||||
Enabled bool `json:"enabled"`
|
||||
Deleted bool `json:"deleted"`
|
||||
BaseURL string `json:"base_url"`
|
||||
APIKeys []AIProviderKey `json:"api_keys"`
|
||||
Settings AIProviderSettings `json:"settings"`
|
||||
@@ -674,10 +676,14 @@ func validateAIProviderKeyMutations(muts []AIProviderKeyMutation) []ValidationEr
|
||||
return validations
|
||||
}
|
||||
|
||||
// AIProviders lists all (non-deleted) AI providers. Callers who cannot
|
||||
// read provider configuration get rows without base URL, keys or settings.
|
||||
func (c *Client) AIProviders(ctx context.Context) ([]AIProvider, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/ai/providers", nil)
|
||||
type AIProvidersFilter struct {
|
||||
IncludeDeleted bool `json:"include_deleted,omitempty"`
|
||||
}
|
||||
|
||||
// AIProviders lists providers, omitting configuration the caller cannot read.
|
||||
func (c *Client) AIProviders(ctx context.Context, filter AIProvidersFilter) ([]AIProvider, error) {
|
||||
res, err := c.Request(ctx, http.MethodGet, "/api/v2/ai/providers", nil,
|
||||
WithQueryParam("include_deleted", strconv.FormatBool(filter.IncludeDeleted)))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Generated
-54
@@ -82,60 +82,6 @@ Alias: also available at /api/v2/aibridge/models for backward compatibility.
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
## List AI Gateway providers
|
||||
|
||||
### Code samples
|
||||
|
||||
```sh
|
||||
# Example request using curl
|
||||
curl -X GET http://coder-server:8080/api/v2/ai-gateway/providers \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Coder-Session-Token: API_KEY'
|
||||
```
|
||||
|
||||
`GET /api/v2/ai-gateway/providers`
|
||||
|
||||
### Example responses
|
||||
|
||||
> 200 Response
|
||||
|
||||
```json
|
||||
[
|
||||
{
|
||||
"display_name": "string",
|
||||
"icon": "string",
|
||||
"name": "string",
|
||||
"type": "openai"
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### Responses
|
||||
|
||||
| Status | Meaning | Description | Schema |
|
||||
|--------|---------------------------------------------------------|-------------|---------------------------------------------------------------------------|
|
||||
| 200 | [OK](https://tools.ietf.org/html/rfc7231#section-6.3.1) | OK | array of [codersdk.AIBridgeProvider](schemas.md#codersdkaibridgeprovider) |
|
||||
|
||||
<h3 id="list-ai-gateway-providers-responseschema">Response Schema</h3>
|
||||
|
||||
Status Code **200**
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|------------------|--------------------------------------------------------------|----------|--------------|-------------|
|
||||
| `[array item]` | array | false | | |
|
||||
| `» display_name` | string | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
| `» name` | string | false | | |
|
||||
| `» type` | [codersdk.AIProviderType](schemas.md#codersdkaiprovidertype) | false | | |
|
||||
|
||||
#### Enumerated Values
|
||||
|
||||
| Property | Value(s) |
|
||||
|----------|---------------------------------------------------------------------------------------------------------|
|
||||
| `type` | `anthropic`, `azure`, `bedrock`, `copilot`, `google`, `openai`, `openai-compat`, `openrouter`, `vercel` |
|
||||
|
||||
To perform this operation, you must be authenticated. [Learn more](authentication.md).
|
||||
|
||||
## List AI Gateway sessions
|
||||
|
||||
### Code samples
|
||||
|
||||
Generated
+11
@@ -20,6 +20,12 @@ curl -X GET http://coder-server:8080/api/v2/ai/providers \
|
||||
|
||||
Lists AI providers, including disabled ones. The `base_url`, `api_keys`, `settings`, and `status` fields are empty when the caller can't read AI provider configuration.
|
||||
|
||||
### Parameters
|
||||
|
||||
| Name | In | Type | Required | Description |
|
||||
|-------------------|-------|---------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||
| `include_deleted` | query | boolean | false | Include deleted providers, which are returned without configuration. Each name appears once: its live provider if one exists, otherwise the most recently updated deleted one. |
|
||||
|
||||
### Example responses
|
||||
|
||||
> 200 Response
|
||||
@@ -36,6 +42,7 @@ Lists AI providers, including disabled ones. The `base_url`, `api_keys`, `settin
|
||||
],
|
||||
"base_url": "string",
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"deleted": true,
|
||||
"display_name": "string",
|
||||
"enabled": true,
|
||||
"icon": "string",
|
||||
@@ -72,6 +79,7 @@ Status Code **200**
|
||||
| `»» masked` | string | false | | |
|
||||
| `» base_url` | string | false | | |
|
||||
| `» created_at` | string(date-time) | false | | |
|
||||
| `» deleted` | boolean | false | | |
|
||||
| `» display_name` | string | false | | |
|
||||
| `» enabled` | boolean | false | | |
|
||||
| `» icon` | string | false | | |
|
||||
@@ -143,6 +151,7 @@ curl -X POST http://coder-server:8080/api/v2/ai/providers \
|
||||
],
|
||||
"base_url": "string",
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"deleted": true,
|
||||
"display_name": "string",
|
||||
"enabled": true,
|
||||
"icon": "string",
|
||||
@@ -201,6 +210,7 @@ curl -X GET http://coder-server:8080/api/v2/ai/providers/{idOrName} \
|
||||
],
|
||||
"base_url": "string",
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"deleted": true,
|
||||
"display_name": "string",
|
||||
"enabled": true,
|
||||
"icon": "string",
|
||||
@@ -305,6 +315,7 @@ curl -X PATCH http://coder-server:8080/api/v2/ai/providers/{idOrName} \
|
||||
],
|
||||
"base_url": "string",
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"deleted": true,
|
||||
"display_name": "string",
|
||||
"enabled": true,
|
||||
"icon": "string",
|
||||
|
||||
Generated
+2
-20
@@ -595,26 +595,6 @@ title: Schemas
|
||||
| `model` | string | false | | Model is the priced model, either the requested model or the model reported by the provider. |
|
||||
| `output_price` | integer | false | | |
|
||||
|
||||
## codersdk.AIBridgeProvider
|
||||
|
||||
```json
|
||||
{
|
||||
"display_name": "string",
|
||||
"icon": "string",
|
||||
"name": "string",
|
||||
"type": "openai"
|
||||
}
|
||||
```
|
||||
|
||||
### Properties
|
||||
|
||||
| Name | Type | Required | Restrictions | Description |
|
||||
|----------------|----------------------------------------------------|----------|--------------|-------------|
|
||||
| `display_name` | string | false | | |
|
||||
| `icon` | string | false | | |
|
||||
| `name` | string | false | | |
|
||||
| `type` | [codersdk.AIProviderType](#codersdkaiprovidertype) | false | | |
|
||||
|
||||
## codersdk.AIBridgeProxyConfig
|
||||
|
||||
```json
|
||||
@@ -1429,6 +1409,7 @@ title: Schemas
|
||||
],
|
||||
"base_url": "string",
|
||||
"created_at": "2019-08-24T14:15:22Z",
|
||||
"deleted": true,
|
||||
"display_name": "string",
|
||||
"enabled": true,
|
||||
"icon": "string",
|
||||
@@ -1452,6 +1433,7 @@ title: Schemas
|
||||
| `api_keys` | array of [codersdk.AIProviderKey](#codersdkaiproviderkey) | false | | |
|
||||
| `base_url` | string | false | | |
|
||||
| `created_at` | string | false | | |
|
||||
| `deleted` | boolean | false | | |
|
||||
| `display_name` | string | false | | |
|
||||
| `enabled` | boolean | false | | |
|
||||
| `icon` | string | false | | |
|
||||
|
||||
@@ -644,48 +644,6 @@ func (api *API) aiBridgeListClients(rw http.ResponseWriter, r *http.Request) {
|
||||
httpapi.Write(ctx, rw, http.StatusOK, clients)
|
||||
}
|
||||
|
||||
// aiBridgeListProviders returns the provider metadata used to filter AI
|
||||
// Gateway sessions by provider_name. It reads ai_providers rather than
|
||||
// scanning interceptions so the response stays cheap on large deployments,
|
||||
// and is authorized on interception read (see dbauthz), so session viewers
|
||||
// get labels and icons without access to provider configuration.
|
||||
//
|
||||
// @Summary List AI Gateway providers
|
||||
// @ID list-ai-gateway-providers
|
||||
// @Security CoderSessionToken
|
||||
// @Produce json
|
||||
// @Tags AI Gateway
|
||||
// @Success 200 {array} codersdk.AIBridgeProvider
|
||||
// @Router /api/v2/ai-gateway/providers [get]
|
||||
func (api *API) aiBridgeListProviders(rw http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
rows, err := api.Database.GetAIProviderFilterOptions(ctx)
|
||||
if httpapi.Is404Error(err) {
|
||||
httpapi.ResourceNotFound(rw)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
|
||||
Message: "Internal error getting AI Gateway providers.",
|
||||
Detail: err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
providers := make([]codersdk.AIBridgeProvider, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
providers = append(providers, codersdk.AIBridgeProvider{
|
||||
Name: row.Name,
|
||||
Type: codersdk.AIProviderType(row.Type),
|
||||
DisplayName: row.DisplayName.String,
|
||||
Icon: row.Icon,
|
||||
})
|
||||
}
|
||||
|
||||
httpapi.Write(ctx, rw, http.StatusOK, providers)
|
||||
}
|
||||
|
||||
// aiGatewayRetention returns the AI Gateway data retention. It holds no usage
|
||||
// data, so any authenticated user can read it when the AI Gateway feature is
|
||||
// enabled, without access to the deployment config.
|
||||
|
||||
@@ -1681,166 +1681,6 @@ func TestAIBridgeListClients(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestAIBridgeListProviders(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
t.Run("RequiresLicenseFeature", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
dv := coderdtest.DeploymentValues(t)
|
||||
client, _ := coderdenttest.New(t, &coderdenttest.Options{
|
||||
Options: &coderdtest.Options{
|
||||
DeploymentValues: dv,
|
||||
},
|
||||
LicenseOptions: &coderdenttest.LicenseOptions{
|
||||
Features: license.Features{},
|
||||
},
|
||||
})
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
//nolint:gocritic // Owner role is irrelevant here.
|
||||
_, err := client.AIBridgeListProviders(ctx)
|
||||
var sdkErr *codersdk.Error
|
||||
require.ErrorAs(t, err, &sdkErr)
|
||||
require.Equal(t, http.StatusForbidden, sdkErr.StatusCode())
|
||||
})
|
||||
|
||||
t.Run("NotAliasedUnderAIBridge", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, _ := coderdenttest.New(t, aibridgeOpts(t))
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
//nolint:gocritic // Owner role is irrelevant here.
|
||||
res, err := client.Request(ctx, http.MethodGet, "/api/v2/aibridge/providers", nil)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusNotFound, res.StatusCode)
|
||||
})
|
||||
|
||||
t.Run("ReturnsMetadataIncludingDeletedAndDisabled", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, db, _ := coderdenttest.NewWithDatabase(t, aibridgeOpts(t))
|
||||
|
||||
dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeAnthropic,
|
||||
Name: "anthropic-prod",
|
||||
DisplayName: sql.NullString{String: "Anthropic (prod)", Valid: true},
|
||||
Icon: "/icon/custom.svg",
|
||||
})
|
||||
dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeOpenai,
|
||||
Name: "openai-disabled",
|
||||
Enabled: false,
|
||||
})
|
||||
deleted := dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeOpenai,
|
||||
Name: "openai-old",
|
||||
})
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
require.NoError(t, db.DeleteAIProviderByID(dbauthz.AsSystemRestricted(ctx), deleted.ID))
|
||||
|
||||
providers, err := client.AIBridgeListProviders(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []codersdk.AIBridgeProvider{
|
||||
{Name: "anthropic-prod", Type: codersdk.AIProviderTypeAnthropic, DisplayName: "Anthropic (prod)", Icon: "/icon/custom.svg"},
|
||||
{Name: "openai-disabled", Type: codersdk.AIProviderTypeOpenAI, DisplayName: "openai-disabled"},
|
||||
{Name: "openai-old", Type: codersdk.AIProviderTypeOpenAI, DisplayName: "openai-old"},
|
||||
}, providers)
|
||||
})
|
||||
|
||||
t.Run("ReusedNamePrefersLiveRow", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, db, _ := coderdenttest.NewWithDatabase(t, aibridgeOpts(t))
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
old := dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeOpenai,
|
||||
Name: "shared",
|
||||
DisplayName: sql.NullString{String: "Old", Valid: true},
|
||||
})
|
||||
require.NoError(t, db.DeleteAIProviderByID(dbauthz.AsSystemRestricted(ctx), old.ID))
|
||||
dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeAnthropic,
|
||||
Name: "shared",
|
||||
DisplayName: sql.NullString{String: "New", Valid: true},
|
||||
})
|
||||
|
||||
providers, err := client.AIBridgeListProviders(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, []codersdk.AIBridgeProvider{
|
||||
{Name: "shared", Type: codersdk.AIProviderTypeAnthropic, DisplayName: "New"},
|
||||
}, providers)
|
||||
})
|
||||
|
||||
t.Run("EmptyIsArray", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, _ := coderdenttest.New(t, aibridgeOpts(t))
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
//nolint:gocritic // Owner role is irrelevant here.
|
||||
res, err := client.Request(ctx, http.MethodGet, "/api/v2/ai-gateway/providers", nil)
|
||||
require.NoError(t, err)
|
||||
defer res.Body.Close()
|
||||
require.Equal(t, http.StatusOK, res.StatusCode)
|
||||
body, err := io.ReadAll(res.Body)
|
||||
require.NoError(t, err)
|
||||
require.JSONEq(t, "[]", string(body))
|
||||
})
|
||||
|
||||
t.Run("AuditorWithoutAIProviderRead", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
adminClient, db, firstUser := coderdenttest.NewWithDatabase(t, aibridgeOpts(t))
|
||||
auditorClient, auditorUser := coderdtest.CreateAnotherUser(t, adminClient, firstUser.OrganizationID, rbac.RoleAuditor())
|
||||
|
||||
dbgen.AIProvider(t, db, database.AIProvider{
|
||||
Type: database.AIProviderTypeAnthropic,
|
||||
Name: "anthropic-prod",
|
||||
})
|
||||
now := dbtime.Now()
|
||||
endedAt := now.Add(time.Minute)
|
||||
dbgen.AIBridgeInterception(t, db, database.InsertAIBridgeInterceptionParams{
|
||||
InitiatorID: auditorUser.ID,
|
||||
Provider: "anthropic",
|
||||
ProviderName: "anthropic-prod",
|
||||
StartedAt: now,
|
||||
}, &endedAt)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
// Auditors cannot read provider configuration.
|
||||
_, err := auditorClient.AIProvider(ctx, "anthropic-prod")
|
||||
require.Error(t, err)
|
||||
|
||||
providers, err := auditorClient.AIBridgeListProviders(ctx)
|
||||
require.NoError(t, err)
|
||||
require.Len(t, providers, 1)
|
||||
require.Equal(t, "anthropic-prod", providers[0].Name)
|
||||
|
||||
sessions, err := auditorClient.AIBridgeListSessions(ctx, codersdk.AIBridgeListSessionsFilter{
|
||||
ProviderName: "anthropic-prod",
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.EqualValues(t, 1, sessions.Count)
|
||||
})
|
||||
|
||||
t.Run("MemberDenied", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
adminClient, firstUser := coderdenttest.New(t, aibridgeOpts(t))
|
||||
memberClient, _ := coderdtest.CreateAnotherUser(t, adminClient, firstUser.OrganizationID)
|
||||
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
_, err := memberClient.AIBridgeListProviders(ctx)
|
||||
var sdkErr *codersdk.Error
|
||||
require.ErrorAs(t, err, &sdkErr)
|
||||
require.Equal(t, http.StatusNotFound, sdkErr.StatusCode())
|
||||
})
|
||||
}
|
||||
|
||||
func TestAIGatewayRetention(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -315,16 +315,6 @@ func New(ctx context.Context, options *Options) (_ *API, err error) {
|
||||
r.Route("/ai-gateway/proxy", aiGatewayProxyHTTPHandler(api, apiKeyMiddleware))
|
||||
})
|
||||
|
||||
api.AGPL.APIHandler.Group(func(r chi.Router) {
|
||||
r.Route("/ai-gateway/providers", func(r chi.Router) {
|
||||
r.Use(
|
||||
apiKeyMiddleware,
|
||||
api.RequireFeatureMW(codersdk.FeatureAIBridge),
|
||||
)
|
||||
r.Get("/", api.aiBridgeListProviders)
|
||||
})
|
||||
})
|
||||
|
||||
api.AGPL.APIHandler.Group(func(r chi.Router) {
|
||||
r.Route("/ai-gateway/keys", func(r chi.Router) {
|
||||
r.Use(
|
||||
|
||||
+4
-9
@@ -3145,13 +3145,6 @@ class ApiMethods {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
getAIBridgeProviders = async () => {
|
||||
const response = await this.axios.get<TypesGen.AIBridgeProvider[]>(
|
||||
`${aiGatewayPath}/providers`,
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
getAIBridgeSessionList = async (options: SearchParamOptions) => {
|
||||
const url = getURLWithSearchParams(`${aiGatewayPath}/sessions`, options);
|
||||
const response =
|
||||
@@ -3172,9 +3165,11 @@ class ApiMethods {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
getAIProviders = async (): Promise<TypesGen.AIProvider[]> => {
|
||||
getAIProviders = async (
|
||||
filter?: TypesGen.AIProvidersFilter,
|
||||
): Promise<TypesGen.AIProvider[]> => {
|
||||
const response = await this.axios.get<TypesGen.AIProvider[]>(
|
||||
"/api/v2/ai/providers",
|
||||
getURLWithSearchParams("/api/v2/ai/providers", filter),
|
||||
);
|
||||
return response.data;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,6 @@ import {
|
||||
import { API } from "#/api/api";
|
||||
import type {
|
||||
AIBridgeListSessionsResponse,
|
||||
AIBridgeProvider,
|
||||
AIBridgeSessionThreadsResponse,
|
||||
AISpendPeriodWindow,
|
||||
Organization,
|
||||
@@ -41,13 +40,6 @@ export const paginatedSessions = (
|
||||
};
|
||||
};
|
||||
|
||||
export const aiBridgeProvidersKey = ["aiBridgeProviders"] as const;
|
||||
|
||||
export const aiBridgeProviders = () => ({
|
||||
queryKey: aiBridgeProvidersKey,
|
||||
queryFn: (): Promise<AIBridgeProvider[]> => API.getAIBridgeProviders(),
|
||||
});
|
||||
|
||||
type AIBridgeModelsOptions = Pagination & { model?: string };
|
||||
|
||||
export const aiBridgeModelsKey = (options: AIBridgeModelsOptions) =>
|
||||
|
||||
@@ -26,6 +26,18 @@ export const aiProvidersList = () => ({
|
||||
queryFn: (): Promise<AIProvider[]> => API.getAIProviders(),
|
||||
});
|
||||
|
||||
export const aiProvidersIncludingDeletedKey = [
|
||||
...aiProvidersListKey,
|
||||
{ include_deleted: true },
|
||||
] as const;
|
||||
|
||||
/** Sessions and spend recorded under a deleted provider still need its label. */
|
||||
export const aiProvidersIncludingDeleted = () => ({
|
||||
queryKey: aiProvidersIncludingDeletedKey,
|
||||
queryFn: (): Promise<AIProvider[]> =>
|
||||
API.getAIProviders({ include_deleted: true }),
|
||||
});
|
||||
|
||||
const selectChatProviderConfigs = (
|
||||
providers: readonly AIProvider[],
|
||||
): ChatProviderConfig[] =>
|
||||
|
||||
Generated
+6
-13
@@ -153,19 +153,6 @@ export interface AIBridgePricedModel {
|
||||
readonly cache_write_price: number | null;
|
||||
}
|
||||
|
||||
// From codersdk/aibridge.go
|
||||
/**
|
||||
* AIBridgeProvider is the display metadata for a configured AI provider,
|
||||
* used to filter AI Gateway sessions by provider_name. It carries no
|
||||
* configuration so it can be served to anyone who can read sessions.
|
||||
*/
|
||||
export interface AIBridgeProvider {
|
||||
readonly name: string;
|
||||
readonly type: AIProviderType;
|
||||
readonly display_name: string;
|
||||
readonly icon: string;
|
||||
}
|
||||
|
||||
// From codersdk/deployment.go
|
||||
export interface AIBridgeProxyConfig {
|
||||
readonly enabled: boolean;
|
||||
@@ -522,6 +509,7 @@ export interface AIProvider {
|
||||
readonly display_name: string;
|
||||
readonly icon: string;
|
||||
readonly enabled: boolean;
|
||||
readonly deleted: boolean;
|
||||
readonly base_url: string;
|
||||
readonly api_keys: readonly AIProviderKey[];
|
||||
readonly settings: AIProviderSettings;
|
||||
@@ -754,6 +742,11 @@ export const AIProviderTypes: AIProviderType[] = [
|
||||
"vercel",
|
||||
];
|
||||
|
||||
// From codersdk/aiproviders.go
|
||||
export interface AIProvidersFilter {
|
||||
readonly include_deleted?: boolean;
|
||||
}
|
||||
|
||||
// From codersdk/aibridge.go
|
||||
/**
|
||||
* AISpendPeriodWindow is the [Start, End) window over which AI spend is
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
||||
import { useState } from "react";
|
||||
import { fn, screen, userEvent, within } from "storybook/test";
|
||||
import {
|
||||
aiBridgeClientsKey,
|
||||
aiBridgeModelsKey,
|
||||
aiBridgeProvidersKey,
|
||||
} from "#/api/queries/aiBridge";
|
||||
import { aiBridgeClientsKey, aiBridgeModelsKey } from "#/api/queries/aiBridge";
|
||||
import { aiProvidersIncludingDeletedKey } from "#/api/queries/aiProviders";
|
||||
import { permittedOrganizationsKey } from "#/api/queries/organizations";
|
||||
import { usersKey } from "#/api/queries/users";
|
||||
import type { AIBridgeProvider } from "#/api/typesGenerated";
|
||||
import type { DateTimeRangeValue } from "#/components/DateTimeRangePicker/dateTimeRange";
|
||||
import type { UseFilterResult } from "#/components/Filter/Filter";
|
||||
import {
|
||||
MockAIProviderAnthropic,
|
||||
MockAIProviders,
|
||||
MockDefaultOrganization,
|
||||
MockOrganization2,
|
||||
MockPermissions,
|
||||
@@ -25,16 +23,6 @@ import {
|
||||
} from "#/testHelpers/storybook";
|
||||
import { ListSessionsFilter } from "./ListSessionsFilter";
|
||||
|
||||
const mockProviders: AIBridgeProvider[] = [
|
||||
{
|
||||
name: "anthropic-prod",
|
||||
type: "anthropic",
|
||||
display_name: "Anthropic (prod)",
|
||||
icon: "",
|
||||
},
|
||||
{ name: "openai-prod", type: "openai", display_name: "", icon: "" },
|
||||
];
|
||||
|
||||
const timeRange: DateTimeRangeValue = {
|
||||
start: new Date("2026-08-12T15:00:00Z"),
|
||||
end: new Date("2026-08-13T15:00:00Z"),
|
||||
@@ -83,7 +71,7 @@ const meta: Meta<typeof ListSessionsFilterHarness> = {
|
||||
user: MockUserOwner,
|
||||
permissions: MockPermissions,
|
||||
queries: [
|
||||
{ key: aiBridgeProvidersKey, data: mockProviders },
|
||||
{ key: aiProvidersIncludingDeletedKey, data: MockAIProviders },
|
||||
{
|
||||
key: aiBridgeClientsKey({ q: "", limit: 25 }),
|
||||
data: ["claude-code", "cursor"],
|
||||
@@ -115,7 +103,7 @@ export const Default: Story = {
|
||||
|
||||
export const WithFilters: Story = {
|
||||
args: {
|
||||
initialQuery: `user:me provider_name:anthropic-prod client:claude-code model:"us.anthropic.claude-3-5-sonnet-v2:0" ${rangeQuery}`,
|
||||
initialQuery: `user:me provider_name:${MockAIProviderAnthropic.name} client:claude-code model:"us.anthropic.claude-3-5-sonnet-v2:0" ${rangeQuery}`,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ const ListSessionsFilterHarness = ({
|
||||
|
||||
describe("ListSessionsFilter", () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(API, "getAIBridgeProviders").mockResolvedValue([]);
|
||||
vi.spyOn(API, "getAIProviders").mockResolvedValue([]);
|
||||
vi.spyOn(API, "getAIBridgeClients").mockResolvedValue([]);
|
||||
vi.spyOn(API, "getAIBridgeModels").mockResolvedValue([bedrockModel]);
|
||||
});
|
||||
@@ -74,4 +74,20 @@ describe("ListSessionsFilter", () => {
|
||||
),
|
||||
);
|
||||
});
|
||||
|
||||
it("requests deleted providers so sessions recorded under them stay filterable", async () => {
|
||||
const user = userEvent.setup({ skipHover: true });
|
||||
renderWithAuth(
|
||||
<ListSessionsFilterHarness onUpdate={vi.fn()} initialQuery="" />,
|
||||
);
|
||||
|
||||
await user.click(await screen.findByRole("button", { name: "Filters" }));
|
||||
await user.hover(await screen.findByRole("option", { name: "Provider" }));
|
||||
|
||||
await waitFor(() =>
|
||||
expect(API.getAIProviders).toHaveBeenCalledWith({
|
||||
include_deleted: true,
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,5 @@
|
||||
import {
|
||||
aiBridgeClients,
|
||||
aiBridgeModels,
|
||||
aiBridgeProviders,
|
||||
} from "#/api/queries/aiBridge";
|
||||
import { aiBridgeClients, aiBridgeModels } from "#/api/queries/aiBridge";
|
||||
import { aiProvidersIncludingDeleted } from "#/api/queries/aiProviders";
|
||||
import { filterOptionsByText } from "#/components/Filter/FilterCombobox/filterQuery";
|
||||
import type { FilterOption } from "#/components/Filter/FilterCombobox/types";
|
||||
import { ProviderIcon } from "#/modules/aiModels/ProviderIcon";
|
||||
@@ -17,9 +14,9 @@ export const getProviderFilterOptions = async (
|
||||
queryClient: OptionsQueryClient,
|
||||
): Promise<readonly FilterOption[]> => {
|
||||
// The providers endpoint has no search, so filter here.
|
||||
const providers = await queryClient.fetchQuery(aiBridgeProviders());
|
||||
const providers = await queryClient.fetchQuery(aiProvidersIncludingDeleted());
|
||||
const options = providers.map((provider) => ({
|
||||
label: provider.display_name || provider.name,
|
||||
label: provider.display_name,
|
||||
value: provider.name,
|
||||
startIcon: <ProviderIcon provider={provider.type} icon={provider.icon} />,
|
||||
}));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AIBridgeProvider } from "#/api/typesGenerated";
|
||||
import type { AIProvider } from "#/api/typesGenerated";
|
||||
import { ProviderIcon } from "#/modules/aiModels/ProviderIcon";
|
||||
import { ItemsBadge } from "./ItemsBadge";
|
||||
import { AIBridgeProviderIcon } from "./icons/AIBridgeProviderIcon";
|
||||
@@ -7,7 +7,7 @@ import { getProviderDisplayName } from "./utils";
|
||||
type ProvidersBadgeProps = {
|
||||
providers: readonly string[];
|
||||
/** Configured providers by name; matches supply the label and icon. */
|
||||
providersByName?: ReadonlyMap<string, AIBridgeProvider>;
|
||||
providersByName?: ReadonlyMap<string, AIProvider>;
|
||||
};
|
||||
|
||||
export const ProvidersBadge: React.FC<ProvidersBadgeProps> = ({
|
||||
|
||||
@@ -42,7 +42,7 @@ const meta = {
|
||||
MockGroup,
|
||||
MockGroup2,
|
||||
]);
|
||||
spyOn(API, "getAIBridgeProviders").mockResolvedValue(MockAIProviders);
|
||||
spyOn(API, "getAIProviders").mockResolvedValue(MockAIProviders);
|
||||
spyOn(API, "getAIBridgeClients").mockResolvedValue([
|
||||
"Claude Code",
|
||||
"Codex",
|
||||
|
||||
@@ -11,8 +11,8 @@ import {
|
||||
type AISpendReportFilter,
|
||||
aiBridgeClients,
|
||||
aiBridgeModels,
|
||||
aiBridgeProviders,
|
||||
} from "#/api/queries/aiBridge";
|
||||
import { aiProvidersIncludingDeleted } from "#/api/queries/aiProviders";
|
||||
import { groupsByOrganization } from "#/api/queries/groups";
|
||||
import { organizationMembers } from "#/api/queries/organizations";
|
||||
import { Avatar } from "#/components/Avatar/Avatar";
|
||||
@@ -94,7 +94,7 @@ const getProviderOptions = async (
|
||||
query: string,
|
||||
queryClient: OptionsQueryClient,
|
||||
): Promise<FilterOption[]> => {
|
||||
const providers = await queryClient.fetchQuery(aiBridgeProviders());
|
||||
const providers = await queryClient.fetchQuery(aiProvidersIncludingDeleted());
|
||||
const normalized = query.trim().toLowerCase();
|
||||
return providers
|
||||
.filter(
|
||||
|
||||
@@ -5774,6 +5774,7 @@ export const MockAIProviderOpenAI: TypesGen.AIProvider = {
|
||||
icon: "",
|
||||
base_url: "https://api.openai.com",
|
||||
enabled: false,
|
||||
deleted: false,
|
||||
api_keys: [
|
||||
{
|
||||
id: "6d7c1f3a-1f0b-4a12-a1b5-0fb1f8e72e01",
|
||||
@@ -5794,6 +5795,7 @@ export const MockAIProviderAnthropic: TypesGen.AIProvider = {
|
||||
icon: "",
|
||||
base_url: "https://api.anthropic.com",
|
||||
enabled: false,
|
||||
deleted: false,
|
||||
api_keys: [],
|
||||
settings: null as unknown as TypesGen.AIProviderSettings,
|
||||
created_at: "2026-05-14T10:00:00Z",
|
||||
@@ -5814,6 +5816,7 @@ export const MockAIProviderBedrock: TypesGen.AIProvider = {
|
||||
icon: "",
|
||||
base_url: "https://bedrock-runtime.us-east-2.amazonaws.com",
|
||||
enabled: true,
|
||||
deleted: false,
|
||||
api_keys: [],
|
||||
settings: {
|
||||
_type: "bedrock",
|
||||
@@ -5840,6 +5843,7 @@ export const MockAIProviderClaudePlatformAWS: TypesGen.AIProvider = {
|
||||
icon: "",
|
||||
base_url: "https://aws-external-anthropic.us-east-1.api.aws",
|
||||
enabled: true,
|
||||
deleted: false,
|
||||
api_keys: [],
|
||||
settings: {
|
||||
_type: "claude_platform_aws",
|
||||
@@ -5874,6 +5878,7 @@ export const MockAIProviderCopilot: TypesGen.AIProvider = {
|
||||
icon: "",
|
||||
base_url: "https://api.business.githubcopilot.com",
|
||||
enabled: true,
|
||||
deleted: false,
|
||||
api_keys: [],
|
||||
settings: null as unknown as TypesGen.AIProviderSettings,
|
||||
created_at: "2026-05-14T10:00:00Z",
|
||||
|
||||
Reference in new issue
Block a user