diff --git a/backend/api/handler/coze/workflow_service_test.go b/backend/api/handler/coze/workflow_service_test.go index c22b7530..82de5fbc 100644 --- a/backend/api/handler/coze/workflow_service_test.go +++ b/backend/api/handler/coze/workflow_service_test.go @@ -43,13 +43,14 @@ import ( "github.com/cloudwego/hertz/pkg/common/ut" "github.com/cloudwego/hertz/pkg/protocol" "github.com/cloudwego/hertz/pkg/protocol/sse" - "github.com/coze-dev/coze-studio/backend/domain/workflow/config" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/mock/gomock" "gorm.io/driver/mysql" "gorm.io/gorm" + "github.com/coze-dev/coze-studio/backend/domain/workflow/config" + "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge" modelknowledge "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge" model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr" diff --git a/backend/application/workflow/init.go b/backend/application/workflow/init.go index e7fc0487..52a9f846 100644 --- a/backend/application/workflow/init.go +++ b/backend/application/workflow/init.go @@ -20,9 +20,10 @@ import ( "context" "path/filepath" - "gopkg.in/yaml.v3" "os" + "gopkg.in/yaml.v3" + "github.com/cloudwego/eino/callbacks" "github.com/cloudwego/eino/compose" "gorm.io/gorm" @@ -92,7 +93,7 @@ func InitService(_ context.Context, components *ServiceComponents) (*Application if err != nil { return nil, err } - + workflow.SetRepository(workflowRepo) workflowDomainSVC := service.NewWorkflowService(workflowRepo) diff --git a/backend/crossdomain/contract/message/message.go b/backend/crossdomain/contract/message/message.go index bb317af4..0a3d564e 100644 --- a/backend/crossdomain/contract/message/message.go +++ b/backend/crossdomain/contract/message/message.go @@ -20,6 +20,7 @@ import ( "context" "github.com/cloudwego/eino/schema" + "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity" ) diff --git a/backend/crossdomain/impl/message/message.go b/backend/crossdomain/impl/message/message.go index 843857d7..9fd7fdf9 100644 --- a/backend/crossdomain/impl/message/message.go +++ b/backend/crossdomain/impl/message/message.go @@ -22,6 +22,7 @@ import ( "strconv" "github.com/cloudwego/eino/schema" + model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" crossagentrun "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agentrun" crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message" diff --git a/backend/crossdomain/impl/message/message_test.go b/backend/crossdomain/impl/message/message_test.go index f68a547e..01e9310c 100644 --- a/backend/crossdomain/impl/message/message_test.go +++ b/backend/crossdomain/impl/message/message_test.go @@ -21,6 +21,9 @@ import ( "testing" "github.com/cloudwego/eino/schema" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message" "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity" @@ -28,8 +31,6 @@ import ( "github.com/coze-dev/coze-studio/backend/infra/contract/storage" "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/sonic" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) type mockWorkflowRepo struct { diff --git a/backend/crossdomain/impl/workflow/workflow.go b/backend/crossdomain/impl/workflow/workflow.go index 2f0f93f1..daaa826c 100644 --- a/backend/crossdomain/impl/workflow/workflow.go +++ b/backend/crossdomain/impl/workflow/workflow.go @@ -18,6 +18,7 @@ package workflow import ( "context" + "github.com/cloudwego/eino/compose" einoCompose "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/schema" diff --git a/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go b/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go index 36b273f0..e114d892 100644 --- a/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go +++ b/backend/domain/workflow/internal/canvas/adaptor/canvas_test.go @@ -18,7 +18,6 @@ package adaptor import ( "context" - "github.com/coze-dev/coze-studio/backend/domain/workflow/config" "io" "net" "net/http" @@ -28,6 +27,8 @@ import ( "testing" "time" + "github.com/coze-dev/coze-studio/backend/domain/workflow/config" + "github.com/bytedance/mockey" "github.com/cloudwego/eino/schema" "github.com/stretchr/testify/assert" diff --git a/backend/domain/workflow/internal/compose/test/llm_test.go b/backend/domain/workflow/internal/compose/test/llm_test.go index 1ced79da..27acd4bf 100644 --- a/backend/domain/workflow/internal/compose/test/llm_test.go +++ b/backend/domain/workflow/internal/compose/test/llm_test.go @@ -31,11 +31,12 @@ import ( model2 "github.com/cloudwego/eino/components/model" "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/schema" - workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" - "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute" "github.com/stretchr/testify/assert" "go.uber.org/mock/gomock" + workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" + "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute" + model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr" crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr" mockmodel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr/modelmock" diff --git a/backend/domain/workflow/internal/nodes/conversation/createconversation.go b/backend/domain/workflow/internal/nodes/conversation/createconversation.go index 688d5b1c..671dcb49 100644 --- a/backend/domain/workflow/internal/nodes/conversation/createconversation.go +++ b/backend/domain/workflow/internal/nodes/conversation/createconversation.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" diff --git a/backend/domain/workflow/internal/nodes/conversation/createmessage.go b/backend/domain/workflow/internal/nodes/conversation/createmessage.go index baded0c9..16b038e4 100644 --- a/backend/domain/workflow/internal/nodes/conversation/createmessage.go +++ b/backend/domain/workflow/internal/nodes/conversation/createmessage.go @@ -20,6 +20,7 @@ import ( "context" "errors" "fmt" + "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" conventity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity" @@ -27,6 +28,7 @@ import ( "sync/atomic" einoSchema "github.com/cloudwego/eino/schema" + model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" crossagentrun "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agentrun" diff --git a/backend/domain/workflow/internal/nodes/conversation/editmessage.go b/backend/domain/workflow/internal/nodes/conversation/editmessage.go index 84b7102d..f4c38a58 100644 --- a/backend/domain/workflow/internal/nodes/conversation/editmessage.go +++ b/backend/domain/workflow/internal/nodes/conversation/editmessage.go @@ -20,9 +20,10 @@ import ( "context" "errors" "fmt" - model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" "strconv" + model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message" + workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message" crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message" diff --git a/backend/domain/workflow/internal/nodes/intentdetector/prompt.go b/backend/domain/workflow/internal/nodes/intentdetector/prompt.go index 4b08686d..ab42d05c 100644 --- a/backend/domain/workflow/internal/nodes/intentdetector/prompt.go +++ b/backend/domain/workflow/internal/nodes/intentdetector/prompt.go @@ -19,6 +19,7 @@ package intentdetector import ( "context" "fmt" + "github.com/cloudwego/eino/components/prompt" "github.com/cloudwego/eino/schema" diff --git a/backend/domain/workflow/internal/nodes/utils.go b/backend/domain/workflow/internal/nodes/utils.go index 32b3dab8..9f22a1f2 100644 --- a/backend/domain/workflow/internal/nodes/utils.go +++ b/backend/domain/workflow/internal/nodes/utils.go @@ -25,6 +25,7 @@ import ( "strings" "github.com/cloudwego/eino/compose" + crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" diff --git a/backend/domain/workflow/internal/repo/suggest.go b/backend/domain/workflow/internal/repo/suggest.go index e0420bb0..7f8b99ea 100644 --- a/backend/domain/workflow/internal/repo/suggest.go +++ b/backend/domain/workflow/internal/repo/suggest.go @@ -25,6 +25,7 @@ import ( "github.com/cloudwego/eino/compose" einoCompose "github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/schema" + "github.com/coze-dev/coze-studio/backend/domain/workflow" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/pkg/logs" diff --git a/backend/domain/workflow/service/conversation_impl.go b/backend/domain/workflow/service/conversation_impl.go index 5a17f8e0..ccec12ea 100644 --- a/backend/domain/workflow/service/conversation_impl.go +++ b/backend/domain/workflow/service/conversation_impl.go @@ -19,6 +19,7 @@ package service import ( "context" "fmt" + "github.com/coze-dev/coze-studio/backend/api/model/conversation/common" conventity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity" diff --git a/backend/domain/workflow/service/service_impl.go b/backend/domain/workflow/service/service_impl.go index c8adf50d..27e6bd10 100644 --- a/backend/domain/workflow/service/service_impl.go +++ b/backend/domain/workflow/service/service_impl.go @@ -29,6 +29,7 @@ import ( "strconv" einoCompose "github.com/cloudwego/eino/compose" + "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/plugin" workflowModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/workflow" cloudworkflow "github.com/coze-dev/coze-studio/backend/api/model/workflow" diff --git a/backend/infra/impl/storage/s3/s3.go b/backend/infra/impl/storage/s3/s3.go index 3b75aa2e..4f62659b 100644 --- a/backend/infra/impl/storage/s3/s3.go +++ b/backend/infra/impl/storage/s3/s3.go @@ -21,7 +21,6 @@ import ( "context" "fmt" "io" - "net/url" "time" "github.com/aws/aws-sdk-go-v2/aws" @@ -32,6 +31,7 @@ import ( "github.com/coze-dev/coze-studio/backend/infra/contract/storage" "github.com/coze-dev/coze-studio/backend/infra/impl/storage/proxy" + "github.com/coze-dev/coze-studio/backend/pkg/goutil" "github.com/coze-dev/coze-studio/backend/pkg/logs" "github.com/coze-dev/coze-studio/backend/pkg/taskgroup" ) @@ -182,8 +182,7 @@ func (t *s3Client) PutObjectWithReader(ctx context.Context, objectKey string, co } if option.Tagging != nil { - tagging := mapToQueryParams(option.Tagging) - input.Tagging = aws.String(tagging) + input.Tagging = aws.String(goutil.MapToQuery(option.Tagging)) } // upload object @@ -361,17 +360,6 @@ func (t *s3Client) ListObjectsPaginated(ctx context.Context, input *storage.List return output, nil } -func mapToQueryParams(tagging map[string]string) string { - if len(tagging) == 0 { - return "" - } - params := url.Values{} - for k, v := range tagging { - params.Set(k, v) - } - return params.Encode() -} - func tagsToMap(tags []types.Tag) map[string]string { if len(tags) == 0 { return nil diff --git a/backend/infra/impl/storage/tos/tos.go b/backend/infra/impl/storage/tos/tos.go index 051902eb..fa5c7241 100644 --- a/backend/infra/impl/storage/tos/tos.go +++ b/backend/infra/impl/storage/tos/tos.go @@ -30,8 +30,10 @@ import ( "github.com/coze-dev/coze-studio/backend/infra/contract/storage" "github.com/coze-dev/coze-studio/backend/infra/impl/storage/proxy" + "github.com/coze-dev/coze-studio/backend/pkg/goutil" "github.com/coze-dev/coze-studio/backend/pkg/lang/conv" "github.com/coze-dev/coze-studio/backend/pkg/logs" + "github.com/coze-dev/coze-studio/backend/pkg/taskgroup" ) type tosClient struct { @@ -181,7 +183,7 @@ func (t *tosClient) PutObjectWithReader(ctx context.Context, objectKey string, c } if len(option.Tagging) > 0 { - input.Meta = option.Tagging + input.Tagging = goutil.MapToQuery(option.Tagging) } _, err := client.PutObjectV2(ctx, input) @@ -277,26 +279,38 @@ func (t *tosClient) ListObjectsPaginated(ctx context.Context, input *storage.Lis continue } - var tagging map[string]string - if obj.Meta != nil { - obj.Meta.Range(func(key, value string) bool { - if tagging == nil { - tagging = make(map[string]string) - } - tagging[key] = value - return true - }) - } - files = append(files, &storage.FileInfo{ Key: obj.Key, LastModified: obj.LastModified, ETag: obj.ETag, Size: obj.Size, - Tagging: tagging, }) } + if input.WithTagging { + client := t.client + taskGroup := taskgroup.NewTaskGroup(ctx, 5) + for idx := range files { + f := files[idx] + taskGroup.Go(func() error { + tagging, err := client.GetObjectTagging(ctx, &tos.GetObjectTaggingInput{ + Bucket: t.bucketName, + Key: f.Key, + }) + if err != nil { + return err + } + + f.Tagging = tagsToMap(tagging.TagSet.Tags) + return nil + }) + } + + if err := taskGroup.Wait(); err != nil { + return nil, err + } + } + return &storage.ListObjectsPaginatedOutput{ Files: files, Cursor: output.NextMarker, @@ -345,3 +359,16 @@ func (t *tosClient) ListAllObjects(ctx context.Context, prefix string, withTaggi return files, nil } + +func tagsToMap(tags []tos.Tag) map[string]string { + if len(tags) == 0 { + return nil + } + + m := make(map[string]string, len(tags)) + for _, tag := range tags { + m[tag.Key] = tag.Value + } + + return m +} diff --git a/backend/pkg/goutil/url.go b/backend/pkg/goutil/url.go new file mode 100644 index 00000000..fab21f89 --- /dev/null +++ b/backend/pkg/goutil/url.go @@ -0,0 +1,31 @@ +/* + * Copyright 2025 coze-dev Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package goutil + +import "net/url" + +// MapToQuery converts a map[string]string to a URL-encoded query string. +func MapToQuery(data map[string]string) string { + if len(data) == 0 { + return "" + } + params := url.Values{} + for k, v := range data { + params.Set(k, v) + } + return params.Encode() +}