feat: 更新主流大模型供应商目录

- 按云服务、Coding Plan、API 网关和本地模型分组

- 新增兼容模型发现与供应商协议校验
This commit is contained in:
Logan.Li committed 2026-07-30 21:34:33 +08:00
1 parent 01e4435f29
commit d8b124fc7c
15 files changed
+838 -237

No files matched your search

+7 -3
View File
@@ -195,10 +195,11 @@ func (h *LLMHandler) llmConfigFromTestRequest(req model.SaveLLMConfigRequest) (m
}
if strings.Contains(req.APIKey, "****") {
var saved model.LLMConfig
if err := h.db.First(&saved).Error; err != nil {
if err := h.db.Take(&saved).Error; err != nil || !canReuseMaskedAPIKey(req.Provider, req.Endpoint, saved) {
if !isLocalLLMProvider(req.Provider) {
return cfg, "请填写 API Key"
return cfg, "提供商或 Endpoint 已变化,请重新填写 API Key"
}
cfg.APIKey = ""
} else {
cfg.APIKey = saved.APIKey
}
@@ -209,6 +210,9 @@ func (h *LLMHandler) llmConfigFromTestRequest(req model.SaveLLMConfigRequest) (m
if cfg.Model == "" {
return cfg, "请填写模型名"
}
if requiresExplicitEndpoint(cfg.Provider) && strings.TrimSpace(cfg.Endpoint) == "" {
return cfg, "请填写 Endpoint"
}
if cfg.APIKey == "" && !isLocalLLMProvider(cfg.Provider) {
return cfg, "请填写 API Key"
}
@@ -226,7 +230,7 @@ func (h *LLMHandler) TestLLMConnection(c *gin.Context) {
if req.Provider != "" {
cfg, errMsg = h.llmConfigFromTestRequest(req)
} else {
if err := h.db.First(&cfg).Error; err != nil {
if err := h.db.Take(&cfg).Error; err != nil {
c.JSON(http.StatusOK, model.Response{Code: 400, Message: "请先填写配置并测试连接"})
return
}