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:
@@ -74,6 +74,7 @@ func (h *Handler) CreateProvider(c *gin.Context) {
|
||||
Status: status,
|
||||
AutoBan: autoBan,
|
||||
BanReason: req.BanReason,
|
||||
Weight: req.Weight,
|
||||
}
|
||||
if !req.BanUntil.IsZero() {
|
||||
tu := req.BanUntil.UTC()
|
||||
@@ -162,6 +163,9 @@ func (h *Handler) UpdateProvider(c *gin.Context) {
|
||||
if req.Models != nil {
|
||||
update["models"] = strings.Join(req.Models, ",")
|
||||
}
|
||||
if req.Weight > 0 {
|
||||
update["weight"] = req.Weight
|
||||
}
|
||||
if strings.TrimSpace(req.Group) != "" {
|
||||
update["group"] = groupx.Normalize(req.Group)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user