feat: widen ai_provider_type enum for chatd providers (#25394)

This commit is contained in:
Danny Kopping
2026-05-18 15:06:30 +02:00
committed by GitHub
parent 78d4cf9e47
commit c69dd9c5dc
6 changed files with 79 additions and 6 deletions
+7 -1
View File
@@ -12,7 +12,13 @@ CREATE TYPE agent_key_scope_enum AS ENUM (
CREATE TYPE ai_provider_type AS ENUM (
'openai',
'anthropic'
'anthropic',
'azure',
'bedrock',
'google',
'openai-compat',
'openrouter',
'vercel'
);
CREATE TYPE ai_seat_usage_reason AS ENUM (
@@ -0,0 +1,3 @@
-- No-op: Postgres does not allow removing enum values safely.
-- Matches the precedent in 000495_ai_providers.down.sql for ALTER
-- TYPE resource_type / api_key_scope ADD VALUE.
@@ -0,0 +1,15 @@
-- Widen ai_provider_type to carry the full chatd provider set so the
-- chatd-side migration can preserve type fidelity when it lands. The
-- aibridge runtime currently has native support only for OpenAI and
-- Anthropic (with a Bedrock variant on the Anthropic client); the new
-- non-Bedrock types route through the OpenAI fantasy client today
-- because chatd already configures these providers against their
-- OpenAI-compatible endpoints. Native gateway-side support for these
-- providers comes later, at which point this enum already carries the
-- right discriminator and no further migration is needed.
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'azure';
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'bedrock';
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'google';
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'openai-compat';
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'openrouter';
ALTER TYPE ai_provider_type ADD VALUE IF NOT EXISTS 'vercel';
+21 -3
View File
@@ -19,8 +19,14 @@ import (
type AIProviderType string
const (
AiProviderTypeOpenai AIProviderType = "openai"
AiProviderTypeAnthropic AIProviderType = "anthropic"
AiProviderTypeOpenai AIProviderType = "openai"
AiProviderTypeAnthropic AIProviderType = "anthropic"
AiProviderTypeAzure AIProviderType = "azure"
AiProviderTypeBedrock AIProviderType = "bedrock"
AiProviderTypeGoogle AIProviderType = "google"
AiProviderTypeOpenaiCompat AIProviderType = "openai-compat"
AiProviderTypeOpenrouter AIProviderType = "openrouter"
AiProviderTypeVercel AIProviderType = "vercel"
)
func (e *AIProviderType) Scan(src interface{}) error {
@@ -61,7 +67,13 @@ func (ns NullAIProviderType) Value() (driver.Value, error) {
func (e AIProviderType) Valid() bool {
switch e {
case AiProviderTypeOpenai,
AiProviderTypeAnthropic:
AiProviderTypeAnthropic,
AiProviderTypeAzure,
AiProviderTypeBedrock,
AiProviderTypeGoogle,
AiProviderTypeOpenaiCompat,
AiProviderTypeOpenrouter,
AiProviderTypeVercel:
return true
}
return false
@@ -71,6 +83,12 @@ func AllAIProviderTypeValues() []AIProviderType {
return []AIProviderType{
AiProviderTypeOpenai,
AiProviderTypeAnthropic,
AiProviderTypeAzure,
AiProviderTypeBedrock,
AiProviderTypeGoogle,
AiProviderTypeOpenaiCompat,
AiProviderTypeOpenrouter,
AiProviderTypeVercel,
}
}