chore(shell): auto cp .env form .env.example when debug

* chore(shell): auto cp .env form .env.example when debug
* chore(docker): using default env example if env not exit when debug app

See merge request: !910
This commit is contained in:
樊侣 2025-07-25 03:50:24 +00:00
parent 5343a7718d
commit f3934ccf62
8 changed files with 25 additions and 19 deletions

View File

@ -14,13 +14,19 @@ MYSQL_INIT_SQL := ./docker/volumes/mysql/sql_init.sql
ENV_FILE := ./docker/.env ENV_FILE := ./docker/.env
STATIC_DIR := ./bin/resources/static STATIC_DIR := ./bin/resources/static
debug: middleware python server debug: env middleware python server
env:
@if [ ! -f "$(ENV_FILE)" ]; then \
echo "Env file '$(ENV_FILE)' not found, using example env..."; \
cp ./docker/.env.example $(ENV_FILE); \
fi
fe: fe:
@echo "Building frontend..." @echo "Building frontend..."
@bash $(BUILD_FE_SCRIPT) @bash $(BUILD_FE_SCRIPT)
server: server: env
@if [ ! -d "$(STATIC_DIR)" ]; then \ @if [ ! -d "$(STATIC_DIR)" ]; then \
echo "Static directory '$(STATIC_DIR)' not found, building frontend..."; \ echo "Static directory '$(STATIC_DIR)' not found, building frontend..."; \
$(MAKE) fe; \ $(MAKE) fe; \
@ -83,6 +89,7 @@ help:
@echo "" @echo ""
@echo "Targets:" @echo "Targets:"
@echo " debug - Start the debug environment." @echo " debug - Start the debug environment."
@echo " env - Setup env file."
@echo " fe - Build the frontend." @echo " fe - Build the frontend."
@echo " server - Build and run the server binary." @echo " server - Build and run the server binary."
@echo " build_server - Build the server binary." @echo " build_server - Build the server binary."

View File

