6e6b899071
CI / docker (push) Successful in 7m37s
引入用户端对话/生图与管理端 Provider 配置,统一 invoke 编排、Gateway、请求日志与模型管理;前端按设计规范拆分布局,Go module 更名为 github.com/rose_cat707/Atlas;生图长任务 SSE 推送;管理端登录防爆破;协议与服务类型联动;Replicate 模型同步修复;用户端创作台 UI 重构;管理端创作历史替代请求日志。 Co-authored-by: Cursor <cursoragent@cursor.com>
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package domain
|
|
|
|
import "fmt"
|
|
|
|
var protocolServiceTypes = map[string][]ServiceType{
|
|
"openai": {ServiceChat},
|
|
"replicate": {ServiceTextToImage, ServiceImageToImage},
|
|
}
|
|
|
|
var serviceTypeProtocol = map[ServiceType]string{
|
|
ServiceChat: "openai",
|
|
ServiceTextToImage: "replicate",
|
|
ServiceImageToImage: "replicate",
|
|
}
|
|
|
|
func DefaultProtocol(serviceType ServiceType) string {
|
|
if p, ok := serviceTypeProtocol[serviceType]; ok {
|
|
return p
|
|
}
|
|
return "openai"
|
|
}
|
|
|
|
func DefaultServiceType(protocol string) ServiceType {
|
|
types := ServiceTypesForProtocol(protocol)
|
|
if len(types) == 0 {
|
|
return ServiceChat
|
|
}
|
|
return types[0]
|
|
}
|
|
|
|
func ServiceTypesForProtocol(protocol string) []ServiceType {
|
|
return append([]ServiceType(nil), protocolServiceTypes[protocol]...)
|
|
}
|
|
|
|
func ProtocolForServiceType(serviceType ServiceType) string {
|
|
return DefaultProtocol(serviceType)
|
|
}
|
|
|
|
func ValidateProviderBinding(protocol, serviceType string) error {
|
|
types := ServiceTypesForProtocol(protocol)
|
|
if len(types) == 0 {
|
|
return fmt.Errorf("unsupported protocol: %s", protocol)
|
|
}
|
|
st := ServiceType(serviceType)
|
|
for _, allowed := range types {
|
|
if allowed == st {
|
|
return nil
|
|
}
|
|
}
|
|
return fmt.Errorf("protocol %s does not support service_type %s", protocol, serviceType)
|
|
}
|