From 8a73d50beb30b61ed329b8399797bdab341a1acb Mon Sep 17 00:00:00 2001 From: mixinju Date: Tue, 29 Jul 2025 22:58:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BD=BF=E7=94=A8thrift=5Fvalidator?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C-?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E7=A1=AC=E7=BC=96=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/handler/coze/loop/apis/wire_gen.go | 1 + .../domain/evaluator/evaluator_validator.go | 33 ++++++++++---- ...coze.loop.evaluation.eval_set_validator.go | 33 +++++++------- ...oze.loop.evaluation.evaluator_validator.go | 45 +++++++++++++++++-- .../llm/domain/runtime/runtime_validator.go | 9 ++++ .../coze.loop.llm.runtime_validator.go | 24 ++++++---- .../application/evaluation_set_app.go | 9 ++-- .../evaluation/application/evaluator_app.go | 42 ++++++----------- .../evaluation/application/wire_gen.go | 2 +- backend/modules/llm/application/runtime.go | 37 +++------------ backend/modules/llm/application/wire_gen.go | 2 +- .../model/model_request_record.gen.go | 4 +- .../query/model_request_record.gen.go | 2 +- .../coze.loop.evaluation.eval_set.thrift | 6 +-- .../coze.loop.evaluation.evaluator.thrift | 18 ++++---- .../loop/evaluation/domain/evaluator.thrift | 14 +++--- .../loop/llm/coze.loop.llm.runtime.thrift | 8 ++-- .../coze/loop/llm/domain/runtime.thrift | 6 +-- 18 files changed, 165 insertions(+), 130 deletions(-) diff --git a/backend/api/handler/coze/loop/apis/wire_gen.go b/backend/api/handler/coze/loop/apis/wire_gen.go index e83641abc..d6ab66eb7 100644 --- a/backend/api/handler/coze/loop/apis/wire_gen.go +++ b/backend/api/handler/coze/loop/apis/wire_gen.go @@ -8,6 +8,7 @@ package apis import ( "context" + "github.com/cloudwego/kitex/pkg/endpoint" "github.com/coze-dev/coze-loop/backend/infra/ck" "github.com/coze-dev/coze-loop/backend/infra/db" diff --git a/backend/kitex_gen/coze/loop/evaluation/domain/evaluator/evaluator_validator.go b/backend/kitex_gen/coze/loop/evaluation/domain/evaluator/evaluator_validator.go index bf8c17615..ae1775294 100644 --- a/backend/kitex_gen/coze/loop/evaluation/domain/evaluator/evaluator_validator.go +++ b/backend/kitex_gen/coze/loop/evaluation/domain/evaluator/evaluator_validator.go @@ -70,15 +70,32 @@ func (p *EvaluatorContent) IsValid() error { return nil } func (p *Evaluator) IsValid() error { - if p.BaseInfo != nil { - if err := p.BaseInfo.IsValid(); err != nil { - return fmt.Errorf("field BaseInfo not valid, %w", err) - } + if p.EvaluatorID == nil { + return fmt.Errorf("field EvaluatorID not_nil rule failed") } - if p.CurrentVersion != nil { - if err := p.CurrentVersion.IsValid(); err != nil { - return fmt.Errorf("field CurrentVersion not valid, %w", err) - } + if p.WorkspaceID == nil { + return fmt.Errorf("field WorkspaceID not_nil rule failed") + } + if p.EvaluatorType == nil { + return fmt.Errorf("field EvaluatorType not_nil rule failed") + } + if p.Name == nil { + return fmt.Errorf("field Name not_nil rule failed") + } + if p.Description == nil { + return fmt.Errorf("field Description not_nil rule failed") + } + if p.BaseInfo == nil { + return fmt.Errorf("field BaseInfo not_nil rule failed") + } + if err := p.BaseInfo.IsValid(); err != nil { + return fmt.Errorf("field BaseInfo not valid, %w", err) + } + if p.CurrentVersion == nil { + return fmt.Errorf("field CurrentVersion not_nil rule failed") + } + if err := p.CurrentVersion.IsValid(); err != nil { + return fmt.Errorf("field CurrentVersion not valid, %w", err) } return nil } diff --git a/backend/kitex_gen/coze/loop/evaluation/eval_set/coze.loop.evaluation.eval_set_validator.go b/backend/kitex_gen/coze/loop/evaluation/eval_set/coze.loop.evaluation.eval_set_validator.go index 7845af87c..4840b3cac 100644 --- a/backend/kitex_gen/coze/loop/evaluation/eval_set/coze.loop.evaluation.eval_set_validator.go +++ b/backend/kitex_gen/coze/loop/evaluation/eval_set/coze.loop.evaluation.eval_set_validator.go @@ -22,23 +22,26 @@ var ( ) func (p *CreateEvaluationSetRequest) IsValid() error { - if p.Name != nil { - if len(*p.Name) < int(1) { - return fmt.Errorf("field Name min_len rule failed, current value: %d", len(*p.Name)) - } - if len(*p.Name) > int(255) { - return fmt.Errorf("field Name max_len rule failed, current value: %d", len(*p.Name)) - } + if p.Name == nil { + return fmt.Errorf("field Name not_nil rule failed") } - if p.Description != nil { - if len(*p.Description) > int(2048) { - return fmt.Errorf("field Description max_len rule failed, current value: %d", len(*p.Description)) - } + if len(*p.Name) < int(1) { + return fmt.Errorf("field Name min_len rule failed, current value: %d", len(*p.Name)) } - if p.EvaluationSetSchema != nil { - if err := p.EvaluationSetSchema.IsValid(); err != nil { - return fmt.Errorf("field EvaluationSetSchema not valid, %w", err) - } + if len(*p.Name) > int(255) { + return fmt.Errorf("field Name max_len rule failed, current value: %d", len(*p.Name)) + } + if p.Description == nil { + return fmt.Errorf("field Description not_nil rule failed") + } + if len(*p.Description) > int(2048) { + return fmt.Errorf("field Description max_len rule failed, current value: %d", len(*p.Description)) + } + if p.EvaluationSetSchema == nil { + return fmt.Errorf("field EvaluationSetSchema not_nil rule failed") + } + if err := p.EvaluationSetSchema.IsValid(); err != nil { + return fmt.Errorf("field EvaluationSetSchema not valid, %w", err) } if p.BizCategory != nil { if len(*p.BizCategory) > int(128) { diff --git a/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go b/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go index 348b0e990..7f7e49855 100644 --- a/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go +++ b/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go @@ -85,10 +85,11 @@ func (p *GetEvaluatorResponse) IsValid() error { return nil } func (p *CreateEvaluatorRequest) IsValid() error { - if p.Evaluator != nil { - if err := p.Evaluator.IsValid(); err != nil { - return fmt.Errorf("field Evaluator not valid, %w", err) - } + if p.Evaluator == nil { + return fmt.Errorf("field Evaluator not_nil rule failed") + } + if err := p.Evaluator.IsValid(); err != nil { + return fmt.Errorf("field Evaluator not valid, %w", err) } if p.Base != nil { if err := p.Base.IsValid(); err != nil { @@ -132,6 +133,24 @@ func (p *UpdateEvaluatorDraftResponse) IsValid() error { return nil } func (p *UpdateEvaluatorRequest) IsValid() error { + _src := []int64{int64(0)} + for _, src := range _src { + if p.EvaluatorID == int64(src) { + return fmt.Errorf("field EvaluatorID not_in rule failed, current value: %v", p.EvaluatorID) + } + } + _src1 := []int64{int64(0)} + for _, src := range _src1 { + if p.WorkspaceID == int64(src) { + return fmt.Errorf("field WorkspaceID not_in rule failed, current value: %v", p.WorkspaceID) + } + } + if p.Name == nil { + return fmt.Errorf("field Name not_nil rule failed") + } + if p.Description == nil { + return fmt.Errorf("field Description not_nil rule failed") + } if p.Base != nil { if err := p.Base.IsValid(); err != nil { return fmt.Errorf("field Base not valid, %w", err) @@ -227,6 +246,24 @@ func (p *BatchGetEvaluatorVersionsResponse) IsValid() error { return nil } func (p *SubmitEvaluatorVersionRequest) IsValid() error { + _src := []int64{int64(0)} + for _, src := range _src { + if p.WorkspaceID == int64(src) { + return fmt.Errorf("field WorkspaceID not_in rule failed, current value: %v", p.WorkspaceID) + } + } + _src1 := []int64{int64(0)} + for _, src := range _src1 { + if p.EvaluatorID == int64(src) { + return fmt.Errorf("field EvaluatorID not_in rule failed, current value: %v", p.EvaluatorID) + } + } + if p.Version == nil { + return fmt.Errorf("field Version not_nil rule failed") + } + if p.Description == nil { + return fmt.Errorf("field Description not_nil rule failed") + } if p.Base != nil { if err := p.Base.IsValid(); err != nil { return fmt.Errorf("field Base not valid, %w", err) diff --git a/backend/kitex_gen/coze/loop/llm/domain/runtime/runtime_validator.go b/backend/kitex_gen/coze/loop/llm/domain/runtime/runtime_validator.go index 13883ab67..482059c7f 100644 --- a/backend/kitex_gen/coze/loop/llm/domain/runtime/runtime_validator.go +++ b/backend/kitex_gen/coze/loop/llm/domain/runtime/runtime_validator.go @@ -69,5 +69,14 @@ func (p *Tool) IsValid() error { return nil } func (p *BizParam) IsValid() error { + if p.WorkspaceID == nil { + return fmt.Errorf("field WorkspaceID not_nil rule failed") + } + if p.Scenario == nil { + return fmt.Errorf("field Scenario not_nil rule failed") + } + if p.ScenarioEntityID == nil { + return fmt.Errorf("field ScenarioEntityID not_nil rule failed") + } return nil } diff --git a/backend/kitex_gen/coze/loop/llm/runtime/coze.loop.llm.runtime_validator.go b/backend/kitex_gen/coze/loop/llm/runtime/coze.loop.llm.runtime_validator.go index a8b751f3c..7e1302444 100644 --- a/backend/kitex_gen/coze/loop/llm/runtime/coze.loop.llm.runtime_validator.go +++ b/backend/kitex_gen/coze/loop/llm/runtime/coze.loop.llm.runtime_validator.go @@ -22,15 +22,23 @@ var ( ) func (p *ChatRequest) IsValid() error { - if p.ModelConfig != nil { - if err := p.ModelConfig.IsValid(); err != nil { - return fmt.Errorf("field ModelConfig not valid, %w", err) - } + if p.ModelConfig == nil { + return fmt.Errorf("field ModelConfig not_nil rule failed") } - if p.BizParam != nil { - if err := p.BizParam.IsValid(); err != nil { - return fmt.Errorf("field BizParam not valid, %w", err) - } + if err := p.ModelConfig.IsValid(); err != nil { + return fmt.Errorf("field ModelConfig not valid, %w", err) + } + if len(p.Messages) < int(1) { + return fmt.Errorf("field Messages MinLen rule failed, current value: %v", p.Messages) + } + if len(p.Tools) < int(1) { + return fmt.Errorf("field Tools MinLen rule failed, current value: %v", p.Tools) + } + if p.BizParam == nil { + return fmt.Errorf("field BizParam not_nil rule failed") + } + if err := p.BizParam.IsValid(); err != nil { + return fmt.Errorf("field BizParam not valid, %w", err) } if p.Base != nil { if err := p.Base.IsValid(); err != nil { diff --git a/backend/modules/evaluation/application/evaluation_set_app.go b/backend/modules/evaluation/application/evaluation_set_app.go index 6dd473041..0e0f24765 100644 --- a/backend/modules/evaluation/application/evaluation_set_app.go +++ b/backend/modules/evaluation/application/evaluation_set_app.go @@ -71,12 +71,11 @@ func (e *EvaluationSetApplicationImpl) CreateEvaluationSet(ctx context.Context, if req == nil { return nil, errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("req is nil")) } - if req.Name == nil { - return nil, errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("name is nil")) - } - if req.EvaluationSetSchema == nil { - return nil, errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("schema is nil")) + + if err = req.IsValid(); err != nil { + return nil, errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg(err.Error())) } + // 鉴权 err = e.auth.Authorization(ctx, &rpc.AuthorizationParam{ ObjectID: strconv.FormatInt(req.WorkspaceID, 10), diff --git a/backend/modules/evaluation/application/evaluator_app.go b/backend/modules/evaluation/application/evaluator_app.go index aa3d8bfae..b0dd7eba4 100644 --- a/backend/modules/evaluation/application/evaluator_app.go +++ b/backend/modules/evaluation/application/evaluator_app.go @@ -216,23 +216,12 @@ func (e *EvaluatorHandlerImpl) CreateEvaluator(ctx context.Context, request *eva func (e *EvaluatorHandlerImpl) checkCreateEvaluatorRequest(ctx context.Context, request *evaluatorservice.CreateEvaluatorRequest) (err error) { if request == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("req is nil")) - } - if request.Evaluator == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("evaluator_version is nil")) - } - if request.Evaluator.Name == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("name is nil")) - } - if request.Evaluator.WorkspaceID == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("workspace id is nil")) + return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("request is nil")) } - if request.Evaluator.EvaluatorType == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("evaluator_version type is nil")) - } - if request.Evaluator.CurrentVersion == nil { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("current version is nil")) + if err = request.IsValid(); err != nil { + return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg(err.Error())) } + if request.Evaluator.CurrentVersion.EvaluatorContent == nil { return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("evaluator_version content is nil")) } @@ -321,11 +310,10 @@ func validateUpdateEvaluatorRequest(ctx context.Context, request *evaluatorservi if request == nil { return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("req is nil")) } - if request.GetEvaluatorID() == 0 { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("id is 0")) - } - if request.WorkspaceID == 0 { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("space id is 0")) + + err := request.IsValid() + if err != nil { + return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg(err.Error())) } if utf8.RuneCountInString(request.GetName()) > consts.MaxEvaluatorNameLength { return errorx.NewByCode(errno.EvaluatorNameExceedMaxLengthCode) @@ -559,20 +547,18 @@ func (e *EvaluatorHandlerImpl) SubmitEvaluatorVersion(ctx context.Context, reque } func (e *EvaluatorHandlerImpl) validateSubmitEvaluatorVersionRequest(ctx context.Context, request *evaluatorservice.SubmitEvaluatorVersionRequest) error { - if request.GetEvaluatorID() == 0 { - return errorx.NewByCode(errno.InvalidEvaluatorIDCode, errorx.WithExtraMsg("[validateSubmitEvaluatorVersionRequest] evaluator_version id is empty")) - } - if len(request.GetVersion()) == 0 { - return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("[validateSubmitEvaluatorVersionRequest] evaluator_version version is empty")) + if err := request.IsValid(); err != nil { + return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg(err.Error())) } + if len(request.GetVersion()) > consts.MaxEvaluatorVersionLength { return errorx.NewByCode(errno.EvaluatorVersionExceedMaxLengthCode) } - _, err := semver.StrictNewVersion(request.GetVersion()) - if err != nil { + if _, err := semver.StrictNewVersion(request.GetVersion()); err != nil { return errorx.NewByCode(errno.CommonInvalidParamCode, errorx.WithExtraMsg("[validateSubmitEvaluatorVersionRequest] evaluator_version version does not follow SemVer specification")) } - if len(request.GetDescription()) > consts.MaxEvaluatorVersionDescLength { + + if utf8.RuneCountInString(request.GetDescription()) > consts.MaxEvaluatorVersionDescLength { return errorx.NewByCode(errno.EvaluatorVersionDescriptionExceedMaxLengthCode) } // 机审 diff --git a/backend/modules/evaluation/application/wire_gen.go b/backend/modules/evaluation/application/wire_gen.go index fb801e726..dde100ba2 100644 --- a/backend/modules/evaluation/application/wire_gen.go +++ b/backend/modules/evaluation/application/wire_gen.go @@ -7,6 +7,7 @@ package application import ( + "context" "github.com/coze-dev/coze-loop/backend/infra/db" "github.com/coze-dev/coze-loop/backend/infra/external/audit" "github.com/coze-dev/coze-loop/backend/infra/external/benefit" @@ -49,7 +50,6 @@ import ( "github.com/coze-dev/coze-loop/backend/modules/evaluation/infra/rpc/prompt" conf2 "github.com/coze-dev/coze-loop/backend/modules/evaluation/pkg/conf" "github.com/coze-dev/coze-loop/backend/pkg/conf" - "context" "github.com/google/wire" ) diff --git a/backend/modules/llm/application/runtime.go b/backend/modules/llm/application/runtime.go index 71ae76965..91d9d824e 100644 --- a/backend/modules/llm/application/runtime.go +++ b/backend/modules/llm/application/runtime.go @@ -10,10 +10,6 @@ import ( "strconv" "time" - "github.com/coze-dev/cozeloop-go" - "github.com/coze-dev/cozeloop-go/spec/tracespec" - "github.com/pkg/errors" - "github.com/coze-dev/coze-loop/backend/infra/limiter" "github.com/coze-dev/coze-loop/backend/infra/looptracer" "github.com/coze-dev/coze-loop/backend/infra/redis" @@ -31,6 +27,8 @@ import ( "github.com/coze-dev/coze-loop/backend/pkg/json" "github.com/coze-dev/coze-loop/backend/pkg/lang/ptr" "github.com/coze-dev/coze-loop/backend/pkg/logs" + "github.com/coze-dev/cozeloop-go" + "github.com/coze-dev/cozeloop-go/spec/tracespec" ) type runtimeApp struct { @@ -56,9 +54,10 @@ func NewRuntimeApplication( func (r *runtimeApp) Chat(ctx context.Context, req *runtime.ChatRequest) (resp *runtime.ChatResponse, err error) { resp = runtime.NewChatResponse() - if err = r.validateChatReq(ctx, req); err != nil { + if err := req.IsValid(); err != nil { return resp, errorx.NewByCode(llm_errorx.RequestNotValidCode, errorx.WithExtraMsg(err.Error())) } + // 1. 模型信息获取 model, err := r.manageSrv.GetModelByID(ctx, req.GetModelConfig().GetModelID()) if err != nil { @@ -116,9 +115,10 @@ func (r *runtimeApp) Chat(ctx context.Context, req *runtime.ChatRequest) (resp * func (r *runtimeApp) ChatStream(ctx context.Context, req *runtime.ChatRequest, stream runtime.LLMRuntimeService_ChatStreamServer) (err error) { // 参数校验 - if err = r.validateChatReq(ctx, req); err != nil { + if err := req.IsValid(); err != nil { return errorx.NewByCode(llm_errorx.RequestNotValidCode, errorx.WithExtraMsg(err.Error())) } + // 1. 模型信息获取 model, err := r.manageSrv.GetModelByID(ctx, req.GetModelConfig().GetModelID()) if err != nil { @@ -345,28 +345,3 @@ func (r *runtimeApp) setAndFinishSpan(ctx context.Context, span looptracer.Span, span.SetTags(ctx, tags) span.Finish(ctx) } - -func (r *runtimeApp) validateChatReq(ctx context.Context, req *runtime.ChatRequest) (err error) { - if req.GetModelConfig() == nil { - return errors.Errorf("model config is required") - } - if len(req.GetMessages()) == 0 { - return errors.Errorf("messages is required") - } - if req.GetBizParam() == nil { - return errors.Errorf("bizParam is required") - } - if !req.GetBizParam().IsSetScenario() { - return errors.Errorf("bizParam.scenario is required") - } - if !req.GetBizParam().IsSetScenarioEntityID() { - return errors.Errorf("bizParam.scenario_entity_id is required") - } - // if !req.GetBizParam().IsSetUserID() { - // return errors.Errorf("bizParam.user_id is required") - // } - if !req.GetBizParam().IsSetWorkspaceID() { - return errors.Errorf("bizParam.workspace_id is required") - } - return nil -} diff --git a/backend/modules/llm/application/wire_gen.go b/backend/modules/llm/application/wire_gen.go index d6cbf7839..4f50e1b18 100644 --- a/backend/modules/llm/application/wire_gen.go +++ b/backend/modules/llm/application/wire_gen.go @@ -7,6 +7,7 @@ package application import ( + "context" "github.com/coze-dev/coze-loop/backend/infra/db" "github.com/coze-dev/coze-loop/backend/infra/idgen" "github.com/coze-dev/coze-loop/backend/infra/limiter" @@ -21,7 +22,6 @@ import ( "github.com/coze-dev/coze-loop/backend/modules/llm/infra/repo/dao" "github.com/coze-dev/coze-loop/backend/modules/llm/infra/rpc" "github.com/coze-dev/coze-loop/backend/pkg/conf" - "context" "github.com/google/wire" ) diff --git a/backend/modules/llm/infra/repo/gorm_gen/model/model_request_record.gen.go b/backend/modules/llm/infra/repo/gorm_gen/model/model_request_record.gen.go index 1d8bd43da..c0efd12f1 100644 --- a/backend/modules/llm/infra/repo/gorm_gen/model/model_request_record.gen.go +++ b/backend/modules/llm/infra/repo/gorm_gen/model/model_request_record.gen.go @@ -14,7 +14,7 @@ const TableNameModelRequestRecord = "model_request_record" type ModelRequestRecord struct { ID int64 `gorm:"column:id;type:bigint unsigned;primaryKey;autoIncrement:true;comment:自增主键ID" json:"id"` // 自增主键ID SpaceID int64 `gorm:"column:space_id;type:bigint unsigned;not null;index:idx_space_id_create_time,priority:1;comment:空间id" json:"space_id"` // 空间id - UserID string `gorm:"column:user_id;type:varchar(256);not null;comment:user id" json:"user_id"` // user id + UserID string `gorm:"column:user_id;type:varchar(256);not null;comment:user id" json:"user_id"` // user id UsageScene string `gorm:"column:usage_scene;type:varchar(128);not null;comment:场景" json:"usage_scene"` // 场景 UsageSceneEntityID string `gorm:"column:usage_scene_entity_id;type:varchar(256);not null;comment:场景实体id" json:"usage_scene_entity_id"` // 场景实体id Frame string `gorm:"column:frame;type:varchar(128);not null;comment:使用的框架,如eino" json:"frame"` // 使用的框架,如eino @@ -35,4 +35,4 @@ type ModelRequestRecord struct { // TableName ModelRequestRecord's table name func (*ModelRequestRecord) TableName() string { return TableNameModelRequestRecord -} \ No newline at end of file +} diff --git a/backend/modules/llm/infra/repo/gorm_gen/query/model_request_record.gen.go b/backend/modules/llm/infra/repo/gorm_gen/query/model_request_record.gen.go index 122b66c39..cb3d11712 100644 --- a/backend/modules/llm/infra/repo/gorm_gen/query/model_request_record.gen.go +++ b/backend/modules/llm/infra/repo/gorm_gen/query/model_request_record.gen.go @@ -55,7 +55,7 @@ type modelRequestRecord struct { ALL field.Asterisk ID field.Int64 // 自增主键ID SpaceID field.Int64 // 空间id - UserID field.String // user id + UserID field.String // user id UsageScene field.String // 场景 UsageSceneEntityID field.String // 场景实体id Frame field.String // 使用的框架,如eino diff --git a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.eval_set.thrift b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.eval_set.thrift index 47c9ba495..09cd5dd3f 100644 --- a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.eval_set.thrift +++ b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.eval_set.thrift @@ -8,9 +8,9 @@ include "../data/domain/dataset.thrift" struct CreateEvaluationSetRequest { 1: required i64 workspace_id (api.js_conv="true", go.tag='json:"workspace_id"'), - 2: optional string name (vt.min_size = "1", vt.max_size = "255"), - 3: optional string description (vt.max_size = "2048"), - 4: optional eval_set.EvaluationSetSchema evaluation_set_schema, + 2: optional string name (vt.not_nil="true",vt.min_size = "1", vt.max_size = "255"), + 3: optional string description (vt.max_size = "2048",vt.not_nil="true"), + 4: optional eval_set.EvaluationSetSchema evaluation_set_schema (vt.not_nil="true"), 5: optional eval_set.BizCategory biz_category (vt.max_size = "128") // 业务分类 200: optional common.Session session diff --git a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift index de2c61407..6c376b107 100644 --- a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift +++ b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift @@ -53,7 +53,7 @@ struct GetEvaluatorResponse { } struct CreateEvaluatorRequest { - 1: required evaluator.Evaluator evaluator (api.body='evaluator') + 1: required evaluator.Evaluator evaluator (api.body='evaluator' vt.not_nil="true") 100: optional string cid (api.body='cid') 255: optional base.Base Base @@ -81,11 +81,11 @@ struct UpdateEvaluatorDraftResponse { } struct UpdateEvaluatorRequest { - 1: required i64 evaluator_id (api.path='evaluator_id', api.js_conv='true', go.tag='json:"evaluator_id"') // 评估器 id - 2: required i64 workspace_id (api.body='workspace_id', api.js_conv='true', go.tag='json:"workspace_id"') // 空间 id + 1: required i64 evaluator_id (api.path='evaluator_id', api.js_conv='true', go.tag='json:"evaluator_id"' ,vt.not_in="0") // 评估器 id + 2: required i64 workspace_id (api.body='workspace_id', api.js_conv='true', go.tag='json:"workspace_id"',vt.not_in="0") // 空间 id 3: required evaluator.EvaluatorType evaluator_type (api.body='evaluator_type', go.tag='json:"evaluator_type"') - 4: optional string name (api.body='name', go.tag='json:"name"') // 展示用名称 - 5: optional string description (api.body='description', go.tag='json:"description"') // 描述 + 4: optional string name (api.body='name', go.tag='json:"name"',vt.not_nil="true") // 展示用名称 + 5: optional string description (api.body='description', go.tag='json:"description"',vt.not_nil="true") // 描述 255: optional base.Base Base } @@ -154,10 +154,10 @@ struct BatchGetEvaluatorVersionsResponse { } struct SubmitEvaluatorVersionRequest { - 1: required i64 workspace_id (api.body='workspace_id', api.js_conv='true', go.tag='json:"workspace_id"') - 2: required i64 evaluator_id (api.path='evaluator_id', api.js_conv='true', go.tag='json:"evaluator_id"') - 3: required string version (api.body='version') - 4: optional string description (api.body='description') + 1: required i64 workspace_id (api.body='workspace_id', api.js_conv='true', go.tag='json:"workspace_id"',vt.not_in="0") + 2: required i64 evaluator_id (api.path='evaluator_id', api.js_conv='true', go.tag='json:"evaluator_id"',vt.not_in="0") + 3: required string version (api.body='version',vt.not_nil="true") + 4: optional string description (api.body='description',vt.not_nil="true") 100: optional string cid (api.body='cid') 255: optional base.Base Base diff --git a/idl/thrift/coze/loop/evaluation/domain/evaluator.thrift b/idl/thrift/coze/loop/evaluation/domain/evaluator.thrift index a2ceb6da7..3f988231a 100644 --- a/idl/thrift/coze/loop/evaluation/domain/evaluator.thrift +++ b/idl/thrift/coze/loop/evaluation/domain/evaluator.thrift @@ -78,14 +78,14 @@ struct EvaluatorContent { } struct Evaluator { - 1: optional i64 evaluator_id (api.js_conv = 'true', go.tag = 'json:"evaluator_id"') - 2: optional i64 workspace_id (api.js_conv = 'true', go.tag = 'json:"workspace_id"') - 3: optional EvaluatorType evaluator_type - 4: optional string name - 5: optional string description + 1: optional i64 evaluator_id (api.js_conv = 'true', go.tag = 'json:"evaluator_id"',vt.not_nil="true") + 2: optional i64 workspace_id (api.js_conv = 'true', go.tag = 'json:"workspace_id"',vt.not_nil="true") + 3: optional EvaluatorType evaluator_type (vt.not_nil="true") + 4: optional string name (vt.not_nil="true") + 5: optional string description (vt.not_nil="true") 6: optional bool draft_submitted - 7: optional common.BaseInfo base_info - 11: optional EvaluatorVersion current_version + 7: optional common.BaseInfo base_info (vt.not_nil="true") + 11: optional EvaluatorVersion current_version (vt.not_nil="true") 12: optional string latest_version } diff --git a/idl/thrift/coze/loop/llm/coze.loop.llm.runtime.thrift b/idl/thrift/coze/loop/llm/coze.loop.llm.runtime.thrift index daad42f35..f71883cba 100644 --- a/idl/thrift/coze/loop/llm/coze.loop.llm.runtime.thrift +++ b/idl/thrift/coze/loop/llm/coze.loop.llm.runtime.thrift @@ -5,13 +5,13 @@ include "./domain/runtime.thrift" struct ChatRequest { // 模型配置 - 1: optional runtime.ModelConfig model_config + 1: optional runtime.ModelConfig model_config (vt.not_nil="true") // 消息 - 2: optional list messages + 2: optional list messages (vt.min_size="1") // 工具 - 3: optional list tools + 3: optional list tools (vt.min_size="1") // 业务参数 - 4: optional runtime.BizParam biz_param + 4: optional runtime.BizParam biz_param (vt.not_nil="true") 255: optional base.Base Base } diff --git a/idl/thrift/coze/loop/llm/domain/runtime.thrift b/idl/thrift/coze/loop/llm/domain/runtime.thrift index f75e374f5..460f8f1af 100644 --- a/idl/thrift/coze/loop/llm/domain/runtime.thrift +++ b/idl/thrift/coze/loop/llm/domain/runtime.thrift @@ -70,10 +70,10 @@ struct Tool { struct BizParam { - 1: optional i64 workspace_id (api.js_conv='true', go.tag='json:"workspace_id"') + 1: optional i64 workspace_id (api.js_conv='true', go.tag='json:"workspace_id"', vt.not_nil="true") 2: optional string user_id - 3: optional common.Scenario scenario // 使用场景 - 4: optional string scenario_entity_id // 场景实体id, prompt场景需要传prompt key + 3: optional common.Scenario scenario (vt.not_nil="true") // 使用场景 + 4: optional string scenario_entity_id (vt.not_nil="true") // 场景实体id, prompt场景需要传prompt key 5: optional string scenario_entity_version // 场景实体version(非必填) } From 6d34e2f6d1a2706c87fd0d9e4196b6700567614e Mon Sep 17 00:00:00 2001 From: mixinju <151109044+mixinju@users.noreply.github.com> Date: Tue, 19 Aug 2025 13:28:47 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=AE=8C=E5=96=84required=20string?= =?UTF-8?q?=E7=9A=84thrift=20validator=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../evaluator/coze.loop.evaluation.evaluator_validator.go | 4 ++-- .../loop/evaluation/coze.loop.evaluation.evaluator.thrift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go b/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go index 7f7e49855..d921ee69b 100644 --- a/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go +++ b/backend/kitex_gen/coze/loop/evaluation/evaluator/coze.loop.evaluation.evaluator_validator.go @@ -258,8 +258,8 @@ func (p *SubmitEvaluatorVersionRequest) IsValid() error { return fmt.Errorf("field EvaluatorID not_in rule failed, current value: %v", p.EvaluatorID) } } - if p.Version == nil { - return fmt.Errorf("field Version not_nil rule failed") + if len(p.Version) < int(1) { + return fmt.Errorf("field Version min_len rule failed, current value: %d", len(p.Version)) } if p.Description == nil { return fmt.Errorf("field Description not_nil rule failed") diff --git a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift index 6c376b107..4bd9e2e13 100644 --- a/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift +++ b/idl/thrift/coze/loop/evaluation/coze.loop.evaluation.evaluator.thrift @@ -156,7 +156,7 @@ struct BatchGetEvaluatorVersionsResponse { struct SubmitEvaluatorVersionRequest { 1: required i64 workspace_id (api.body='workspace_id', api.js_conv='true', go.tag='json:"workspace_id"',vt.not_in="0") 2: required i64 evaluator_id (api.path='evaluator_id', api.js_conv='true', go.tag='json:"evaluator_id"',vt.not_in="0") - 3: required string version (api.body='version',vt.not_nil="true") + 3: required string version (api.body='version',vt.min_size="1") 4: optional string description (api.body='description',vt.not_nil="true") 100: optional string cid (api.body='cid')