@ -26,11 +26,11 @@ import (
"github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/flow/agent/react" "github.com/cloudwego/eino/flow/agent/react"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
"github.com/coze-dev/coze-studio/backend/domain/workflow" "github.com/coze-dev/coze-studio/backend/domain/workflow"
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel" "github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices" "github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
) )
@ -97,7 +97,6 @@ func BuildAgent(ctx context.Context, conf *Config) (r *AgentRunner, err error) {
modelFactory: conf.ModelFactory, modelFactory: conf.ModelFactory,
modelInfo: modelInfo, modelInfo: modelInfo,
}) })
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -22,22 +22,20 @@ import (
"math/rand" "math/rand"
"github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/compose"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/jinzhu/copier"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/bot_common" "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/bot_common"
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossplugin" "github.com/coze-dev/coze-studio/backend/crossdomain/contract/crossplugin"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/agentflow" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/agentflow"
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/repository" "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/repository"
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel" "github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/pkg/errorx" "github.com/coze-dev/coze-studio/backend/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/jsoncache" "github.com/coze-dev/coze-studio/backend/pkg/jsoncache"
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices" "github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
"github.com/coze-dev/coze-studio/backend/pkg/logs" "github.com/coze-dev/coze-studio/backend/pkg/logs"
"github.com/coze-dev/coze-studio/backend/types/errno" "github.com/coze-dev/coze-studio/backend/types/errno"
"github.com/jinzhu/copier"
) )
type singleAgentImpl struct { type singleAgentImpl struct {

View File

@ -20,6 +20,7 @@ import (
"context" "context"
"github.com/cloudwego/eino/components/model" "github.com/cloudwego/eino/components/model"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr" "github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
) )

View File

@ -31,7 +31,6 @@ import (
model2 "github.com/cloudwego/eino/components/model" model2 "github.com/cloudwego/eino/components/model"
"github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock" "go.uber.org/mock/gomock"
@ -42,6 +41,7 @@ import (
compose2 "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/compose" compose2 "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/compose"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/llm" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/llm"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/internal/testutil" "github.com/coze-dev/coze-studio/backend/internal/testutil"
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache" "github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
) )

View File

@ -28,7 +28,6 @@ import (
"github.com/cloudwego/eino/components/tool" "github.com/cloudwego/eino/components/tool"
"github.com/cloudwego/eino/compose" "github.com/cloudwego/eino/compose"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
workflow3 "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow" workflow3 "github.com/coze-dev/coze-studio/backend/api/model/ocean/cloud/workflow"
workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow" workflow2 "github.com/coze-dev/coze-studio/backend/domain/workflow"
@ -62,6 +61,7 @@ import (
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/textprocessor" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/textprocessor"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/variableaggregator" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/variableaggregator"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/variableassigner" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes/variableassigner"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr" "github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
"github.com/coze-dev/coze-studio/backend/pkg/safego" "github.com/coze-dev/coze-studio/backend/pkg/safego"
) )
@ -501,7 +501,6 @@ func (s *NodeSchema) ToDatabaseCustomSQLConfig() (*database.CustomSQLConfig, err
OutputConfig: s.OutputTypes, OutputConfig: s.OutputTypes,
CustomSQLExecutor: crossdatabase.GetDatabaseOperator(), CustomSQLExecutor: crossdatabase.GetDatabaseOperator(),
}, nil }, nil
} }
func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) { func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) {
@ -517,7 +516,6 @@ func (s *NodeSchema) ToDatabaseQueryConfig() (*database.QueryConfig, error) {
} }
func (s *NodeSchema) ToDatabaseInsertConfig() (*database.InsertConfig, error) { func (s *NodeSchema) ToDatabaseInsertConfig() (*database.InsertConfig, error) {
return &database.InsertConfig{ return &database.InsertConfig{
DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs), DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs),
OutputConfig: s.OutputTypes, OutputConfig: s.OutputTypes,
@ -535,7 +533,6 @@ func (s *NodeSchema) ToDatabaseDeleteConfig() (*database.DeleteConfig, error) {
} }
func (s *NodeSchema) ToDatabaseUpdateConfig() (*database.UpdateConfig, error) { func (s *NodeSchema) ToDatabaseUpdateConfig() (*database.UpdateConfig, error) {
return &database.UpdateConfig{ return &database.UpdateConfig{
DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs), DatabaseInfoID: mustGetKey[int64]("DatabaseInfoID", s.Configs),
ClauseGroup: mustGetKey[*crossdatabase.ClauseGroup]("ClauseGroup", s.Configs), ClauseGroup: mustGetKey[*crossdatabase.ClauseGroup]("ClauseGroup", s.Configs),
@ -575,7 +572,6 @@ func (s *NodeSchema) ToPluginConfig() (*plugin.Config, error) {
PluginVersion: mustGetKey[string]("PluginVersion", s.Configs), PluginVersion: mustGetKey[string]("PluginVersion", s.Configs),
PluginService: crossplugin.GetPluginService(), PluginService: crossplugin.GetPluginService(),
}, nil }, nil
} }
func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) { func (s *NodeSchema) ToCodeRunnerConfig() (*code.Config, error) {

View File

@ -24,6 +24,7 @@ import (
"github.com/cloudwego/eino/components" "github.com/cloudwego/eino/components"
"github.com/cloudwego/eino/components/model" "github.com/cloudwego/eino/components/model"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr" "github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
) )
@ -77,7 +78,8 @@ func NewModelWithFallback(m, f model.BaseChatModel, info, fInfo *modelmgr.Model)
} }
func (m *ModelForLLM) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) ( func (m *ModelForLLM) Generate(ctx context.Context, input []*schema.Message, opts ...model.Option) (
output *schema.Message, err error) { output *schema.Message, err error,
) {
if m.UseFallback(ctx) { if m.UseFallback(ctx) {
if !m.fallbackEnableCallback { if !m.fallbackEnableCallback {
defer func() { defer func() {
@ -106,7 +108,8 @@ func (m *ModelForLLM) Generate(ctx context.Context, input []*schema.Message, opt
} }
func (m *ModelForLLM) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) ( func (m *ModelForLLM) Stream(ctx context.Context, input []*schema.Message, opts ...model.Option) (
output *schema.StreamReader[*schema.Message], err error) { output *schema.StreamReader[*schema.Message], err error,
) {
if m.UseFallback(ctx) { if m.UseFallback(ctx) {
if !m.fallbackEnableCallback { if !m.fallbackEnableCallback {
defer func() { defer func() {

View File

@ -22,11 +22,11 @@ import (
"github.com/cloudwego/eino/components/prompt" "github.com/cloudwego/eino/components/prompt"
"github.com/cloudwego/eino/schema" "github.com/cloudwego/eino/schema"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo" "github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/execute"
"github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes" "github.com/coze-dev/coze-studio/backend/domain/workflow/internal/nodes"
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
"github.com/coze-dev/coze-studio/backend/pkg/ctxcache" "github.com/coze-dev/coze-studio/backend/pkg/ctxcache"
"github.com/coze-dev/coze-studio/backend/pkg/sonic" "github.com/coze-dev/coze-studio/backend/pkg/sonic"
) )
@ -108,7 +108,8 @@ func newPrompts(sp, up *promptTpl, model ModelWithInfo) *prompts {
func (pl *promptTpl) render(ctx context.Context, vs map[string]any, func (pl *promptTpl) render(ctx context.Context, vs map[string]any,
sources map[string]*nodes.SourceInfo, sources map[string]*nodes.SourceInfo,
supportedModals map[modelmgr.Modal]bool) (*schema.Message, error) { supportedModals map[modelmgr.Modal]bool,
) (*schema.Message, error) {
if !pl.hasMultiModal || len(supportedModals) == 0 { if !pl.hasMultiModal || len(supportedModals) == 0 {
var opts []nodes.RenderOption var opts []nodes.RenderOption
if len(pl.reservedKeys) > 0 { if len(pl.reservedKeys) > 0 {
@ -237,7 +238,8 @@ func (pl *promptTpl) render(ctx context.Context, vs map[string]any,
} }
func (p *prompts) Format(ctx context.Context, vs map[string]any, _ ...prompt.Option) ( func (p *prompts) Format(ctx context.Context, vs map[string]any, _ ...prompt.Option) (
_ []*schema.Message, err error) { _ []*schema.Message, err error,
) {
exeCtx := execute.GetExeCtx(ctx) exeCtx := execute.GetExeCtx(ctx)
var nodeKey vo.NodeKey var nodeKey vo.NodeKey
if exeCtx != nil && exeCtx.NodeCtx != nil { if exeCtx != nil && exeCtx.NodeCtx != nil {