feat: Support for Chat Flow & Agent Support for binding a single chat flow (#765)

Co-authored-by: Yu Yang <72337138+tomasyu985@users.noreply.github.com>
Co-authored-by: zengxiaohui <csu.zengxiaohui@gmail.com>
Co-authored-by: lijunwen.gigoo <lijunwen.gigoo@bytedance.com>
Co-authored-by: lvxinyu.1117 <lvxinyu.1117@bytedance.com>
Co-authored-by: liuyunchao.0510 <liuyunchao.0510@bytedance.com>
Co-authored-by: haozhenfei <37089575+haozhenfei@users.noreply.github.com>
Co-authored-by: July <jiangxujin@bytedance.com>
Co-authored-by: tecvan-fe <fanwenjie.fe@bytedance.com>
This commit is contained in:
Zhj
2025-08-28 21:53:32 +08:00
committed by GitHub
parent bbc615a18e
commit d70101c979
503 changed files with 48036 additions and 3427 deletions

View File

@@ -40,6 +40,7 @@ import (
_ "golang.org/x/image/tiff"
_ "golang.org/x/image/webp"
"gorm.io/gorm"
"github.com/google/uuid"
@@ -50,7 +51,9 @@ import (
"github.com/coze-dev/coze-studio/backend/api/model/playground"
"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/pkg/errorx"
"github.com/coze-dev/coze-studio/backend/pkg/lang/conv"
@@ -61,16 +64,26 @@ import (
"github.com/coze-dev/coze-studio/backend/types/errno"
)
func InitService(oss storage.Storage, cache cache.Cmdable) {
SVC.cache = cache
SVC.oss = oss
func InitService(components *UploadComponents) *UploadService {
SVC.cache = components.Cache
SVC.oss = components.Oss
SVC.UploadSVC = service.NewUploadSVC(components.DB, components.Idgen, components.Oss)
return SVC
}
type UploadComponents struct {
Oss storage.Storage
Cache cache.Cmdable
DB *gorm.DB
Idgen idgen.IDGenerator
}
var SVC = &UploadService{}
type UploadService struct {
oss storage.Storage
cache cache.Cmdable
oss storage.Storage
cache cache.Cmdable
UploadSVC service.UploadService
}
const (
@@ -427,6 +440,23 @@ func (u *UploadService) UploadFileOpen(ctx context.Context, req *bot_open_api.Up
}
resp.File.CreatedAt = time.Now().Unix()
resp.File.URL = url
fileEntity := entity.File{
Name: fileHeader.Filename,
FileSize: fileHeader.Size,
TosURI: objName,
Status: entity.FileStatusValid,
CreatorID: strconv.FormatInt(uid, 10),
Source: entity.FileSourceAPI,
CozeAccountID: uid,
ContentType: fileHeader.Header.Get("Content-Type"),
CreatedAt: time.Now().UnixMilli(),
UpdatedAt: time.Now().UnixMilli(),
}
domainResp, err := u.UploadSVC.UploadFile(ctx, &service.UploadFileRequest{File: &fileEntity})
if err != nil {
return &resp, err
}
resp.File.ID = strconv.FormatInt(domainResp.File.ID, 10)
return &resp, nil
}