mirror of
https://github.com/EZ-Api/ez-api.git
synced 2026-01-13 17:47:51 +00:00
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:
@@ -79,6 +79,7 @@ func (s *SyncService) SyncProvider(provider *model.Provider) error {
|
||||
GoogleLocation: provider.GoogleLocation,
|
||||
Group: group,
|
||||
Models: models,
|
||||
Weight: provider.Weight,
|
||||
Status: normalizeStatus(provider.Status),
|
||||
AutoBan: provider.AutoBan,
|
||||
BanReason: provider.BanReason,
|
||||
@@ -139,6 +140,7 @@ type providerSnapshot struct {
|
||||
GoogleLocation string `json:"google_location,omitempty"`
|
||||
Group string `json:"group"`
|
||||
Models []string `json:"models"`
|
||||
Weight int `json:"weight,omitempty"`
|
||||
Status string `json:"status"`
|
||||
AutoBan bool `json:"auto_ban"`
|
||||
BanReason string `json:"ban_reason,omitempty"`
|
||||
@@ -220,6 +222,7 @@ func (s *SyncService) SyncAll(db *gorm.DB) error {
|
||||
GoogleLocation: p.GoogleLocation,
|
||||
Group: group,
|
||||
Models: models,
|
||||
Weight: p.Weight,
|
||||
Status: normalizeStatus(p.Status),
|
||||
AutoBan: p.AutoBan,
|
||||
BanReason: p.BanReason,
|
||||
|
||||
Reference in New Issue
Block a user