Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions backend/modules/observability/application/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ func (t *TaskApplication) validateCreateTaskReq(ctx context.Context, req *task.C
return errorx.NewByCode(obErrorx.CommercialCommonInvalidParamCodeCode, errorx.WithExtraMsg("The start time must be earlier than the end time."))
}
}
if req.GetTask().GetRule().GetSampler().GetIsCycle() && req.GetTask().GetRule().GetSampler().GetCycleInterval() == 0 {
return errorx.NewByCode(obErrorx.CommercialCommonInvalidParamCodeCode, errorx.WithExtraMsg("invalid cycle_interval"))
}

return nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import (

"github.com/coze-dev/coze-loop/backend/infra/middleware/session"
"github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/evaluation/domain/common"
"github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/evaluation/domain/eval_set"
"github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/observability/domain/dataset"
"github.com/coze-dev/coze-loop/backend/kitex_gen/coze/loop/observability/domain/task"
"github.com/coze-dev/coze-loop/backend/modules/observability/domain/component/rpc"
Expand Down Expand Up @@ -192,11 +191,12 @@ func buildSpan(input string) *loop_span.Span {

func makeSchemaJSON(t *testing.T, fieldName string, contentType common.ContentType) string {
t.Helper()
fieldSchemas := []*eval_set.FieldSchema{
fieldSchemas := []traceentity.FieldSchema{
{
Key: gptr.Of(fieldName),
Name: gptr.Of(fieldName),
ContentType: gptr.Of(contentType),
Name: fieldName,
ContentType: traceentity.ContentType(contentType),
TextSchema: "{}",
},
}
bytes, err := json.Marshal(fieldSchemas)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_
logs.CtxInfo(ctx, "Evaluator field name is nil")
continue
}
var evaluationSetSchemas []*eval_set.FieldSchema
var evaluationSetSchemas []*entity.FieldSchema
if evaluationSetSchema == "" {
logs.CtxInfo(ctx, "Evaluation set schema is nil")
continue
Expand All @@ -213,25 +213,25 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_
continue
}
for _, fieldSchema := range evaluationSetSchemas {
if fieldSchema.GetKey() == *mapping.EvalSetName {
key := fieldSchema.GetKey()
if key == "" {
logs.CtxInfo(ctx, "Evaluator field key is empty, name:%v", *mapping.FieldSchema.Name)
if *fieldSchema.Key == *mapping.EvalSetName {
key := fieldSchema.Key
if key == nil {
logs.CtxInfo(ctx, "Evaluator field key is empty, name:%v", fieldSchema.Name)
continue
}
value, err := span.ExtractByJsonpath(ctx, mapping.TraceFieldKey, mapping.TraceFieldJsonpath)
if err != nil {
logs.CtxInfo(ctx, "Extract field failed, err:%v", err)
continue
}
content, err := GetContentInfo(ctx, fieldSchema.GetContentType(), value)
content, err := GetContentInfo(ctx, fieldSchema.ContentType, value)
if err != nil {
logs.CtxInfo(ctx, "GetContentInfo failed, err:%v", err)
return nil
}
fieldDatas = append(fieldDatas, &eval_set.FieldData{
Key: gptr.Of(key),
Name: gptr.Of(fieldSchema.GetName()),
Key: key,
Name: gptr.Of(fieldSchema.Name),
Content: content,
})
}
Expand All @@ -241,10 +241,10 @@ func buildItem(ctx context.Context, span *loop_span.Span, fieldMappings []*task_
}

// todo:[xun]和手动回流的代码逻辑一样,需要抽取公共代码
func GetContentInfo(ctx context.Context, contentType common.ContentType, value string) (*common.Content, error) {
func GetContentInfo(ctx context.Context, contentType entity.ContentType, value string) (*common.Content, error) {
var content *common.Content
switch contentType {
case common.ContentTypeMultiPart:
case entity.ContentType_MultiPart:
var parts []tracespec.ModelMessagePart
err := json.Unmarshal([]byte(value), &parts)
if err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ func TestBuildItem(t *testing.T) {
TraceFieldJsonpath: "",
EvalSetName: gptr.Of("field_1"),
}
evalSchema := []*eval_set.FieldSchema{
evalSchema := []*entity.FieldSchema{
{
Key: gptr.Of("field_1"),
Name: gptr.Of("field_1"),
ContentType: gptr.Of(common.ContentTypeText),
Name: "field_1",
ContentType: common.ContentTypeText,
},
}
evalSchemaBytes, err := json.Marshal(evalSchema)
Expand All @@ -235,11 +235,11 @@ func TestBuildItem(t *testing.T) {
// content error path should return nil
mapping.FieldSchema.ContentType = gptr.Of(common.ContentTypeMultiPart)
badSpan := &loop_span.Span{TraceID: span.TraceID, SpanID: span.SpanID, Input: "invalid json"}
badSchema := []*eval_set.FieldSchema{
badSchema := []*entity.FieldSchema{
{
Key: gptr.Of("field_1"),
Name: gptr.Of("field_1"),
ContentType: gptr.Of(common.ContentTypeMultiPart),
Name: "field_1",
ContentType: common.ContentTypeMultiPart,
},
}
badBytes, err := json.Marshal(badSchema)
Expand Down Expand Up @@ -279,11 +279,11 @@ func TestBuildItems(t *testing.T) {
goodSpan := &loop_span.Span{TraceID: "1234567890abcdef1234567890abcdef", SpanID: "deadc0debeefcafe", Input: "hello"}
badSpan := &loop_span.Span{TraceID: goodSpan.TraceID, SpanID: "badbadbadbadbad", Input: "invalid"}
mapping.FieldSchema.ContentType = gptr.Of(common.ContentTypeMultiPart)
multipartSchema := []*eval_set.FieldSchema{
multipartSchema := []*entity.FieldSchema{
{
Key: gptr.Of("field_1"),
Name: gptr.Of("field_1"),
ContentType: gptr.Of(common.ContentTypeMultiPart),
Name: "field_1",
ContentType: common.ContentTypeMultiPart,
},
}
multipartBytes, err := json.Marshal(multipartSchema)
Expand Down
Loading