feat: py sandbox for workflow

* chore: update Dockerfile and sandbox.py
* feat: py sandbox for workflow
* feat: py sandbox for workflow

See merge request: !885
This commit is contained in:
徐兆楠
2025-07-25 07:17:25 +00:00
parent e8686379b2
commit 3749abdea0
20 changed files with 521 additions and 79 deletions

View File

@@ -29,6 +29,7 @@ import (
"github.com/bytedance/mockey"
"github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
@@ -746,7 +747,7 @@ func TestCodeAndPluginNodes(t *testing.T) {
defer ctrl.Finish()
mockCodeRunner := mockcode.NewMockRunner(ctrl)
mockey.Mock(code.GetCodeRunner).Return(mockCodeRunner).Build()
mockCodeRunner.EXPECT().Run(gomock.Any(), gomock.Any()).Return(&code.RunResponse{
mockCodeRunner.EXPECT().Run(gomock.Any(), gomock.Any()).Return(&coderunner.RunResponse{
Result: map[string]any{
"key0": "value0",
"key1": []string{"value1", "value2"},

View File

@@ -23,8 +23,6 @@ import (
"strings"
einoCompose "github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/code"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/database"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/knowledge"
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/model"
@@ -34,6 +32,7 @@ import (
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/loop"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/qa"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/selector"
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
"github.com/coze-dev/coze-studio/backend/pkg/lang/crypto"
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
"github.com/coze-dev/coze-studio/backend/types/errno"
@@ -1075,12 +1074,12 @@ func ConvertRetrievalSearchType(s int64) (knowledge.SearchType, error) {
}
}
func ConvertCodeLanguage(l int64) (code.Language, error) {
func ConvertCodeLanguage(l int64) (coderunner.Language, error) {
switch l {
case 5:
return code.JavaScript, nil
return coderunner.JavaScript, nil
case 3:
return code.Python, nil
return coderunner.Python, nil
default:
return "", fmt.Errorf("invalid language: %d", l)