feat(channels): 拉模型改为勾选即绑定,启动清扫遗留模型
- fetch-models 返回 bound 标记,渠道页勾选=立即导入绑定, 取消=解绑(无其他渠道接入时本地模型行一并删除) - 新增 POST /channels/unbind-model - 启动时 PurgeOrphanModels 清掉 provider 时代的无绑定模型行 - 模型管理页移除「渠道导入模型」按钮 Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
@@ -106,6 +106,24 @@ func (h *ChannelAdminHandler) ImportModels(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"ok": true})
|
||||
}
|
||||
|
||||
// UnbindModel detaches one upstream model from a channel; the local model row
|
||||
// is deleted too when no other channel still binds it.
|
||||
func (h *ChannelAdminHandler) UnbindModel(c *gin.Context) {
|
||||
var body struct {
|
||||
ID string `json:"id"`
|
||||
Model string `json:"model"`
|
||||
}
|
||||
if err := c.ShouldBindJSON(&body); err != nil || strings.TrimSpace(body.ID) == "" || strings.TrimSpace(body.Model) == "" {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"detail": "id and model required"})
|
||||
return
|
||||
}
|
||||
if err := h.channels.UnbindModel(c.Request.Context(), body.ID, body.Model); err != nil {
|
||||
writeUpstreamErr(c, err)
|
||||
return
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{"ok": true})
|
||||
}
|
||||
|
||||
// writeUpstreamErr translates upstream-protocol errors into sensible admin
|
||||
// responses (auth → 400 with the upstream's message, temporary → 502).
|
||||
func writeUpstreamErr(c *gin.Context, err error) {
|
||||
|
||||
Reference in New Issue
Block a user