diff --git a/consts/public/public.go b/consts/public/public.go index b17843c..26a6dd4 100644 --- a/consts/public/public.go +++ b/consts/public/public.go @@ -61,3 +61,43 @@ var ModelTypeName = map[int]string{ VideoSubTypeVideoToVideo: "视频模型-视频生视频", VideoSubTypeVideoEdit: "视频模型-视频编辑", } + +// 运营商常量 +const ( + OperatorAliyun = "阿里云百炼" + OperatorVolcengine = "火山引擎" + OperatorTencent = "腾讯云" + OperatorHuawei = "华为云" + OperatorBaidu = "百度智能云" + OperatorOpenAI = "OpenAI" + OperatorAzure = "Azure OpenAI" + OperatorAWS = "AWS Bedrock" + OperatorGoogle = "Google Cloud" + OperatorDeepSeek = "DeepSeek" + OperatorMoonshot = "Moonshot" + OperatorZhipu = "智谱AI" + OperatorBaichuan = "百川智能" + OperatorMinimax = "MiniMax" + OperatorXunfei = "科大讯飞" + OperatorOthers = "其他" +) + +// OperatorList 运营商列表(供前端下拉框使用) +var OperatorList = []string{ + OperatorAliyun, + OperatorVolcengine, + OperatorTencent, + OperatorHuawei, + OperatorBaidu, + OperatorOpenAI, + OperatorAzure, + OperatorAWS, + OperatorGoogle, + OperatorDeepSeek, + OperatorMoonshot, + OperatorZhipu, + OperatorBaichuan, + OperatorMinimax, + OperatorXunfei, + OperatorOthers, +} diff --git a/controller/model_controller.go b/controller/model_controller.go index 619b49e..2411b04 100644 --- a/controller/model_controller.go +++ b/controller/model_controller.go @@ -49,6 +49,11 @@ func (c *model) ListType(ctx context.Context, req *dto.ListTypeReq) (res *dto.Ty return service.GetModelTypesFromConfig() } +// ListOperator 运营商列表 +func (c *model) ListOperator(ctx context.Context, req *dto.ListOperatorReq) (res *dto.ListOperatorRes, err error) { + return service.GetOperatorList() +} + // UpdateChatModel 更新是否为聊天模型 func (c *model) UpdateChatModel(ctx context.Context, req *dto.UpdateChatModelReq) (res *dto.UpdateChatModelRes, err error) { err = service.Model.UpdateChatModel(ctx, req) diff --git a/model/dto/model_dto.go b/model/dto/model_dto.go index 92503fb..89ba260 100644 --- a/model/dto/model_dto.go +++ b/model/dto/model_dto.go @@ -136,6 +136,14 @@ type TypeItem struct { Type map[int]string `json:"type" dc:"模型类型ID到名称的映射"` } +type ListOperatorReq struct { + g.Meta `path:"/listOperator" method:"get" tags:"模型管理" summary:"获取运营商列表" dc:"获取运营商列表"` +} + +type ListOperatorRes struct { + List []string `json:"list" dc:"运营商名称到ID的映射"` +} + type UpdateChatModelReq struct { g.Meta `path:"/updateChatModel" method:"post" tags:"模型管理" summary:"更新聊天模型" dc:"更新指定模型的聊天模型"` Id int64 `p:"id" json:"id" v:"required#model不能为空" dc:"模型id"` diff --git a/service/model_service.go b/service/model_service.go index 23bc5c5..980ff4b 100644 --- a/service/model_service.go +++ b/service/model_service.go @@ -303,6 +303,13 @@ func GetModelTypesFromConfig() (res *dto.TypeItem, err error) { }, nil } +// GetOperatorList 获取运营商列表 +func GetOperatorList() (res *dto.ListOperatorRes, err error) { + return &dto.ListOperatorRes{ + List: public.OperatorList, + }, nil +} + func (s *modelService) UpdateChatModel(ctx context.Context, req *dto.UpdateChatModelReq) error { // 校验新会话模型是否存在 newModel, err := dao.Model.GetByAcrossTenant(ctx, &entity.AsynchModel{