mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-11-20 00:01:06 +00:00
* 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
55 lines
1.1 KiB
Go
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 ""
|
|
}
|