Files
1Panel/agent/app/provider/account_presets.go
ssongliu 92c3173aec feat(ai): sync gateway providers and model discovery (#14426)
* feat(ai): sync gateway providers and model discovery

Add provider account types and protocol-aware model discovery, and replace predefined models with editable model pools.

Align provider icons with AI Gateway, preserve international Coding Plan restrictions, and filter account counts consistently with selectable accounts.

* fix(ai): preserve Ollama base paths during model discovery

* fix(ai): restore custom DashScope image protocol support
2026-11-13 14:04:11 +08:00

55 lines
1.1 KiB
Go

package provider
import (
"strings"
)
type AccountTypePreset struct {
Key string `json:"key"`
APIConfigs []APIConfig `json:"apiTypes"`
}
func FindAccountType(provider, accountType string) (AccountTypePreset, bool) {
meta, ok := catalog[provider]
if !ok || len(meta.AccountTypes) == 0 {
return AccountTypePreset{}, false
}
if accountType == "" {
switch provider {
case "bailian", "ark", "xiaomi":
accountType = "payAsYouGo"
case "kimi", "zai":
accountType = "chinaApi"
default:
return meta.AccountTypes[0], true
}
}
for _, item := range meta.AccountTypes {
if item.Key == accountType {
return item, true
}
}
return AccountTypePreset{}, false
}
func Purpose(apiType string) string {
switch apiType {
case "openai-completions", "openai-responses", "anthropic-messages", "gemini-generate-content":
return "text"
case "openai-embeddings":
return "embedding"
case "rerank":
return "rerank"
}
if strings.HasSuffix(apiType, "-images") {
return "image"
}
if strings.HasSuffix(apiType, "-transcriptions") {
return "transcription"
}
if strings.HasSuffix(apiType, "-speech") {
return "speech"
}
return ""
}