- entity/dto 落地 ref_system_model_id 字段 + ReferenceSystemModelReq/Res - DAO 新增 CountReferences / UpdateReferencesName 辅助方法 - roundtrip 单测验证 DTO→entity 映射 Co-Authored-By: Claude <noreply@anthropic.com>
170 lines
10 KiB
Go
170 lines
10 KiB
Go
package dto
|
||
|
||
import (
|
||
"model-gateway/consts/model"
|
||
"model-gateway/consts/public"
|
||
"model-gateway/model/entity"
|
||
|
||
"gitea.redpowerfuture.com/red-future/common/beans"
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
// CreateModelManageReq 添加模型配置
|
||
type CreateModelManageReq struct {
|
||
g.Meta `path:"/createModelManage" method:"post" tags:"模型管理" summary:"创建模型配置" dc:"添加新的模型配置"`
|
||
ModelSupplier model.SupplierType `json:"modelSupplier" v:"required#模型供应商不能为空" dc:"模型供应商"`
|
||
ModelName string `json:"modelName" v:"required#模型名称不能为空" dc:"模型名称"`
|
||
ModelType model.ModelType `json:"modelType" v:"required#模型类型不能为空" dc:"模型类型"`
|
||
BaseURL string `json:"baseUrl" v:"required#模型服务地址不能为空" dc:"模型服务地址"`
|
||
SystemModel *bool `json:"systemModel" dc:"系统模型"`
|
||
RefSystemModelId int64 `json:"refSystemModelId" dc:"引用的系统模型ID(引用创建时填,普通创建留空)"`
|
||
HttpMethod string `json:"httpMethod" dc:"请求方式:GET/POST" d:"POST"`
|
||
ChatModel *bool `json:"chatModel" dc:"对话模型"`
|
||
ResponseType model.ResponseType `json:"responseType" v:"required#调用模式不能为空" dc:"调用模式:0-同步 1-异步 2-流式"`
|
||
ApiKey string `json:"apiKey" dc:"调用凭证/密钥"`
|
||
Enabled *bool `json:"enabled" dc:"启用"`
|
||
RequestHeadMapping map[string]string `json:"requestHeadMapping" dc:"请求头映射"`
|
||
RequestBodyMapping map[string]any `json:"requestBodyMapping" dc:"请求体映射"`
|
||
RequestBusinessFieldMapping map[string]string `json:"requestBusinessFieldMapping" dc:"业务字段映射"`
|
||
ResponseMapping map[string]any `json:"responseMapping" dc:"返回映射"`
|
||
ResponseBodyMapping map[string]string `json:"responseBodyMapping" dc:"返回体映射"`
|
||
ResponseBusinessFieldMapping map[string]string `json:"responseBusinessFieldMapping" dc:"业务字段映射"`
|
||
MaxConcurrency int `json:"maxConcurrency" dc:"最大并发数(默认10)"`
|
||
TokenMapping *entity.TokenMapping `json:"tokenMapping" dc:"token映射"`
|
||
AsyncTaskMapping *entity.AsyncTaskMapping `json:"asyncTaskMapping" dc:"异步任务映射"`
|
||
TokenPredictPrice float64 `json:"tokenPredictPrice" dc:"模型Token预估价格"`
|
||
TokenPredictPriceUnit string `json:"tokenPredictPriceUnit" dc:"模型Token预估价格单位"`
|
||
MaxTokens int `json:"maxTokens" dc:"最大token数"`
|
||
MinDuration int `json:"minDuration" dc:"最小时长"`
|
||
MaxDuration int `json:"maxDuration" dc:"最大时长"`
|
||
LastFrame string `json:"lastFrame" dc:"视频的尾帧图像"`
|
||
}
|
||
|
||
type CreateModelManageRes struct {
|
||
Id int64 `json:"id,string" dc:"配置ID"`
|
||
}
|
||
|
||
type UpdateModelManageReq struct {
|
||
g.Meta `path:"/updateModelManage" method:"put" tags:"模型管理" summary:"更新模型配置" dc:"更新指定ID的模型配置"`
|
||
Id int64 `json:"id" v:"required#id不能为空" dc:"配置ID"`
|
||
ModelSupplier model.SupplierType `json:"modelSupplier" dc:"模型供应商"`
|
||
ModelName string `json:"modelName" dc:"模型名称"`
|
||
ModelType model.ModelType `json:"modelType" dc:"模型类型"`
|
||
BaseURL string `json:"baseUrl" dc:"模型服务地址"`
|
||
SystemModel *bool `json:"systemModel" dc:"系统模型"`
|
||
RefSystemModelId int64 `json:"refSystemModelId" dc:"引用的系统模型ID(引用行只改个人字段,本字段无效)"`
|
||
HttpMethod string `json:"httpMethod" dc:"请求方式:GET/POST"`
|
||
ChatModel *bool `json:"chatModel" dc:"对话模型"`
|
||
ResponseType model.ResponseType `json:"responseType" dc:"调用模式:0-同步 1-异步 2-流式"`
|
||
ApiKey string `json:"apiKey" dc:"调用凭证/密钥"`
|
||
Enabled *bool `json:"enabled" dc:"启用"`
|
||
RequestHeadMapping map[string]string `json:"requestHeadMapping" dc:"请求头映射"`
|
||
RequestBodyMapping map[string]any `json:"requestBodyMapping" dc:"请求体映射"`
|
||
RequestBusinessFieldMapping map[string]string `json:"requestBusinessFieldMapping" dc:"业务字段映射"`
|
||
ResponseMapping map[string]any `json:"responseMapping" dc:"返回映射"`
|
||
ResponseBodyMapping map[string]string `json:"responseBodyMapping" dc:"返回主体映射"`
|
||
ResponseBusinessFieldMapping map[string]string `json:"responseBusinessFieldMapping" dc:"业务字段映射"`
|
||
MaxConcurrency int `json:"maxConcurrency" dc:"最大并发数(默认10)"`
|
||
TokenMapping *entity.TokenMapping `json:"tokenMapping" dc:"token映射"`
|
||
AsyncTaskMapping *entity.AsyncTaskMapping `json:"asyncTaskMapping" dc:"异步任务映射"`
|
||
TokenPredictPrice float64 `json:"tokenPredictPrice" dc:"模型Token预估价格"`
|
||
TokenPredictPriceUnit string `json:"tokenPredictPriceUnit" dc:"模型Token预估价格单位"`
|
||
MaxTokens int `json:"maxTokens" dc:"最大token数"`
|
||
MinDuration int `json:"minDuration" dc:"最小时长"`
|
||
MaxDuration int `json:"maxDuration" dc:"最大时长"`
|
||
LastFrame string `json:"lastFrame" dc:"视频的尾帧图像"`
|
||
}
|
||
|
||
type DeleteModelManageReq struct {
|
||
g.Meta `path:"/deleteModelManage" method:"delete" tags:"模型管理" summary:"删除模型配置" dc:"删除指定ID的模型配置"`
|
||
Id int64 `p:"id" json:"id,string" v:"required#id不能为空" dc:"配置ID"`
|
||
}
|
||
|
||
type GetModelManage struct {
|
||
ChatModel *bool `json:"chatModel" dc:"对话模型"`
|
||
Creator string `json:"creator" dc:"创建人"`
|
||
ModelName string `json:"modelName" dc:"模型名称"`
|
||
}
|
||
|
||
type GetModelManageReq struct {
|
||
g.Meta `path:"/getModelManage" method:"get" tags:"模型管理" summary:"获取模型配置" dc:"获取指定ID的模型配置"`
|
||
Id int64 `p:"id" json:"id,string" v:"required#id不能为空" dc:"配置ID"`
|
||
}
|
||
|
||
type GetModelManageRes struct {
|
||
ModelManage *entity.ModelManage `json:"modelManage"`
|
||
}
|
||
|
||
type GetChatModelReq struct {
|
||
g.Meta `path:"/getChatModel" method:"get" tags:"模型管理" summary:"获取聊天模型" dc:"获取聊天模型"`
|
||
}
|
||
|
||
type GetChatModelRes struct {
|
||
ModelManage *entity.ModelManage `json:"modelManage"`
|
||
}
|
||
|
||
// ListModelManageReq 配置列表
|
||
type ListModelManageReq struct {
|
||
g.Meta `path:"/listModelManage" method:"get" tags:"模型管理" summary:"模型配置列表" dc:"分页获取模型配置列表"`
|
||
*beans.Page `json:"page"`
|
||
Id int64 `p:"id" json:"id,string" dc:"配置ID"`
|
||
ModelName string `p:"modelName" json:"modelName" dc:"模型名称(模糊查询,可选)"`
|
||
ModelType model.ModelType `p:"modelType" json:"modelType" dc:"模型类型"`
|
||
IsSameType bool `p:"isSameType" json:"isSameType" dc:"是否相同类型"`
|
||
Creator string `json:"creator" dc:"创建人"`
|
||
}
|
||
|
||
type ListModelManageRes struct {
|
||
List []*entity.ModelManage `json:"list" dc:"列表数据"`
|
||
Total int `json:"total" dc:"总数"`
|
||
}
|
||
|
||
type CheckChatModelReq struct {
|
||
g.Meta `path:"/checkChatModel" method:"get" tags:"模型管理" summary:"检查是否为聊天模型" dc:"检查是否为聊天模型"`
|
||
}
|
||
|
||
type CheckChatModelRes struct {
|
||
IsChatModel bool `json:"isChatModel" dc:"是否为聊天模型"`
|
||
}
|
||
|
||
// ModelTypeReq 模型类型列表(分页)
|
||
type ModelTypeReq struct {
|
||
g.Meta `path:"/modelType" method:"get" tags:"模型管理" summary:"模型类型列表" dc:"分页获取模型类型列表"`
|
||
}
|
||
|
||
type ModelTypeRes struct {
|
||
List []*model.TypeTree `json:"list" dc:"模型类型ID到名称的映射"`
|
||
}
|
||
|
||
type ModelSupplierReq struct {
|
||
g.Meta `path:"/modelSupplier" method:"get" tags:"模型管理" summary:"获取运营商列表" dc:"获取运营商列表"`
|
||
}
|
||
|
||
type ModelSupplierRes struct {
|
||
List []*public.Option `json:"list" dc:"运营商名称到ID的映射"`
|
||
}
|
||
|
||
// BuildSchemaMappingReq 构建 Schema 映射请求
|
||
type BuildSchemaMappingReq struct {
|
||
g.Meta `path:"/buildSchemaMapping" method:"post" tags:"模型管理" summary:"自动构建 Schema 映射" dc:"根据模型类型和 Schema JSON,自动生成业务字段映射"`
|
||
ModelType int `json:"modelType" v:"required#模型类型不能为空" dc:"模型类型编码"`
|
||
Schema map[string]any `json:"schema" v:"required#Schema不能为空" dc:"模型的完整 Schema JSON"`
|
||
}
|
||
|
||
type BuildSchemaMappingRes struct {
|
||
SchemaMapping map[string]any `json:"schemaMapping" dc:"生成的 Schema 映射 JSON"`
|
||
}
|
||
|
||
// ReferenceSystemModelReq 引用系统模型请求:用户只填 apiKey + 个人开关,配置实时跟随系统模型
|
||
type ReferenceSystemModelReq struct {
|
||
g.Meta `path:"/referenceSystemModel" method:"post" tags:"模型管理" summary:"引用系统模型" dc:"用户引用系统模型,只填 apiKey 等个人字段,配置实时跟随系统模型(不再全量拷贝)"`
|
||
SystemModelId int64 `json:"systemModelId" v:"required#系统模型ID不能为空" dc:"被引用的系统模型ID"`
|
||
ApiKey string `json:"apiKey" v:"required#apiKey不能为空" dc:"调用凭证/密钥"`
|
||
ChatModel *bool `json:"chatModel" dc:"设为我的会话模型"`
|
||
Enabled *bool `json:"enabled" dc:"启用(默认启用)"`
|
||
}
|
||
|
||
type ReferenceSystemModelRes struct {
|
||
Id int64 `json:"id,string" dc:"引用行ID"`
|
||
}
|