diff --git a/config.yml b/config.yml index 1fee1bf..8491f74 100644 --- a/config.yml +++ b/config.yml @@ -29,14 +29,14 @@ database: redis: default: - address: 116.204.74.41:6379 + address: 192.168.3.30:6379 db: 0 consul: - address: 116.204.74.41:8500 + address: 192.168.3.30:8500 jaeger: - addr: 116.204.74.41:4318 + addr: 192.168.3.30:4318 # 本地调试用:可选自动执行 worker/cleaner(默认关闭) asynch: diff --git a/dao/model_dao.go b/dao/model_dao.go index 7e3bf9f..cd13730 100644 --- a/dao/model_dao.go +++ b/dao/model_dao.go @@ -114,6 +114,25 @@ func (d *modelDao) List(ctx context.Context, pageNum, pageSize int, modelNameLik return } +func (d *modelDao) GetByIsChatModel(ctx context.Context) (m *entity.AsynchModel, err error) { + userInfo, err := utils.GetUserInfo(ctx) + if err != nil { + return nil, err + } + r, err := gfdb.DB(ctx).Model(ctx, public.TableNameModel). + Where(entity.AsynchModelCol.IsChatModel, 1). + Where(entity.AsynchModelCol.Creator, userInfo.UserName). + One() + if err != nil { + return nil, err + } + if r.IsEmpty() { + return nil, nil + } + err = r.Struct(&m) + return +} + // ListByCreatorAndPlatform 普通用户:平台公共(tenant_id=0) + 自己创建的(creator=xxx) func (d *modelDao) ListByCreatorAndPlatform(ctx context.Context, creator string, pageNum, pageSize int, modelNameLike string) (list []*entity.AsynchModel, total int64, err error) { // 构建 Where 条件 @@ -200,25 +219,6 @@ WHERE deleted_at IS NULL return } -func (d *modelDao) GetByIsChatModel(ctx context.Context) (m *entity.AsynchModel, err error) { - userInfo, err := utils.GetUserInfo(ctx) - if err != nil { - return nil, err - } - r, err := gfdb.DB(ctx).Model(ctx, public.TableNameModel). - Where(entity.AsynchModelCol.IsChatModel, 1). - Where(entity.AsynchModelCol.Creator, userInfo.UserName). - One() - if err != nil { - return nil, err - } - if r.IsEmpty() { - return nil, nil - } - err = r.Struct(&m) - return -} - // ListAll 用于分组展示:查询全部模型(不按类型过滤,类型拆分在 service 层处理) func (d *modelDao) ListAll(ctx context.Context) (list []*entity.AsynchModel, err error) { r, err := gfdb.DB(ctx).Model(ctx, public.TableNameModel). diff --git a/go.sum b/go.sum index 5457ecb..044b9a6 100644 --- a/go.sum +++ b/go.sum @@ -426,6 +426,7 @@ gonum.org/v1/gonum v0.16.0/go.mod h1:fef3am4MQ93R2HHpKnLk4/Tbh/s0+wqD5nfa6Pnwy4E google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= diff --git a/main.go b/main.go index 28b7e77..d956e49 100644 --- a/main.go +++ b/main.go @@ -33,14 +33,14 @@ func main() { // 本地调试:可选自动触发 worker/cleaner(由配置文件控制) startAutoRunner(ctx) - // 监听退出信号,确保 Ctrl+C 能完整退出(停止 worker/cleaner 并关闭 http server) + // 监听退出信号,确保 Ctrl+C 能完整退出(停止 worker/cleaner 并关闭 gateway server) quit := make(chan os.Signal, 1) signal.Notify(quit, os.Interrupt, syscall.SIGTERM) <-quit g.Log().Infof(ctx, "[main] 收到退出信号,开始优雅退出...") cancel() - // 关闭 http server(RouteRegister 内部是 go Httpserver.Run() 启动的) + // 关闭 gateway server(RouteRegister 内部是 go Httpserver.Run() 启动的) _ = http.Httpserver.Shutdown() } diff --git a/model/dto/model_dto.go b/model/dto/model_dto.go index d261cd6..2b2ed66 100644 --- a/model/dto/model_dto.go +++ b/model/dto/model_dto.go @@ -10,7 +10,7 @@ type CreateModelReq struct { g.Meta `path:"/createModel" method:"post" tags:"模型管理" summary:"创建模型配置" dc:"添加新的模型配置"` ModelName string `p:"modelName" json:"modelName" v:"required#modelName不能为空" dc:"模型名称(唯一标识)"` ModelType int `p:"modelType" json:"modelType" v:"required#modelType不能为空" dc:"模型类型:1-文本生成 2-图像生成 3-语音 4-视频 5-多模态"` - BaseURL string `p:"baseUrl" json:"baseUrl" v:"required#baseUrl不能为空" dc:"模型服务基础地址(如 http(s)://host:port)"` + BaseURL string `p:"baseUrl" json:"baseUrl" v:"required#baseUrl不能为空" dc:"模型服务基础地址(如 gateway(s)://host:port)"` HttpMethod string `p:"httpMethod" json:"httpMethod" dc:"请求方式:GET/POST(默认POST)"` HeadMsg string `p:"headMsg" json:"headMsg" dc:"请求头绑定(支持多个,逗号分隔),示例:Authorization:Bearer xxx,Content-Type:application/json"` IsPrivate *int `p:"isPrivate" json:"isPrivate" v:"in:0,1#私有化参数只能为0或1" dc:"是否私有化:0-私有(默认) 1-公共"` diff --git a/service/file_detect.go b/service/file_detect.go index cf17e65..1ec85fb 100644 --- a/service/file_detect.go +++ b/service/file_detect.go @@ -11,7 +11,7 @@ func DetectFileType(data []byte) (contentType string, ext string) { return "application/octet-stream", "" } ct := http.DetectContentType(data) - // http.DetectContentType 可能带 charset 等参数:text/plain; charset=utf-8 + // gateway.DetectContentType 可能带 charset 等参数:text/plain; charset=utf-8 if idx := strings.Index(ct, ";"); idx > 0 { ct = strings.TrimSpace(ct[:idx]) }