package dto import ( "model-gateway/model/entity" "gitea.com/red-future/common/beans" "github.com/gogf/gf/v2/frame/g" ) // CreateModelReq 添加模型配置 type CreateModelReq struct { g.Meta `path:"/createModel" method:"post" tags:"模型管理" summary:"创建模型配置" dc:"添加新的模型配置"` ModelName string `p:"modelName" json:"modelName" v:"required#模型名称不能为空" dc:"模型名称(唯一标识)"` ModelType int `p:"modelType" json:"modelType" v:"required#模型类型不能为空" dc:"模型类型"` BaseURL string `p:"baseUrl" json:"baseUrl" v:"required#模型地址不能为空" dc:"模型服务地址"` HttpMethod string `p:"httpMethod" json:"httpMethod" dc:"请求方式:GET/POST(默认POST)"` HeadMsg map[string]any `p:"headMsg" json:"headMsg" dc:"请求头JSON结构"` IsPrivate *int `p:"isPrivate" json:"isPrivate" dc:"是否私有化:0-私有 1-公共"` Enabled *int `p:"enabled" json:"enabled" dc:"是否启用:0-停用 1-启用"` IsChatModel *int `p:"isChatModel" json:"isChatModel" dc:"是否为对话模型:0-否 1-是"` IsAsync *int `p:"isAsync" json:"isAsync" dc:"是否异步:0-同步 1-异步"` IsStream *int `p:"isStream" json:"isStream" dc:"是否流式:0-非流式 1-流式"` IsOwner *int `p:"isOwner" json:"isOwner" dc:"是否为所有者:0-否 1-是"` ApiKey string `p:"apiKey" json:"apiKey" dc:"调用凭证/密钥"` Form []map[string]any `p:"form" json:"form" dc:"动态表单配置"` RequestMapping map[string]any `p:"requestMapping" json:"requestMapping" dc:"请求映射"` ResponseMapping map[string]any `p:"responseMapping" json:"responseMapping" dc:"返回映射"` ResponseBody string `p:"responseBody" json:"responseBody" dc:"返回主体"` ResponseTokenField string `p:"responseTokenField" json:"responseTokenField" dc:"响应中消耗token的字段映射"` OperatorName string `p:"operatorName" json:"operatorName" dc:"运营商名称"` TokenConfig map[string]any `p:"tokenConfig" json:"tokenConfig" dc:"token计算配置"` ExtendMapping map[string]any `p:"extendMapping" json:"extendMapping" dc:"附加映射"` QueryConfig map[string]any `p:"queryConfig" json:"queryConfig" dc:"查询/回调配置"` StreamConfig map[string]any `p:"streamConfig" json:"streamConfig" dc:"流式输出配置"` FirstFrame string `p:"firstFrame" json:"firstFrame" dc:"首帧图片参数"` LastFrame string `p:"lastFrame" json:"lastFrame" dc:"尾帧图片参数"` MaxConcurrency int `p:"maxConcurrency" json:"maxConcurrency" dc:"最大并发数(默认10)"` TimeoutSeconds int `p:"timeoutSeconds" json:"timeoutSeconds" dc:"请求超时时间(秒,默认600)"` RetryTimes int `p:"retryTimes" json:"retryTimes" dc:"失败重试次数(默认3)"` AutoCleanSeconds int `p:"autoCleanSeconds" json:"autoCleanSeconds" dc:"任务完成后自动清理时间(秒,默认86400)"` CallbackUrl string `p:"callbackUrl" json:"callbackUrl" dc:"回调地址"` } type CreateModelRes struct { ID int64 `json:"id,string" dc:"配置ID"` } type UpdateModelReq struct { g.Meta `path:"/updateModel" method:"put" tags:"模型管理" summary:"更新模型配置" dc:"更新指定ID的模型配置"` ID int64 `p:"id" json:"id" v:"required#id不能为空" dc:"配置ID"` ModelName string `p:"modelName" json:"modelName" dc:"模型名称"` ModelType int `p:"modelType" json:"modelType" dc:"模型类型"` BaseURL string `p:"baseUrl" json:"baseUrl" dc:"模型服务地址"` HttpMethod string `p:"httpMethod" json:"httpMethod" dc:"请求方式:GET/POST"` HeadMsg map[string]any `p:"headMsg" json:"headMsg" dc:"请求头JSON结构"` IsPrivate *int `p:"isPrivate" json:"isPrivate" dc:"是否私有化:0-私有 1-公共"` Enabled *int `p:"enabled" json:"enabled" dc:"是否启用:0-停用 1-启用"` IsChatModel *int `p:"isChatModel" json:"isChatModel" dc:"是否为对话模型:0-否 1-是"` IsAsync *int `p:"isAsync" json:"isAsync" dc:"是否异步:0-同步 1-异步"` IsStream *int `p:"isStream" json:"isStream" dc:"是否流式:0-非流式 1-流式"` IsOwner *int `p:"isOwner" json:"isOwner" dc:"是否为所有者:0-否 1-是"` ApiKey string `p:"apiKey" json:"apiKey" dc:"调用凭证/密钥"` Form []map[string]any `p:"form" json:"form" dc:"动态表单配置"` RequestMapping map[string]any `p:"requestMapping" json:"requestMapping" dc:"请求映射"` ResponseMapping map[string]any `p:"responseMapping" json:"responseMapping" dc:"返回映射"` ResponseBody string `p:"responseBody" json:"responseBody" dc:"返回主体"` ResponseTokenField string `p:"responseTokenField" json:"responseTokenField" dc:"响应中消耗token的字段映射"` OperatorName string `p:"operatorName" json:"operatorName" dc:"运营商名称"` TokenConfig map[string]any `p:"tokenConfig" json:"tokenConfig" dc:"token计算配置"` ExtendMapping map[string]any `p:"extendMapping" json:"extendMapping" dc:"附加映射"` QueryConfig map[string]any `p:"queryConfig" json:"queryConfig" dc:"查询/回调配置"` StreamConfig map[string]any `p:"streamConfig" json:"streamConfig" dc:"流式输出配置"` FirstFrame string `p:"firstFrame" json:"firstFrame" dc:"首帧图片参数"` LastFrame string `p:"lastFrame" json:"lastFrame" dc:"尾帧图片参数"` MaxConcurrency int `p:"maxConcurrency" json:"maxConcurrency" dc:"最大并发数"` TimeoutSeconds int `p:"timeoutSeconds" json:"timeoutSeconds" dc:"请求超时时间(秒)"` RetryTimes int `p:"retryTimes" json:"retryTimes" dc:"失败重试次数"` AutoCleanSeconds int `p:"autoCleanSeconds" json:"autoCleanSeconds" dc:"任务完成后自动清理时间(秒)"` CallbackUrl string `p:"callbackUrl" json:"callbackUrl" dc:"回调地址"` } type UpdateModelRes struct { ID int64 `json:"id,string" dc:"配置ID"` } // DeleteModelReq 删除模型配置 type DeleteModelReq struct { g.Meta `path:"/deleteModel" method:"delete" tags:"模型管理" summary:"删除模型配置" dc:"删除指定ID的模型配置"` ID int64 `p:"id" json:"id,string" v:"required#id不能为空" dc:"配置ID"` } type DeleteModelRes struct { ID int64 `json:"id,string" dc:"配置ID"` } // GetModelReq 获取模型配置详情 type GetModelReq struct { g.Meta `path:"/getModel" method:"get" tags:"模型管理" summary:"获取模型配置" dc:"根据模型ID获取配置详情"` ID int64 `p:"id" json:"id,string" dc:"配置ID"` Creator string `p:"creator" json:"creator" dc:"创建人"` IsChatModel *int `p:"isChatModel" json:"isChatModel" dc:"是否为聊天模型"` ModelName string `p:"modelName" json:"modelName" dc:"模型名称(唯一标识)"` } type GetModelRes struct { Model *entity.AsynchModel `json:"model" dc:"模型配置详情"` } // ListModelReq 配置列表 type ListModelReq struct { g.Meta `path:"/listModel" method:"get" tags:"模型管理" summary:"模型配置列表" dc:"分页获取模型配置列表"` Page *beans.Page `json:"page"` ModelName string `p:"modelName" json:"modelName" dc:"模型名称(模糊查询,可选)"` ModelType int `p:"modelType" json:"modelType" dc:"模型类型"` Enabled *int `p:"enabled" json:"enabled" dc:"是否启用:0-禁用,1-启用"` IsPrivate *int `p:"isPrivate" json:"isPrivate" dc:"是否私有化 0-私有 1-公共"` IsOwner *int `p:"isOwner" json:"isOwner" dc:"是否为所有者 0-否 1-是"` Creator string `p:"creator" json:"creator" dc:"创建人"` } type ListModelRes struct { List any `json:"list" dc:"列表数据"` Total int `json:"total" dc:"总数"` } // AutoTuneReq 动态调参(由上层定时任务每小时触发一次) type AutoTuneReq struct { g.Meta `path:"/autoTune" method:"post" tags:"模型管理" summary:"动态调参" dc:"按 model_name 维度统计指定时间窗口内执行耗时(P90),动态生成运行时 max_concurrency/queue_limit(不超过配置上限),写入 Redis 供 Worker/CreateTask 使用;windowSeconds 不传默认 3600"` WindowSeconds int `p:"windowSeconds" json:"windowSeconds" dc:"统计窗口秒数;不传/<=0 默认 3600(1小时)"` } type AutoTuneRes struct { List any `json:"list" dc:"调参结果列表"` } type ModelTypeModelItem struct { ID int64 `json:"id" dc:"模型主键ID"` Name string `json:"name" dc:"模型名称"` Form any `json:"form" dc:"动态表单配置(JSON数组),用于前端渲染"` } // ListModelTypeReq 模型类型列表(分页) type ListTypeReq struct { g.Meta `path:"/listType" method:"get" tags:"模型类型列表" summary:"模型类型列表" dc:"分页获取模型类型列表"` } 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"` } type UpdateChatModelRes struct { ID int64 `json:"id,string" dc:"模型ID"` } type GetIsChatModelReq struct { g.Meta `path:"/getIsChatModel" method:"get" tags:"模型管理" summary:"获取模型是否为聊天模型" dc:"根据模型ID获取是否为聊天模型"` } type GetIsChatModelRes struct { Model any `json:"model" dc:"模型详情"` } // NodeFormField 节点表单 type NodeFormField struct { Value any `json:"value" dc:"字段值"` Field string `json:"field" dc:"字段标识"` Label string `json:"label" dc:"字段标签"` Type string `json:"type" dc:"字段类型"` Required bool `json:"required" dc:"是否必填"` Default any `json:"default,omitempty" dc:"默认值"` Options []SelectOption `json:"options" dc:"下拉选项列表"` FieldConstraint any `json:"fieldConstraint" dc:"字段约束"` } type SelectOption struct { Label string `json:"label" dc:"选项标签"` Value string `json:"value" dc:"选项值"` }