feat(api): add provider creation endpoints and weight support

- Add `POST /admin/providers/preset` for streamlined creation of official providers (OpenAI, Anthropic, Gemini)
- Add `POST /admin/providers/custom` for generic OpenAI-compatible providers
- Add `weight` field to provider model and DTOs to enable weighted routing
- Update sync service to propagate provider weights
- Add unit tests for new creation handlers
This commit is contained in:
zenfun
2025-12-17 21:40:54 +08:00
parent 5a4e63b75d
commit 174735f152
8 changed files with 310 additions and 0 deletions

View File

@@ -49,6 +49,7 @@ type Provider struct {
GoogleLocation string `gorm:"size:64" json:"google_location,omitempty"`
Group string `gorm:"default:'default'" json:"group"` // routing group/tier
Models string `json:"models"` // comma-separated list of supported models (e.g. "gpt-4,gpt-3.5-turbo")
Weight int `gorm:"default:1" json:"weight"` // routing weight inside route_group
Status string `gorm:"size:50;default:'active'" json:"status"` // active, auto_disabled, manual_disabled
AutoBan bool `gorm:"default:true" json:"auto_ban"` // whether DP-triggered disable is allowed
BanReason string `gorm:"size:255" json:"ban_reason"` // reason for current disable