Compare commits
17 Commits
feat/plugi
...
feat/brows
| Author | SHA1 | Date | |
|---|---|---|---|
| 6b466dc865 | |||
| 86c593f120 | |||
| 702413c2af | |||
| d92dacffb5 | |||
| 106c6e4d65 | |||
| 8c848401a6 | |||
| ee46dd8417 | |||
| 42147df459 | |||
| ec75ed50cd | |||
| e1c5e7e208 | |||
| 328b73f2c2 | |||
| 46f1fddbca | |||
| 4789889b17 | |||
| 6755ce02bc | |||
| 8fd60f23df | |||
| 5915d49940 | |||
| fa16cddfd2 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -60,3 +60,4 @@ values-dev.yaml
|
||||
|
||||
*.tsbuildinfo
|
||||
|
||||
*venv/
|
||||
@ -47,9 +47,9 @@ RUN apk add --no-cache --virtual .python-build-deps build-base py3-pip git && \
|
||||
COPY --from=builder /app/opencoze /app/opencoze
|
||||
|
||||
# Copy Python application scripts
|
||||
COPY backend/infra/impl/document/parser/builtin/parse_pdf.py /app/parse_pdf.py
|
||||
COPY backend/infra/impl/document/parser/builtin/parse_docx.py /app/parse_docx.py
|
||||
COPY backend/infra/impl/coderunner/script/sandbox.py /app/sandbox.py
|
||||
COPY backend/infra/document/parser/impl/builtin/parse_pdf.py /app/parse_pdf.py
|
||||
COPY backend/infra/document/parser/impl/builtin/parse_docx.py /app/parse_docx.py
|
||||
COPY backend/infra/coderunner/impl/script/sandbox.py /app/sandbox.py
|
||||
|
||||
|
||||
# Copy static resources
|
||||
|
||||
@ -30,7 +30,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/application/conversation"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/impl/sse"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/sse/impl/sse"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
|
||||
@ -83,7 +83,6 @@ import (
|
||||
pluginmodel "github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/pluginmock"
|
||||
crossuser "github.com/coze-dev/coze-studio/backend/crossdomain/contract/user"
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
|
||||
pluginImpl "github.com/coze-dev/coze-studio/backend/crossdomain/impl/plugin"
|
||||
agententity "github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
conventity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
@ -101,16 +100,16 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/variable"
|
||||
mockvar "github.com/coze-dev/coze-studio/backend/domain/workflow/variable/varmock"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/cache/redis"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/checkpoint"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/coderunner/direct"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache/impl/redis"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/checkpoint"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/coderunner/impl/direct"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
mockCrossUser "github.com/coze-dev/coze-studio/backend/internal/mock/crossdomain/crossuser"
|
||||
mockPlugin "github.com/coze-dev/coze-studio/backend/internal/mock/domain/plugin"
|
||||
mockcode "github.com/coze-dev/coze-studio/backend/internal/mock/domain/workflow/crossdomain/code"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/idgen"
|
||||
storageMock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/storage"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/idgen"
|
||||
storageMock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/storage"
|
||||
"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/errorx"
|
||||
@ -3837,7 +3836,7 @@ func TestNodeDebugLoop(t *testing.T) {
|
||||
}, nil
|
||||
}).AnyTimes()
|
||||
|
||||
code.SetCodeRunner(runner)
|
||||
coderunner.SetCodeRunner(runner)
|
||||
id := r.load("loop_with_object_input.json")
|
||||
exeID := r.nodeDebug(id, "122149",
|
||||
withNDInput(map[string]string{"input": `[{"a":"1"},{"a":"2"}]`}))
|
||||
@ -4154,7 +4153,7 @@ func TestCodeExceptionBranch(t *testing.T) {
|
||||
id := r.load("exception/code_exception_branch.json")
|
||||
|
||||
mockey.PatchConvey("exception branch", func() {
|
||||
code.SetCodeRunner(direct.NewRunner())
|
||||
coderunner.SetCodeRunner(direct.NewRunner())
|
||||
|
||||
exeID := r.testRun(id, map[string]string{"input": "hello"})
|
||||
e := r.getProcess(id, exeID)
|
||||
@ -4167,7 +4166,7 @@ func TestCodeExceptionBranch(t *testing.T) {
|
||||
|
||||
mockey.PatchConvey("normal branch", func() {
|
||||
mockCodeRunner := mockcode.NewMockRunner(r.ctrl)
|
||||
mockey.Mock(code.GetCodeRunner).Return(mockCodeRunner).Build()
|
||||
mockey.Mock(coderunner.GetCodeRunner).Return(mockCodeRunner).Build()
|
||||
mockCodeRunner.EXPECT().Run(gomock.Any(), gomock.Any()).Return(&coderunner.RunResponse{
|
||||
Result: map[string]any{
|
||||
"key0": "value0",
|
||||
@ -4891,7 +4890,7 @@ func TestHttpImplicitDependencies(t *testing.T) {
|
||||
}, nil
|
||||
}).AnyTimes()
|
||||
|
||||
code.SetCodeRunner(runner)
|
||||
coderunner.SetCodeRunner(runner)
|
||||
|
||||
mockey.PatchConvey("test http node implicit dependencies", func() {
|
||||
input := map[string]string{
|
||||
@ -6059,7 +6058,7 @@ func TestWorkflowRunWithFiles(t *testing.T) {
|
||||
}, nil
|
||||
}).AnyTimes()
|
||||
|
||||
mockey.Mock(code.GetCodeRunner).Return(runner).Build()
|
||||
mockey.Mock(coderunner.GetCodeRunner).Return(runner).Build()
|
||||
|
||||
idStr := r.load("workflow_wf_file_name.json")
|
||||
r.publish(idStr, "v0.1.1", true)
|
||||
|
||||
@ -21,9 +21,9 @@ import (
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -55,8 +55,8 @@ import (
|
||||
searchEntity "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -25,10 +25,10 @@ import (
|
||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type ServiceComponents struct {
|
||||
|
||||
@ -68,10 +68,14 @@ import (
|
||||
uploadImpl "github.com/coze-dev/coze-studio/backend/crossdomain/impl/upload"
|
||||
variablesImpl "github.com/coze-dev/coze-studio/backend/crossdomain/impl/variables"
|
||||
workflowImpl "github.com/coze-dev/coze-studio/backend/crossdomain/impl/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/checkpoint"
|
||||
implEventbus "github.com/coze-dev/coze-studio/backend/infra/impl/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/checkpoint"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/progressbar"
|
||||
progressBarImpl "github.com/coze-dev/coze-studio/backend/infra/document/progressbar/impl/progressbar"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/eventbus"
|
||||
implEventbus "github.com/coze-dev/coze-studio/backend/infra/eventbus/impl"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/sqlparser"
|
||||
sqlparserImpl "github.com/coze-dev/coze-studio/backend/infra/sqlparser/impl/sqlparser"
|
||||
)
|
||||
|
||||
type eventbusImpl struct {
|
||||
@ -116,6 +120,9 @@ func Init(ctx context.Context) (err error) {
|
||||
return err
|
||||
}
|
||||
|
||||
progressbar.New = progressBarImpl.NewProgressBar
|
||||
sqlparser.New = sqlparserImpl.NewSQLParser
|
||||
|
||||
eventbus := initEventBus(infra)
|
||||
|
||||
basicServices, err := initBasicServices(ctx, infra, eventbus)
|
||||
|
||||
@ -18,65 +18,30 @@ package appinfra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"google.golang.org/genai"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/cloudwego/eino-ext/components/embedding/gemini"
|
||||
"github.com/cloudwego/eino-ext/components/embedding/ollama"
|
||||
"github.com/cloudwego/eino-ext/components/embedding/openai"
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/milvus-io/milvus/client/v2/milvusclient"
|
||||
"github.com/volcengine/volc-sdk-golang/service/visual"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/nl2sql"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/ocr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/rerank"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/searchstore"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/embedding"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/messages2query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/cache/redis"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/coderunner/direct"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/coderunner/sandbox"
|
||||
builtinNL2SQL "github.com/coze-dev/coze-studio/backend/infra/impl/document/nl2sql/builtin"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/ocr/ppocr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/ocr/veocr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/parser/builtin"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/parser/ppstructure"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/rerank/rrf"
|
||||
vikingReranker "github.com/coze-dev/coze-studio/backend/infra/impl/document/rerank/vikingdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/searchstore/elasticsearch"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/searchstore/milvus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/searchstore/oceanbase"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/document/searchstore/vikingdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/embedding/ark"
|
||||
embeddingHttp "github.com/coze-dev/coze-studio/backend/infra/impl/embedding/http"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/embedding/wrap"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/es"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/imagex/veimagex"
|
||||
builtinM2Q "github.com/coze-dev/coze-studio/backend/infra/impl/messages2query/builtin"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/mysql"
|
||||
oceanbaseClient "github.com/coze-dev/coze-studio/backend/infra/impl/oceanbase"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/bizpkg/buildinmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache/impl/redis"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
coderunner "github.com/coze-dev/coze-studio/backend/infra/coderunner/impl"
|
||||
messages2query "github.com/coze-dev/coze-studio/backend/infra/document/messages2query/impl"
|
||||
nl2sql "github.com/coze-dev/coze-studio/backend/infra/document/nl2sql/impl"
|
||||
ocr "github.com/coze-dev/coze-studio/backend/infra/document/ocr/impl"
|
||||
parser "github.com/coze-dev/coze-studio/backend/infra/document/parser/impl"
|
||||
rerank "github.com/coze-dev/coze-studio/backend/infra/document/rerank/impl"
|
||||
searchstore "github.com/coze-dev/coze-studio/backend/infra/document/searchstore/impl"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/es/impl/es"
|
||||
eventbus "github.com/coze-dev/coze-studio/backend/infra/eventbus/impl"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen/impl/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex/impl/veimagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/orm/impl/mysql"
|
||||
storage "github.com/coze-dev/coze-studio/backend/infra/storage/impl"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
@ -105,7 +70,7 @@ type AppDependencies struct {
|
||||
func Init(ctx context.Context) (*AppDependencies, error) {
|
||||
deps := &AppDependencies{}
|
||||
var err error
|
||||
deps.TOSClient, err = initTOS(ctx)
|
||||
deps.TOSClient, err = storage.New(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init tos client failed, err=%w", err)
|
||||
}
|
||||
@ -132,29 +97,29 @@ func Init(ctx context.Context) (*AppDependencies, error) {
|
||||
return nil, fmt.Errorf("init imagex client failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.ResourceEventProducer, err = initResourceEventBusProducer()
|
||||
deps.ResourceEventProducer, err = eventbus.InitResourceEventBusProducer()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init resource event bus producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.AppEventProducer, err = initAppEventProducer()
|
||||
deps.AppEventProducer, err = eventbus.InitAppEventProducer()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init app event producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.KnowledgeEventProducer, err = initKnowledgeEventBusProducer()
|
||||
deps.KnowledgeEventProducer, err = eventbus.InitKnowledgeEventBusProducer()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init knowledge event bus producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.Reranker = initReranker()
|
||||
deps.Reranker = rerank.New()
|
||||
|
||||
deps.Rewriter, err = initRewriter(ctx)
|
||||
deps.Rewriter, err = messages2query.New(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init rewriter failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.NL2SQL, err = initNL2SQL(ctx)
|
||||
deps.NL2SQL, err = nl2sql.New(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init nl2sql failed, err=%w", err)
|
||||
}
|
||||
@ -164,17 +129,12 @@ func Init(ctx context.Context) (*AppDependencies, error) {
|
||||
return nil, fmt.Errorf("init model manager failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.CodeRunner = initCodeRunner()
|
||||
deps.CodeRunner = coderunner.New()
|
||||
|
||||
deps.OCR = initOCR()
|
||||
|
||||
imageAnnotationModel, _, err := getBuiltinChatModel(ctx, "IA_")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get builtin chat model failed, err=%w", err)
|
||||
}
|
||||
deps.OCR = ocr.New()
|
||||
|
||||
var ok bool
|
||||
deps.WorkflowBuildInChatModel, ok, err = getBuiltinChatModel(ctx, "WKR_")
|
||||
deps.WorkflowBuildInChatModel, ok, err = buildinmodel.GetBuiltinChatModel(ctx, "WKR_")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("get workflow builtin chat model failed, err=%w", err)
|
||||
}
|
||||
@ -183,12 +143,12 @@ func Init(ctx context.Context) (*AppDependencies, error) {
|
||||
logs.CtxWarnf(ctx, "workflow builtin chat model for knowledge recall not configured")
|
||||
}
|
||||
|
||||
deps.ParserManager, err = initParserManager(deps.TOSClient, deps.OCR, imageAnnotationModel)
|
||||
deps.ParserManager, err = parser.New(ctx, deps.TOSClient, deps.OCR)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init parser manager failed, err=%w", err)
|
||||
}
|
||||
|
||||
deps.SearchStoreManagers, err = initSearchStoreManagers(ctx, deps.ESClient)
|
||||
deps.SearchStoreManagers, err = searchstore.New(ctx, deps.ESClient)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init search store managers failed, err=%w", err)
|
||||
}
|
||||
@ -196,606 +156,11 @@ func Init(ctx context.Context) (*AppDependencies, error) {
|
||||
return deps, nil
|
||||
}
|
||||
|
||||
func initSearchStoreManagers(ctx context.Context, es es.Client) ([]searchstore.Manager, error) {
|
||||
// es full text search
|
||||
esSearchstoreManager := elasticsearch.NewManager(&elasticsearch.ManagerConfig{Client: es})
|
||||
|
||||
// vector search
|
||||
mgr, err := getVectorStore(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init vector store failed, err=%w", err)
|
||||
}
|
||||
|
||||
return []searchstore.Manager{esSearchstoreManager, mgr}, nil
|
||||
}
|
||||
|
||||
func initReranker() rerank.Reranker {
|
||||
rerankerType := os.Getenv("RERANK_TYPE")
|
||||
switch rerankerType {
|
||||
case "vikingdb":
|
||||
return vikingReranker.NewReranker(getVikingRerankerConfig())
|
||||
case "rrf":
|
||||
return rrf.NewRRFReranker(0)
|
||||
default:
|
||||
return rrf.NewRRFReranker(0)
|
||||
}
|
||||
}
|
||||
func getVikingRerankerConfig() *vikingReranker.Config {
|
||||
return &vikingReranker.Config{
|
||||
AK: os.Getenv("VIKINGDB_RERANK_AK"),
|
||||
SK: os.Getenv("VIKINGDB_RERANK_SK"),
|
||||
Domain: os.Getenv("VIKINGDB_RERANK_HOST"),
|
||||
Region: os.Getenv("VIKINGDB_RERANK_REGION"),
|
||||
Model: os.Getenv("VIKINGDB_RERANK_MODEL"),
|
||||
}
|
||||
}
|
||||
func initRewriter(ctx context.Context) (messages2query.MessagesToQuery, error) {
|
||||
rewriterChatModel, _, err := getBuiltinChatModel(ctx, "M2Q_")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filePath := filepath.Join(getWorkingDirectory(), "resources/conf/prompt/messages_to_query_template_jinja2.json")
|
||||
rewriterTemplate, err := readJinja2PromptTemplate(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
rewriter, err := builtinM2Q.NewMessagesToQuery(ctx, rewriterChatModel, rewriterTemplate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return rewriter, nil
|
||||
}
|
||||
|
||||
func getWorkingDirectory() string {
|
||||
root, err := os.Getwd()
|
||||
if err != nil {
|
||||
logs.Warnf("[InitConfig] Failed to get current working directory: %v", err)
|
||||
root = os.Getenv("PWD")
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
func readJinja2PromptTemplate(jsonFilePath string) (prompt.ChatTemplate, error) {
|
||||
b, err := os.ReadFile(jsonFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var m2qMessages []*schema.Message
|
||||
if err = json.Unmarshal(b, &m2qMessages); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tpl := make([]schema.MessagesTemplate, len(m2qMessages))
|
||||
for i := range m2qMessages {
|
||||
tpl[i] = m2qMessages[i]
|
||||
}
|
||||
return prompt.FromMessages(schema.Jinja2, tpl...), nil
|
||||
}
|
||||
|
||||
func initNL2SQL(ctx context.Context) (nl2sql.NL2SQL, error) {
|
||||
n2sChatModel, _, err := getBuiltinChatModel(ctx, "NL2SQL_")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
filePath := filepath.Join(getWorkingDirectory(), "resources/conf/prompt/nl2sql_template_jinja2.json")
|
||||
n2sTemplate, err := readJinja2PromptTemplate(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
n2s, err := builtinNL2SQL.NewNL2SQL(ctx, n2sChatModel, n2sTemplate)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return n2s, nil
|
||||
}
|
||||
|
||||
func initImageX(ctx context.Context) (imagex.ImageX, error) {
|
||||
uploadComponentType := os.Getenv(consts.FileUploadComponentType)
|
||||
if uploadComponentType != consts.FileUploadComponentTypeImagex {
|
||||
return storage.NewImagex(ctx)
|
||||
}
|
||||
return veimagex.New(
|
||||
os.Getenv(consts.VeImageXAK),
|
||||
os.Getenv(consts.VeImageXSK),
|
||||
os.Getenv(consts.VeImageXDomain),
|
||||
os.Getenv(consts.VeImageXUploadHost),
|
||||
os.Getenv(consts.VeImageXTemplate),
|
||||
[]string{os.Getenv(consts.VeImageXServerID)},
|
||||
)
|
||||
}
|
||||
|
||||
func initTOS(ctx context.Context) (storage.Storage, error) {
|
||||
return storage.New(ctx)
|
||||
}
|
||||
|
||||
func initResourceEventBusProducer() (eventbus.Producer, error) {
|
||||
nameServer := os.Getenv(consts.MQServer)
|
||||
resourceEventBusProducer, err := eventbus.NewProducer(nameServer,
|
||||
consts.RMQTopicResource, consts.RMQConsumeGroupResource, 1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init resource producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
return resourceEventBusProducer, nil
|
||||
}
|
||||
|
||||
func initAppEventProducer() (eventbus.Producer, error) {
|
||||
nameServer := os.Getenv(consts.MQServer)
|
||||
appEventProducer, err := eventbus.NewProducer(nameServer, consts.RMQTopicApp, consts.RMQConsumeGroupApp, 1)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init app producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
return appEventProducer, nil
|
||||
}
|
||||
|
||||
func initKnowledgeEventBusProducer() (eventbus.Producer, error) {
|
||||
nameServer := os.Getenv(consts.MQServer)
|
||||
|
||||
knowledgeProducer, err := eventbus.NewProducer(nameServer, consts.RMQTopicKnowledge, consts.RMQConsumeGroupKnowledge, 2)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init knowledge producer failed, err=%w", err)
|
||||
}
|
||||
|
||||
return knowledgeProducer, nil
|
||||
}
|
||||
|
||||
func initCodeRunner() coderunner.Runner {
|
||||
switch typ := os.Getenv(consts.CodeRunnerType); typ {
|
||||
case "sandbox":
|
||||
getAndSplit := func(key string) []string {
|
||||
v := os.Getenv(key)
|
||||
if v == "" {
|
||||
return nil
|
||||
}
|
||||
return strings.Split(v, ",")
|
||||
}
|
||||
config := &sandbox.Config{
|
||||
AllowEnv: getAndSplit(consts.CodeRunnerAllowEnv),
|
||||
AllowRead: getAndSplit(consts.CodeRunnerAllowRead),
|
||||
AllowWrite: getAndSplit(consts.CodeRunnerAllowWrite),
|
||||
AllowNet: getAndSplit(consts.CodeRunnerAllowNet),
|
||||
AllowRun: getAndSplit(consts.CodeRunnerAllowRun),
|
||||
AllowFFI: getAndSplit(consts.CodeRunnerAllowFFI),
|
||||
NodeModulesDir: os.Getenv(consts.CodeRunnerNodeModulesDir),
|
||||
TimeoutSeconds: 0,
|
||||
MemoryLimitMB: 0,
|
||||
}
|
||||
if f, err := strconv.ParseFloat(os.Getenv(consts.CodeRunnerTimeoutSeconds), 64); err == nil {
|
||||
config.TimeoutSeconds = f
|
||||
} else {
|
||||
config.TimeoutSeconds = 60.0
|
||||
}
|
||||
if mem, err := strconv.ParseInt(os.Getenv(consts.CodeRunnerMemoryLimitMB), 10, 64); err == nil {
|
||||
config.MemoryLimitMB = mem
|
||||
} else {
|
||||
config.MemoryLimitMB = 100
|
||||
}
|
||||
return sandbox.NewRunner(config)
|
||||
default:
|
||||
return direct.NewRunner()
|
||||
}
|
||||
}
|
||||
|
||||
func initOCR() ocr.OCR {
|
||||
var ocr ocr.OCR
|
||||
switch os.Getenv(consts.OCRType) {
|
||||
case "ve":
|
||||
ocrAK := os.Getenv(consts.VeOCRAK)
|
||||
ocrSK := os.Getenv(consts.VeOCRSK)
|
||||
if ocrAK == "" || ocrSK == "" {
|
||||
logs.Warnf("[ve_ocr] ak / sk not configured, ocr might not work well")
|
||||
}
|
||||
inst := visual.NewInstance()
|
||||
inst.Client.SetAccessKey(ocrAK)
|
||||
inst.Client.SetSecretKey(ocrSK)
|
||||
ocr = veocr.NewOCR(&veocr.Config{Client: inst})
|
||||
case "paddleocr":
|
||||
url := os.Getenv(consts.PPOCRAPIURL)
|
||||
client := &http.Client{}
|
||||
ocr = ppocr.NewOCR(&ppocr.Config{Client: client, URL: url})
|
||||
default:
|
||||
// accept ocr not configured
|
||||
}
|
||||
|
||||
return ocr
|
||||
}
|
||||
|
||||
func initParserManager(storage storage.Storage, ocr ocr.OCR, imageAnnotationModel chatmodel.BaseChatModel) (parser.Manager, error) {
|
||||
var parserManager parser.Manager
|
||||
parserType := os.Getenv(consts.ParserType)
|
||||
switch parserType {
|
||||
case "builtin", "":
|
||||
parserManager = builtin.NewManager(storage, ocr, imageAnnotationModel)
|
||||
case "paddleocr":
|
||||
url := os.Getenv(consts.PPStructureAPIURL)
|
||||
client := &http.Client{}
|
||||
apiConfig := &ppstructure.APIConfig{
|
||||
Client: client,
|
||||
URL: url,
|
||||
}
|
||||
parserManager = ppstructure.NewManager(apiConfig, ocr, storage, imageAnnotationModel)
|
||||
default:
|
||||
return nil, fmt.Errorf("parser type %s not supported", parserType)
|
||||
}
|
||||
|
||||
return parserManager, nil
|
||||
}
|
||||
|
||||
func getVectorStore(ctx context.Context) (searchstore.Manager, error) {
|
||||
vsType := os.Getenv("VECTOR_STORE_TYPE")
|
||||
|
||||
switch vsType {
|
||||
case "milvus":
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*5)
|
||||
defer cancel()
|
||||
|
||||
var (
|
||||
milvusAddr = os.Getenv("MILVUS_ADDR")
|
||||
user = os.Getenv("MILVUS_USER")
|
||||
password = os.Getenv("MILVUS_PASSWORD")
|
||||
milvusToken = os.Getenv("MILVUS_TOKEN")
|
||||
)
|
||||
mc, err := milvusclient.New(ctx, &milvusclient.ClientConfig{
|
||||
Address: milvusAddr,
|
||||
Username: user,
|
||||
Password: password,
|
||||
APIKey: milvusToken,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init milvus client failed, err=%w", err)
|
||||
}
|
||||
|
||||
emb, err := getEmbedding(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init milvus embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
mgr, err := milvus.NewManager(&milvus.ManagerConfig{
|
||||
Client: mc,
|
||||
Embedding: emb,
|
||||
EnableHybrid: ptr.Of(true),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init milvus vector store failed, err=%w", err)
|
||||
}
|
||||
|
||||
return mgr, nil
|
||||
case "vikingdb":
|
||||
var (
|
||||
host = os.Getenv("VIKING_DB_HOST")
|
||||
region = os.Getenv("VIKING_DB_REGION")
|
||||
ak = os.Getenv("VIKING_DB_AK")
|
||||
sk = os.Getenv("VIKING_DB_SK")
|
||||
scheme = os.Getenv("VIKING_DB_SCHEME")
|
||||
modelName = os.Getenv("VIKING_DB_MODEL_NAME")
|
||||
)
|
||||
if ak == "" || sk == "" {
|
||||
return nil, fmt.Errorf("invalid vikingdb ak / sk")
|
||||
}
|
||||
if host == "" {
|
||||
host = "api-vikingdb.volces.com"
|
||||
}
|
||||
if region == "" {
|
||||
region = "cn-beijing"
|
||||
}
|
||||
if scheme == "" {
|
||||
scheme = "https"
|
||||
}
|
||||
|
||||
var embConfig *vikingdb.VikingEmbeddingConfig
|
||||
if modelName != "" {
|
||||
embName := vikingdb.VikingEmbeddingModelName(modelName)
|
||||
if embName.Dimensions() == 0 {
|
||||
return nil, fmt.Errorf("embedding model not support, model_name=%s", modelName)
|
||||
}
|
||||
embConfig = &vikingdb.VikingEmbeddingConfig{
|
||||
UseVikingEmbedding: true,
|
||||
EnableHybrid: embName.SupportStatus() == embedding.SupportDenseAndSparse,
|
||||
ModelName: embName,
|
||||
ModelVersion: embName.ModelVersion(),
|
||||
DenseWeight: ptr.Of(0.2),
|
||||
BuiltinEmbedding: nil,
|
||||
}
|
||||
} else {
|
||||
builtinEmbedding, err := getEmbedding(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("builtint embedding init failed, err=%w", err)
|
||||
}
|
||||
|
||||
embConfig = &vikingdb.VikingEmbeddingConfig{
|
||||
UseVikingEmbedding: false,
|
||||
EnableHybrid: false,
|
||||
BuiltinEmbedding: builtinEmbedding,
|
||||
}
|
||||
}
|
||||
|
||||
svc := vikingdb.NewVikingDBService(host, region, ak, sk, scheme)
|
||||
mgr, err := vikingdb.NewManager(&vikingdb.ManagerConfig{
|
||||
Service: svc,
|
||||
IndexingConfig: nil, // use default config
|
||||
EmbeddingConfig: embConfig,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init vikingdb manager failed, err=%w", err)
|
||||
}
|
||||
|
||||
return mgr, nil
|
||||
|
||||
case "oceanbase":
|
||||
emb, err := getEmbedding(ctx)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init oceanbase embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
var (
|
||||
host = os.Getenv("OCEANBASE_HOST")
|
||||
port = os.Getenv("OCEANBASE_PORT")
|
||||
user = os.Getenv("OCEANBASE_USER")
|
||||
password = os.Getenv("OCEANBASE_PASSWORD")
|
||||
database = os.Getenv("OCEANBASE_DATABASE")
|
||||
)
|
||||
if host == "" || port == "" || user == "" || password == "" || database == "" {
|
||||
return nil, fmt.Errorf("invalid oceanbase configuration: host, port, user, password, database are required")
|
||||
}
|
||||
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
user, password, host, port, database)
|
||||
|
||||
client, err := oceanbaseClient.NewOceanBaseClient(dsn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init oceanbase client failed, err=%w", err)
|
||||
}
|
||||
|
||||
if err := client.InitDatabase(ctx); err != nil {
|
||||
return nil, fmt.Errorf("init oceanbase database failed, err=%w", err)
|
||||
}
|
||||
|
||||
// Get configuration from environment variables with defaults
|
||||
batchSize := 100
|
||||
if bs := os.Getenv("OCEANBASE_BATCH_SIZE"); bs != "" {
|
||||
if bsInt, err := strconv.Atoi(bs); err == nil {
|
||||
batchSize = bsInt
|
||||
}
|
||||
}
|
||||
|
||||
enableCache := true
|
||||
if ec := os.Getenv("OCEANBASE_ENABLE_CACHE"); ec != "" {
|
||||
if ecBool, err := strconv.ParseBool(ec); err == nil {
|
||||
enableCache = ecBool
|
||||
}
|
||||
}
|
||||
|
||||
cacheTTL := 300 * time.Second
|
||||
if ct := os.Getenv("OCEANBASE_CACHE_TTL"); ct != "" {
|
||||
if ctInt, err := strconv.Atoi(ct); err == nil {
|
||||
cacheTTL = time.Duration(ctInt) * time.Second
|
||||
}
|
||||
}
|
||||
|
||||
maxConnections := 100
|
||||
if mc := os.Getenv("OCEANBASE_MAX_CONNECTIONS"); mc != "" {
|
||||
if mcInt, err := strconv.Atoi(mc); err == nil {
|
||||
maxConnections = mcInt
|
||||
}
|
||||
}
|
||||
|
||||
connTimeout := 30 * time.Second
|
||||
if ct := os.Getenv("OCEANBASE_CONN_TIMEOUT"); ct != "" {
|
||||
if ctInt, err := strconv.Atoi(ct); err == nil {
|
||||
connTimeout = time.Duration(ctInt) * time.Second
|
||||
}
|
||||
}
|
||||
|
||||
managerConfig := &oceanbase.ManagerConfig{
|
||||
Client: client,
|
||||
Embedding: emb,
|
||||
BatchSize: batchSize,
|
||||
EnableCache: enableCache,
|
||||
CacheTTL: cacheTTL,
|
||||
MaxConnections: maxConnections,
|
||||
ConnTimeout: connTimeout,
|
||||
}
|
||||
mgr, err := oceanbase.NewManager(managerConfig)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init oceanbase vector store failed, err=%w", err)
|
||||
}
|
||||
return mgr, nil
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("unexpected vector store type, type=%s", vsType)
|
||||
}
|
||||
}
|
||||
|
||||
func getEmbedding(ctx context.Context) (embedding.Embedder, error) {
|
||||
var batchSize int
|
||||
if bs, err := strconv.ParseInt(os.Getenv("EMBEDDING_MAX_BATCH_SIZE"), 10, 64); err != nil {
|
||||
logs.CtxWarnf(ctx, "EMBEDDING_MAX_BATCH_SIZE not set / invalid, using default batchSize=100")
|
||||
batchSize = 100
|
||||
} else {
|
||||
batchSize = int(bs)
|
||||
}
|
||||
|
||||
var emb embedding.Embedder
|
||||
|
||||
switch os.Getenv("EMBEDDING_TYPE") {
|
||||
case "openai":
|
||||
var (
|
||||
openAIEmbeddingBaseURL = os.Getenv("OPENAI_EMBEDDING_BASE_URL")
|
||||
openAIEmbeddingModel = os.Getenv("OPENAI_EMBEDDING_MODEL")
|
||||
openAIEmbeddingApiKey = os.Getenv("OPENAI_EMBEDDING_API_KEY")
|
||||
openAIEmbeddingByAzure = os.Getenv("OPENAI_EMBEDDING_BY_AZURE")
|
||||
openAIEmbeddingApiVersion = os.Getenv("OPENAI_EMBEDDING_API_VERSION")
|
||||
openAIEmbeddingDims = os.Getenv("OPENAI_EMBEDDING_DIMS")
|
||||
openAIRequestEmbeddingDims = os.Getenv("OPENAI_EMBEDDING_REQUEST_DIMS")
|
||||
)
|
||||
|
||||
byAzure, err := strconv.ParseBool(openAIEmbeddingByAzure)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init openai embedding by_azure failed, err=%w", err)
|
||||
}
|
||||
|
||||
dims, err := strconv.ParseInt(openAIEmbeddingDims, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init openai embedding dims failed, err=%w", err)
|
||||
}
|
||||
|
||||
openAICfg := &openai.EmbeddingConfig{
|
||||
APIKey: openAIEmbeddingApiKey,
|
||||
ByAzure: byAzure,
|
||||
BaseURL: openAIEmbeddingBaseURL,
|
||||
APIVersion: openAIEmbeddingApiVersion,
|
||||
Model: openAIEmbeddingModel,
|
||||
// Dimensions: ptr.Of(int(dims)),
|
||||
}
|
||||
reqDims := conv.StrToInt64D(openAIRequestEmbeddingDims, 0)
|
||||
if reqDims > 0 {
|
||||
// some openai model not support request dims
|
||||
openAICfg.Dimensions = ptr.Of(int(reqDims))
|
||||
}
|
||||
|
||||
emb, err = wrap.NewOpenAIEmbedder(ctx, openAICfg, dims, batchSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init openai embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
case "ark":
|
||||
var (
|
||||
arkEmbeddingBaseURL = os.Getenv("ARK_EMBEDDING_BASE_URL")
|
||||
arkEmbeddingModel = os.Getenv("ARK_EMBEDDING_MODEL")
|
||||
arkEmbeddingApiKey = os.Getenv("ARK_EMBEDDING_API_KEY")
|
||||
// deprecated: use ARK_EMBEDDING_API_KEY instead
|
||||
// ARK_EMBEDDING_AK will be removed in the future
|
||||
arkEmbeddingAK = os.Getenv("ARK_EMBEDDING_AK")
|
||||
arkEmbeddingDims = os.Getenv("ARK_EMBEDDING_DIMS")
|
||||
arkEmbeddingAPIType = os.Getenv("ARK_EMBEDDING_API_TYPE")
|
||||
)
|
||||
|
||||
dims, err := strconv.ParseInt(arkEmbeddingDims, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init ark embedding dims failed, err=%w", err)
|
||||
}
|
||||
|
||||
apiType := ark.APITypeText
|
||||
if arkEmbeddingAPIType != "" {
|
||||
if t := ark.APIType(arkEmbeddingAPIType); t != ark.APITypeText && t != ark.APITypeMultiModal {
|
||||
return nil, fmt.Errorf("init ark embedding api_type failed, invalid api_type=%s", t)
|
||||
} else {
|
||||
apiType = t
|
||||
}
|
||||
}
|
||||
|
||||
emb, err = ark.NewArkEmbedder(ctx, &ark.EmbeddingConfig{
|
||||
APIKey: func() string {
|
||||
if arkEmbeddingApiKey != "" {
|
||||
return arkEmbeddingApiKey
|
||||
}
|
||||
return arkEmbeddingAK
|
||||
}(),
|
||||
Model: arkEmbeddingModel,
|
||||
BaseURL: arkEmbeddingBaseURL,
|
||||
APIType: &apiType,
|
||||
}, dims, batchSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init ark embedding client failed, err=%w", err)
|
||||
}
|
||||
|
||||
case "ollama":
|
||||
var (
|
||||
ollamaEmbeddingBaseURL = os.Getenv("OLLAMA_EMBEDDING_BASE_URL")
|
||||
ollamaEmbeddingModel = os.Getenv("OLLAMA_EMBEDDING_MODEL")
|
||||
ollamaEmbeddingDims = os.Getenv("OLLAMA_EMBEDDING_DIMS")
|
||||
)
|
||||
|
||||
dims, err := strconv.ParseInt(ollamaEmbeddingDims, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init ollama embedding dims failed, err=%w", err)
|
||||
}
|
||||
|
||||
emb, err = wrap.NewOllamaEmbedder(ctx, &ollama.EmbeddingConfig{
|
||||
BaseURL: ollamaEmbeddingBaseURL,
|
||||
Model: ollamaEmbeddingModel,
|
||||
}, dims, batchSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init ollama embedding failed, err=%w", err)
|
||||
}
|
||||
case "gemini":
|
||||
var (
|
||||
geminiEmbeddingBaseURL = os.Getenv("GEMINI_EMBEDDING_BASE_URL")
|
||||
geminiEmbeddingModel = os.Getenv("GEMINI_EMBEDDING_MODEL")
|
||||
geminiEmbeddingApiKey = os.Getenv("GEMINI_EMBEDDING_API_KEY")
|
||||
geminiEmbeddingDims = os.Getenv("GEMINI_EMBEDDING_DIMS")
|
||||
geminiEmbeddingBackend = os.Getenv("GEMINI_EMBEDDING_BACKEND") // "1" for BackendGeminiAPI / "2" for BackendVertexAI
|
||||
geminiEmbeddingProject = os.Getenv("GEMINI_EMBEDDING_PROJECT")
|
||||
geminiEmbeddingLocation = os.Getenv("GEMINI_EMBEDDING_LOCATION")
|
||||
)
|
||||
|
||||
if len(geminiEmbeddingModel) == 0 {
|
||||
return nil, fmt.Errorf("GEMINI_EMBEDDING_MODEL environment variable is required")
|
||||
}
|
||||
if len(geminiEmbeddingApiKey) == 0 {
|
||||
return nil, fmt.Errorf("GEMINI_EMBEDDING_API_KEY environment variable is required")
|
||||
}
|
||||
if len(geminiEmbeddingDims) == 0 {
|
||||
return nil, fmt.Errorf("GEMINI_EMBEDDING_DIMS environment variable is required")
|
||||
}
|
||||
if len(geminiEmbeddingBackend) == 0 {
|
||||
return nil, fmt.Errorf("GEMINI_EMBEDDING_BACKEND environment variable is required")
|
||||
}
|
||||
|
||||
dims, convErr := strconv.ParseInt(geminiEmbeddingDims, 10, 64)
|
||||
if convErr != nil {
|
||||
return nil, fmt.Errorf("invalid GEMINI_EMBEDDING_DIMS value: %s, err=%w", geminiEmbeddingDims, convErr)
|
||||
}
|
||||
|
||||
backend, convErr := strconv.ParseInt(geminiEmbeddingBackend, 10, 64)
|
||||
if convErr != nil {
|
||||
return nil, fmt.Errorf("invalid GEMINI_EMBEDDING_BACKEND value: %s, err=%w", geminiEmbeddingBackend, convErr)
|
||||
}
|
||||
|
||||
geminiCli, err := genai.NewClient(ctx, &genai.ClientConfig{
|
||||
APIKey: geminiEmbeddingApiKey,
|
||||
Backend: genai.Backend(backend),
|
||||
Project: geminiEmbeddingProject,
|
||||
Location: geminiEmbeddingLocation,
|
||||
HTTPOptions: genai.HTTPOptions{
|
||||
BaseURL: geminiEmbeddingBaseURL,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init gemini client failed, err=%w", err)
|
||||
}
|
||||
|
||||
emb, err = wrap.NewGeminiEmbedder(ctx, &gemini.EmbeddingConfig{
|
||||
Client: geminiCli,
|
||||
Model: geminiEmbeddingModel,
|
||||
OutputDimensionality: ptr.Of(int32(dims)),
|
||||
}, dims, batchSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init gemini embedding failed, err=%w", err)
|
||||
}
|
||||
case "http":
|
||||
var (
|
||||
httpEmbeddingBaseURL = os.Getenv("HTTP_EMBEDDING_ADDR")
|
||||
httpEmbeddingDims = os.Getenv("HTTP_EMBEDDING_DIMS")
|
||||
)
|
||||
dims, err := strconv.ParseInt(httpEmbeddingDims, 10, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init http embedding dims failed, err=%w", err)
|
||||
}
|
||||
emb, err = embeddingHttp.NewEmbedding(httpEmbeddingBaseURL, dims, batchSize)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("init http embedding failed, err=%w", err)
|
||||
}
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("init knowledge embedding failed, type not configured")
|
||||
}
|
||||
|
||||
return emb, nil
|
||||
|
||||
return veimagex.NewDefault()
|
||||
}
|
||||
|
||||
@ -25,12 +25,14 @@ import (
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"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/infra/impl/modelmgr/static"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr/impl/static"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
// TODO(fanlv) : 模型管理移到 Infra
|
||||
|
||||
func initModelMgr() (modelmgr.Manager, error) {
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
)
|
||||
|
||||
func TestInitByEnv(t *testing.T) {
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/connector/entity"
|
||||
connector "github.com/coze-dev/coze-studio/backend/domain/connector/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type ConnectorApplicationService struct {
|
||||
|
||||
@ -18,7 +18,7 @@ package connector
|
||||
|
||||
import (
|
||||
connector "github.com/coze-dev/coze-studio/backend/domain/connector/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
func InitService(tos storage.Storage) *ConnectorApplicationService {
|
||||
|
||||
@ -26,7 +26,6 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/message"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/run"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/agentrun"
|
||||
crossDomainMessage "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
@ -36,7 +35,7 @@ import (
|
||||
convEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
msgEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
cmdEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/impl/sse"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/sse/impl/sse"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -29,9 +29,9 @@ import (
|
||||
shortcutRepo "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/service"
|
||||
uploadService "github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type ServiceComponents struct {
|
||||
|
||||
@ -37,7 +37,7 @@ import (
|
||||
convEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
cmdEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
uploadService "github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/impl/sse"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/sse/impl/sse"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
@ -183,9 +183,9 @@ func parseChatflowParameters(ctx context.Context, ar *run.ChatV3Request) (map[st
|
||||
if err := json.Unmarshal([]byte(*ar.Parameters), ¶meters); err != nil {
|
||||
return nil, errors.New("parameters field should be an object, not a string")
|
||||
}
|
||||
return parameters,nil
|
||||
return parameters, nil
|
||||
}
|
||||
return parameters,nil
|
||||
return parameters, nil
|
||||
}
|
||||
|
||||
func (a *OpenapiAgentRunApplication) buildTools(ctx context.Context, shortcmd *run.ShortcutCommandDetail) ([]*entity.Tool, error) {
|
||||
|
||||
@ -33,7 +33,7 @@ import (
|
||||
cmdEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
uploadEntity "github.com/coze-dev/coze-studio/backend/domain/upload/entity"
|
||||
uploadService "github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/impl/sse"
|
||||
sseImpl "github.com/coze-dev/coze-studio/backend/infra/sse/impl/sse"
|
||||
mockSingleAgent "github.com/coze-dev/coze-studio/backend/internal/mock/domain/agent/singleagent"
|
||||
mockAgentRun "github.com/coze-dev/coze-studio/backend/internal/mock/domain/conversation/agentrun"
|
||||
mockConversation "github.com/coze-dev/coze-studio/backend/internal/mock/domain/conversation/conversation"
|
||||
|
||||
@ -32,8 +32,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/upload"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"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/logs"
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/application/search"
|
||||
knowledgeImpl "github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
@ -33,7 +33,7 @@ func InitService(ctx context.Context, c *ServiceComponents, bus search.ResourceE
|
||||
knowledgeDomainSVC, knowledgeEventHandler := knowledgeImpl.NewKnowledgeSVC(c)
|
||||
|
||||
nameServer := os.Getenv(consts.MQServer)
|
||||
if err := eventbus.DefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicKnowledge, consts.RMQConsumeGroupKnowledge, knowledgeEventHandler); err != nil {
|
||||
if err := eventbus.GetDefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicKnowledge, consts.RMQConsumeGroupKnowledge, knowledgeEventHandler); err != nil {
|
||||
return nil, fmt.Errorf("register knowledge consumer failed, err=%w", err)
|
||||
}
|
||||
|
||||
|
||||
@ -36,9 +36,9 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
resourceEntity "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||
cd "github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
cd "github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/maps"
|
||||
|
||||
@ -23,11 +23,11 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/memory/variables/repository"
|
||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/rdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
rdbService "github.com/coze-dev/coze-studio/backend/infra/impl/rdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/rdb"
|
||||
rdbService "github.com/coze-dev/coze-studio/backend/infra/rdb/impl/rdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type MemoryApplicationServices struct {
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
package modelmgr
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
func InitService(mgr modelmgr.Manager, tosClient storage.Storage) *ModelmgrApplicationService {
|
||||
|
||||
@ -20,8 +20,8 @@ import (
|
||||
"context"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/sets"
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
openapiauth2 "github.com/coze-dev/coze-studio/backend/domain/openauth/openapiauth"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
|
||||
@ -34,7 +34,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/search"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/prompt/repository"
|
||||
prompt "github.com/coze-dev/coze-studio/backend/domain/prompt/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func InitService(db *gorm.DB, idGenSVC idgen.IDGenerator, re search.ResourceEventBus) *PromptApplicationService {
|
||||
|
||||
@ -33,10 +33,10 @@ import (
|
||||
search "github.com/coze-dev/coze-studio/backend/domain/search/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/es"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/es"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
@ -71,14 +71,14 @@ func InitService(ctx context.Context, s *ServiceComponents) (*SearchApplicationS
|
||||
logs.Infof("start search domain consumer...")
|
||||
nameServer := os.Getenv(consts.MQServer)
|
||||
|
||||
err := eventbus.DefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicApp, consts.RMQConsumeGroupApp, searchConsumer)
|
||||
err := eventbus.GetDefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicApp, consts.RMQConsumeGroupApp, searchConsumer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("register search consumer failed, err=%w", err)
|
||||
}
|
||||
|
||||
searchResourceConsumer := search.NewResourceHandler(ctx, s.ESClient)
|
||||
|
||||
err = eventbus.DefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicResource, consts.RMQConsumeGroupResource, searchResourceConsumer)
|
||||
err = eventbus.GetDefaultSVC().RegisterConsumer(nameServer, consts.RMQTopicResource, consts.RMQConsumeGroupResource, searchResourceConsumer)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("register search consumer failed, err=%w", err)
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
var ShortcutCmdSVC *ShortcutCmdApplicationService
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
searchEntity "github.com/coze-dev/coze-studio/backend/domain/search/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
|
||||
@ -36,7 +36,7 @@ import (
|
||||
shortcutCMDEntity "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/entity"
|
||||
workflowEntity "github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -20,8 +20,6 @@ import (
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/repository"
|
||||
singleagent "github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/service"
|
||||
@ -34,11 +32,12 @@ import (
|
||||
shortcutCmd "github.com/coze-dev/coze-studio/backend/domain/shortcutcmd/service"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/jsoncache"
|
||||
)
|
||||
|
||||
|
||||
@ -22,8 +22,8 @@ import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/template/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type ServiceComponents struct {
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
productAPI "github.com/coze-dev/coze-studio/backend/api/model/marketplace/product_public_api"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/template/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/template/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/types/consts"
|
||||
)
|
||||
|
||||
@ -52,9 +52,9 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/upload/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/upload/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -23,8 +23,8 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
func InitService(ctx context.Context, db *gorm.DB, oss storage.Storage, idgen idgen.IDGenerator) *UserApplicationService {
|
||||
|
||||
@ -30,7 +30,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/application/base/ctxutil"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/user/entity"
|
||||
user "github.com/coze-dev/coze-studio/backend/domain/user/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
langSlices "github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
|
||||
@ -741,9 +741,6 @@ func (w *ApplicationService) convertToChatFlowRunResponseList(ctx context.Contex
|
||||
spaceID int64
|
||||
executeID int64
|
||||
|
||||
outputCount int32
|
||||
inputCount int32
|
||||
|
||||
intermediateMessage *message.Message
|
||||
|
||||
needRegeneratedMessage = true
|
||||
@ -818,12 +815,16 @@ func (w *ApplicationService) convertToChatFlowRunResponseList(ctx context.Contex
|
||||
BotID: strconv.FormatInt(bizID, 10),
|
||||
Status: vo.Completed,
|
||||
ExecuteID: strconv.FormatInt(executeID, 10),
|
||||
Usage: &vo.Usage{
|
||||
InputTokens: ptr.Of(inputCount),
|
||||
OutputTokens: ptr.Of(outputCount),
|
||||
TokenCount: ptr.Of(outputCount + inputCount),
|
||||
},
|
||||
}
|
||||
|
||||
if msg.StateMessage.Usage != nil {
|
||||
chatDoneEvent.Usage = &vo.Usage{
|
||||
InputTokens: &msg.StateMessage.Usage.InputTokens,
|
||||
OutputTokens: &msg.StateMessage.Usage.OutputTokens,
|
||||
TokenCount: ptr.Of(msg.StateMessage.Usage.OutputTokens + msg.StateMessage.Usage.OutputTokens),
|
||||
}
|
||||
}
|
||||
|
||||
data, err := sonic.MarshalString(chatDoneEvent)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@ -28,8 +28,6 @@ import (
|
||||
"github.com/cloudwego/eino/compose"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/impl/code"
|
||||
|
||||
knowledge "github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
dbservice "github.com/coze-dev/coze-studio/backend/domain/memory/database/service"
|
||||
variables "github.com/coze-dev/coze-studio/backend/domain/memory/variables/service"
|
||||
@ -40,13 +38,12 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/config"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||
workflowservice "github.com/coze-dev/coze-studio/backend/domain/workflow/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/coderunner"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type ServiceComponents struct {
|
||||
@ -101,8 +98,8 @@ func InitService(_ context.Context, components *ServiceComponents) (*Application
|
||||
workflowDomainSVC := service.NewWorkflowService(workflowRepo)
|
||||
wrapPlugin.SetOSS(components.Tos)
|
||||
|
||||
code.SetCodeRunner(components.CodeRunner)
|
||||
callbacks.AppendGlobalHandlers(workflowservice.GetTokenCallbackHandler())
|
||||
coderunner.SetCodeRunner(components.CodeRunner)
|
||||
callbacks.AppendGlobalHandlers(service.GetTokenCallbackHandler())
|
||||
|
||||
setEventBus(components.DomainNotifier)
|
||||
|
||||
|
||||
@ -53,9 +53,9 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/entity/vo"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/plugin"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package appinfra
|
||||
package buildinmodel
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -22,18 +22,18 @@ import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
ao "github.com/cloudwego/eino-ext/components/model/ark"
|
||||
"github.com/cloudwego/eino-ext/components/model/ark"
|
||||
"github.com/cloudwego/eino-ext/components/model/deepseek"
|
||||
"github.com/cloudwego/eino-ext/components/model/gemini"
|
||||
"github.com/cloudwego/eino-ext/components/model/ollama"
|
||||
mo "github.com/cloudwego/eino-ext/components/model/openai"
|
||||
"github.com/cloudwego/eino-ext/components/model/openai"
|
||||
"github.com/cloudwego/eino-ext/components/model/qwen"
|
||||
"google.golang.org/genai"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
)
|
||||
|
||||
func getBuiltinChatModel(ctx context.Context, envPrefix string) (bcm chatmodel.BaseChatModel, configured bool, err error) {
|
||||
func GetBuiltinChatModel(ctx context.Context, envPrefix string) (bcm chatmodel.BaseChatModel, configured bool, err error) {
|
||||
getEnv := func(key string) string {
|
||||
if val := os.Getenv(envPrefix + key); val != "" {
|
||||
return val
|
||||
@ -44,14 +44,14 @@ func getBuiltinChatModel(ctx context.Context, envPrefix string) (bcm chatmodel.B
|
||||
switch getEnv("BUILTIN_CM_TYPE") {
|
||||
case "openai":
|
||||
byAzure, _ := strconv.ParseBool(getEnv("BUILTIN_CM_OPENAI_BY_AZURE"))
|
||||
bcm, err = mo.NewChatModel(ctx, &mo.ChatModelConfig{
|
||||
bcm, err = openai.NewChatModel(ctx, &openai.ChatModelConfig{
|
||||
APIKey: getEnv("BUILTIN_CM_OPENAI_API_KEY"),
|
||||
ByAzure: byAzure,
|
||||
BaseURL: getEnv("BUILTIN_CM_OPENAI_BASE_URL"),
|
||||
Model: getEnv("BUILTIN_CM_OPENAI_MODEL"),
|
||||
})
|
||||
case "ark":
|
||||
bcm, err = ao.NewChatModel(ctx, &ao.ChatModelConfig{
|
||||
bcm, err = ark.NewChatModel(ctx, &ark.ChatModelConfig{
|
||||
APIKey: getEnv("BUILTIN_CM_ARK_API_KEY"),
|
||||
Model: getEnv("BUILTIN_CM_ARK_MODEL"),
|
||||
BaseURL: getEnv("BUILTIN_CM_ARK_BASE_URL"),
|
||||
51
backend/bizpkg/fileutil/fileutil.go
Normal file
51
backend/bizpkg/fileutil/fileutil.go
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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 fileutil
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/cloudwego/eino/components/prompt"
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
func GetWorkingDirectory() string {
|
||||
root, err := os.Getwd()
|
||||
if err != nil {
|
||||
logs.Warnf("[InitConfig] Failed to get current working directory: %v", err)
|
||||
root = os.Getenv("PWD")
|
||||
}
|
||||
return root
|
||||
}
|
||||
|
||||
func ReadJinja2PromptTemplate(jsonFilePath string) (prompt.ChatTemplate, error) {
|
||||
b, err := os.ReadFile(jsonFilePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var m2qMessages []*schema.Message
|
||||
if err = json.Unmarshal(b, &m2qMessages); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tpl := make([]schema.MessagesTemplate, len(m2qMessages))
|
||||
for i := range m2qMessages {
|
||||
tpl[i] = m2qMessages[i]
|
||||
}
|
||||
return prompt.FromMessages(schema.Jinja2, tpl...), nil
|
||||
}
|
||||
@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package goutil
|
||||
package fileutil
|
||||
|
||||
import (
|
||||
"os"
|
||||
@ -1,4 +1,5 @@
|
||||
- plugin_id: 2
|
||||
product_id: 7376228190244618278
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: library_search.yaml
|
||||
@ -29,6 +30,7 @@
|
||||
method: get
|
||||
sub_url: /document/coze
|
||||
- plugin_id: 3
|
||||
product_id: 7496002227321143350
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: bocha_search.yaml
|
||||
@ -61,6 +63,7 @@
|
||||
method: post
|
||||
sub_url: /v1/web-search
|
||||
- plugin_id: 4
|
||||
product_id: 7328314516272463923
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: wolfram_alpha.yaml
|
||||
@ -95,6 +98,7 @@
|
||||
method: get
|
||||
sub_url: /v2/query
|
||||
- plugin_id: 5
|
||||
product_id: 7351267469065011241
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: maker_smart_design.yaml
|
||||
@ -123,6 +127,7 @@
|
||||
method: get
|
||||
sub_url: /coze
|
||||
- plugin_id: 6
|
||||
product_id: 7343894357063385100
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: sohu_hot_news.yaml
|
||||
@ -151,6 +156,7 @@
|
||||
method: get
|
||||
sub_url: /blog/outer/temp/feeds/ark
|
||||
- plugin_id: 9
|
||||
product_id: 7461926057290153993
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: image_compression.yaml
|
||||
@ -176,6 +182,7 @@
|
||||
method: post
|
||||
sub_url: /img2base64/img2base64
|
||||
- plugin_id: 10
|
||||
product_id: 7355060468744044595
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: worth_buying.yaml
|
||||
@ -208,6 +215,7 @@
|
||||
method: get
|
||||
sub_url: /query
|
||||
- plugin_id: 11
|
||||
product_id: 7358789295274049572
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: chestnut_sign.yaml
|
||||
@ -236,6 +244,7 @@
|
||||
method: post
|
||||
sub_url: /generate_tasks
|
||||
- plugin_id: 12
|
||||
product_id: 7407722060627247143
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: sky_eye_check.yaml
|
||||
@ -284,6 +293,7 @@
|
||||
method: get
|
||||
sub_url: /search/2.0
|
||||
- plugin_id: 14
|
||||
product_id: 7395041877151514662
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_authentication_authorization.yaml
|
||||
@ -312,6 +322,7 @@
|
||||
method: post
|
||||
sub_url: /access_token/get_tenant_access_token
|
||||
- plugin_id: 15
|
||||
product_id: 7395041302766944275
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_message.yaml
|
||||
@ -373,6 +384,7 @@
|
||||
method: post
|
||||
sub_url: /message/send_webhook_message
|
||||
- plugin_id: 16
|
||||
product_id: 7395043460165779483
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_base.yaml
|
||||
@ -494,6 +506,7 @@
|
||||
method: post
|
||||
sub_url: /base/update_records
|
||||
- plugin_id: 17
|
||||
product_id: 7395040352337559578
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_sheet.yaml
|
||||
@ -593,6 +606,7 @@
|
||||
method: post
|
||||
sub_url: /spreadsheet/search_spreadsheet
|
||||
- plugin_id: 18
|
||||
product_id: 7395041172152156186
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_task.yaml
|
||||
@ -652,6 +666,7 @@
|
||||
method: patch
|
||||
sub_url: /task/update_task
|
||||
- plugin_id: 19
|
||||
product_id: 7395041536909574154
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_docx.yaml
|
||||
@ -745,6 +760,7 @@
|
||||
method: post
|
||||
sub_url: /drive/upload_media
|
||||
- plugin_id: 20
|
||||
product_id: 7408195262340104230
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_wiki.yaml
|
||||
@ -776,6 +792,7 @@
|
||||
method: post
|
||||
sub_url: /wiki/search_wiki
|
||||
- plugin_id: 21
|
||||
product_id: 7395041856574423075
|
||||
deprecated: false
|
||||
version: v1.0.0
|
||||
openapi_doc_file: lark_calendar.yaml
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
eino "github.com/cloudwego/eino/components/model"
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
)
|
||||
|
||||
//go:generate mockgen -destination modelmock/model_mock.go --package mockmodel -source modelmgr.go
|
||||
|
||||
@ -15,7 +15,7 @@ import (
|
||||
|
||||
model "github.com/cloudwego/eino/components/model"
|
||||
model0 "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||
modelmgr "github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
modelmgr "github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
gomock "go.uber.org/mock/gomock"
|
||||
)
|
||||
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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 code
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/coderunner"
|
||||
)
|
||||
|
||||
func GetCodeRunner() coderunner.Runner {
|
||||
return runnerImpl
|
||||
}
|
||||
|
||||
func SetCodeRunner(runner coderunner.Runner) {
|
||||
runnerImpl = runner
|
||||
}
|
||||
|
||||
var runnerImpl coderunner.Runner
|
||||
@ -27,7 +27,7 @@ import (
|
||||
crossknowledge "github.com/coze-dev/coze-studio/backend/crossdomain/contract/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/sonic"
|
||||
)
|
||||
|
||||
@ -24,9 +24,8 @@ import (
|
||||
|
||||
model "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/modelmgr"
|
||||
crossmodelmgr "github.com/coze-dev/coze-studio/backend/crossdomain/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
chatmodel2 "github.com/coze-dev/coze-studio/backend/infra/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel/impl/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
@ -37,7 +36,7 @@ type modelManager struct {
|
||||
|
||||
func InitDomainService(m modelmgr.Manager, f chatmodel.Factory) crossmodelmgr.Manager {
|
||||
if f == nil {
|
||||
f = chatmodel2.NewDefaultFactory()
|
||||
f = chatmodel.NewDefaultFactory()
|
||||
}
|
||||
return &modelManager{
|
||||
modelMgr: m,
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/crossdomain/contract/plugin/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/plugin/entity"
|
||||
plugin "github.com/coze-dev/coze-studio/backend/domain/plugin/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
)
|
||||
|
||||
|
||||
@ -58,10 +58,10 @@ func (c *impl) buildSingleAgentStreamExecuteReq(ctx context.Context, agentRuntim
|
||||
) *model.ExecuteRequest {
|
||||
|
||||
return &model.ExecuteRequest{
|
||||
Identity: c.buildIdentity(agentRuntime),
|
||||
Input: agentRuntime.Input,
|
||||
History: agentRuntime.HistoryMsg,
|
||||
UserID: agentRuntime.UserID,
|
||||
Identity: c.buildIdentity(agentRuntime),
|
||||
Input: agentRuntime.Input,
|
||||
History: agentRuntime.HistoryMsg,
|
||||
UserID: agentRuntime.UserID,
|
||||
CustomVariables: agentRuntime.CustomVariables,
|
||||
PreCallTools: slices.Transform(agentRuntime.PreRetrieveTools, func(tool *agentrun.Tool) *agentrun.ToolsRetriever {
|
||||
return &agentrun.ToolsRetriever{
|
||||
|
||||
@ -29,8 +29,8 @@ import (
|
||||
|
||||
"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/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
)
|
||||
@ -43,8 +43,7 @@ type Config struct {
|
||||
ModelFactory chatmodel.Factory
|
||||
CPStore compose.CheckPointStore
|
||||
|
||||
CustomVariables map[string]string
|
||||
|
||||
CustomVariables map[string]string
|
||||
|
||||
ConversationID int64
|
||||
}
|
||||
@ -75,7 +74,7 @@ func BuildAgent(ctx context.Context, conf *Config) (r *AgentRunner, err error) {
|
||||
return nil, err
|
||||
}
|
||||
if conf.CustomVariables != nil {
|
||||
for k,v := range conf.CustomVariables {
|
||||
for k, v := range conf.CustomVariables {
|
||||
avs[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"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/safego"
|
||||
|
||||
@ -22,8 +22,8 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"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/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
)
|
||||
|
||||
// createTestModel creates a test model with the given input modals
|
||||
|
||||
@ -24,8 +24,8 @@ import (
|
||||
"github.com/cloudwego/eino-ext/libs/acl/openai"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"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/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/bot_common"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/data/database/table"
|
||||
crossdatabase "github.com/coze-dev/coze-studio/backend/crossdomain/contract/database"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/memory/database/service"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/sqlparser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/sqlparser"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
)
|
||||
|
||||
@ -79,7 +79,7 @@ func (d *databaseTool) Invoke(ctx context.Context, req ExecuteSQLRequest) (strin
|
||||
tableType = table.TableType_DraftTable
|
||||
}
|
||||
|
||||
tableName, err := sqlparser.NewSQLParser().GetTableName(req.SQL)
|
||||
tableName, err := sqlparser.New().GetTableName(req.SQL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/app/developer_api"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
"context"
|
||||
"strconv"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
)
|
||||
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -23,8 +23,8 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/agent/singleagent/internal/dal"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewSingleAgentRepo(db *gorm.DB, idGen idgen.IDGenerator, cli cache.Cmdable) SingleAgentDraftRepo {
|
||||
|
||||
@ -31,8 +31,8 @@ import (
|
||||
"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/repository"
|
||||
"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/infra/chatmodel"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/modelmgr"
|
||||
"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/lang/slices"
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewAPPConnectorReleaseRefDAO(db *gorm.DB, idGen idgen.IDGenerator) *APPConnectorReleaseRefDAO {
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewAPPDraftDAO(db *gorm.DB, idGen idgen.IDGenerator) *APPDraftDAO {
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -30,8 +30,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/cache"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/taskgroup"
|
||||
|
||||
@ -34,7 +34,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/app/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -21,7 +21,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/connector"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/connector/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/i18n"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
|
||||
|
||||
@ -31,7 +31,7 @@ import (
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
msgEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
@ -82,11 +82,11 @@ func (art *AgentRuntime) ChatflowRun(ctx context.Context, imagex imagex.ImageX)
|
||||
"USER_INPUT": concatWfInput(art),
|
||||
}
|
||||
if art.GetRunMeta().ChatflowParameters != nil {
|
||||
for k,v := range art.GetRunMeta().ChatflowParameters {
|
||||
for k, v := range art.GetRunMeta().ChatflowParameters {
|
||||
chatInput[k] = v
|
||||
}
|
||||
}
|
||||
wfStreamer, err = crossworkflow.DefaultSVC().StreamExecute(ctx, executeConfig, chatInput)
|
||||
wfStreamer, err = crossworkflow.DefaultSVC().StreamExecute(ctx, executeConfig, chatInput)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
)
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/singleagent"
|
||||
crossagent "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agent"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
crossworkflow "github.com/coze-dev/coze-studio/backend/crossdomain/contract/workflow"
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"go.uber.org/mock/gomock"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
mockImagex "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
mockImagex "github.com/coze-dev/coze-studio/backend/internal/mock/infra/imagex"
|
||||
)
|
||||
|
||||
func TestParseMessageURI(t *testing.T) {
|
||||
|
||||
@ -29,7 +29,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/repository"
|
||||
msgEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
)
|
||||
|
||||
@ -32,7 +32,7 @@ import (
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
msgEntity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/internal/dal"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewRunRecordRepo(db *gorm.DB, idGen idgen.IDGenerator) RunRecordRepo {
|
||||
|
||||
@ -26,7 +26,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/internal"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/imagex"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/safego"
|
||||
)
|
||||
|
||||
@ -27,8 +27,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/repository"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/orm"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/orm"
|
||||
)
|
||||
|
||||
func TestAgentRun(t *testing.T) {
|
||||
|
||||
@ -28,7 +28,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
)
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/internal/dal"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewConversationRepo(db *gorm.DB, idGen idgen.IDGenerator) ConversationRepo {
|
||||
|
||||
@ -29,8 +29,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/repository"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/orm"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/orm"
|
||||
)
|
||||
|
||||
// Test_NewListMessage tests the NewListMessage function
|
||||
|
||||
@ -29,7 +29,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
|
||||
@ -24,7 +24,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/internal/dal"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
func NewMessageRepo(db *gorm.DB, idGen idgen.IDGenerator) MessageRepo {
|
||||
|
||||
@ -30,8 +30,8 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/message/repository"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/orm"
|
||||
mock "github.com/coze-dev/coze-studio/backend/internal/mock/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/orm"
|
||||
)
|
||||
|
||||
// Test_NewListMessage tests the NewListMessage function
|
||||
|
||||
@ -26,7 +26,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/datacopy/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/datacopy/internal/convert"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/datacopy/internal/dal/dao"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/impl/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
)
|
||||
|
||||
type DataCopySVCConfig struct {
|
||||
|
||||
@ -18,8 +18,8 @@ package entity
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
)
|
||||
|
||||
type Document struct {
|
||||
|
||||
@ -18,7 +18,7 @@ package entity
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
)
|
||||
|
||||
type RetrievalStrategy = knowledge.RetrievalStrategy
|
||||
|
||||
@ -21,8 +21,8 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -17,8 +17,8 @@
|
||||
package convert
|
||||
|
||||
import (
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/contract/rdb/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/rdb/entity"
|
||||
)
|
||||
|
||||
func ConvertColumnType(columnType document.TableColumnType) rdbEntity.DataType {
|
||||
|
||||
@ -23,7 +23,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ import (
|
||||
"github.com/smartystreets/goconvey/convey"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -31,7 +31,7 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/orm"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/orm"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/query"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/orm"
|
||||
"github.com/coze-dev/coze-studio/backend/internal/mock/infra/orm"
|
||||
)
|
||||
|
||||
func TestKnowledgeSuite(t *testing.T) {
|
||||
|
||||
@ -29,13 +29,13 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/events"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/rdb"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/contract/rdb/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/rdb"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/rdb/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
"github.com/coze-dev/coze-studio/backend/types/errno"
|
||||
|
||||
@ -23,11 +23,11 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/processor"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/repository"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/rdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/storage"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/eventbus"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/idgen"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/rdb"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/storage"
|
||||
)
|
||||
|
||||
type DocProcessorConfig struct {
|
||||
|
||||
@ -22,7 +22,7 @@ import (
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/parser"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/parser"
|
||||
)
|
||||
|
||||
func getFormatType(tp knowledge.DocumentType) parser.FileExtension {
|
||||
|
||||
@ -28,8 +28,8 @@ import (
|
||||
knowledgeModel "github.com/coze-dev/coze-studio/backend/api/model/crossdomain/knowledge"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/convert"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/searchstore"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/searchstore"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||
)
|
||||
|
||||
|
||||
@ -35,10 +35,10 @@ import (
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/consts"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/convert"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/internal/dal/model"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/document/searchstore"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/contract/rdb"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/contract/rdb/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/document/searchstore"
|
||||
"github.com/coze-dev/coze-studio/backend/infra/rdb"
|
||||
rdbEntity "github.com/coze-dev/coze-studio/backend/infra/rdb/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/errorx"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/slices"
|
||||
"github.com/coze-dev/coze-studio/backend/pkg/logs"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user