fix(agent): disallow update if prompt is empty (#1802)
This commit is contained in:
parent
14ce6bc112
commit
f19761fa31
|
|
@ -102,6 +102,18 @@ func (sa *SingleAgentDraftDAO) MGet(ctx context.Context, agentIDs []int64) ([]*e
|
||||||
return dos, nil
|
return dos, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (sa *SingleAgentDraftDAO) Save(ctx context.Context, agentInfo *entity.SingleAgent) (err error) {
|
||||||
|
po := sa.singleAgentDraftDo2Po(agentInfo)
|
||||||
|
singleAgentDAOModel := sa.dbQuery.SingleAgentDraft
|
||||||
|
|
||||||
|
err = singleAgentDAOModel.WithContext(ctx).Where(singleAgentDAOModel.AgentID.Eq(agentInfo.AgentID)).Save(po)
|
||||||
|
if err != nil {
|
||||||
|
return errorx.WrapByCode(err, errno.ErrAgentUpdateCode)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (sa *SingleAgentDraftDAO) Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error) {
|
func (sa *SingleAgentDraftDAO) Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error) {
|
||||||
po := sa.singleAgentDraftDo2Po(agentInfo)
|
po := sa.singleAgentDraftDo2Po(agentInfo)
|
||||||
singleAgentDAOModel := sa.dbQuery.SingleAgentDraft
|
singleAgentDAOModel := sa.dbQuery.SingleAgentDraft
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,7 @@ type SingleAgentDraftRepo interface {
|
||||||
MGet(ctx context.Context, agentIDs []int64) ([]*entity.SingleAgent, error)
|
MGet(ctx context.Context, agentIDs []int64) ([]*entity.SingleAgent, error)
|
||||||
Delete(ctx context.Context, spaceID, agentID int64) (err error)
|
Delete(ctx context.Context, spaceID, agentID int64) (err error)
|
||||||
Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error)
|
Update(ctx context.Context, agentInfo *entity.SingleAgent) (err error)
|
||||||
|
Save(ctx context.Context, agentInfo *entity.SingleAgent) (err error)
|
||||||
|
|
||||||
GetDisplayInfo(ctx context.Context, userID, agentID int64) (*entity.AgentDraftDisplayInfo, error)
|
GetDisplayInfo(ctx context.Context, userID, agentID int64) (*entity.AgentDraftDisplayInfo, error)
|
||||||
UpdateDisplayInfo(ctx context.Context, userID int64, e *entity.AgentDraftDisplayInfo) error
|
UpdateDisplayInfo(ctx context.Context, userID int64, e *entity.AgentDraftDisplayInfo) error
|
||||||
|
|
|
||||||
|
|
@ -153,7 +153,7 @@ func (s *singleAgentImpl) UpdateSingleAgentDraft(ctx context.Context, agentInfo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.AgentDraftRepo.Update(ctx, agentInfo)
|
return s.AgentDraftRepo.Save(ctx, agentInfo)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *singleAgentImpl) CreateSingleAgentDraftWithID(ctx context.Context, creatorID, agentID int64, draft *entity.SingleAgent) (int64, error) {
|
func (s *singleAgentImpl) CreateSingleAgentDraftWithID(ctx context.Context, creatorID, agentID int64, draft *entity.SingleAgent) (int64, error) {
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,11 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/cloudwego/eino/schema"
|
"github.com/cloudwego/eino/schema"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"go.uber.org/mock/gomock"
|
||||||
|
"gorm.io/driver/mysql"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/entity"
|
"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/model"
|
||||||
"github.com/coze-dev/coze-studio/backend/domain/knowledge/repository"
|
"github.com/coze-dev/coze-studio/backend/domain/knowledge/repository"
|
||||||
|
|
@ -35,10 +40,6 @@ import (
|
||||||
mock_db "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/rdb"
|
mock_db "github.com/coze-dev/coze-studio/backend/internal/mock/infra/contract/rdb"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/ptr"
|
||||||
"github.com/coze-dev/coze-studio/backend/pkg/lang/sets"
|
"github.com/coze-dev/coze-studio/backend/pkg/lang/sets"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
"go.uber.org/mock/gomock"
|
|
||||||
"gorm.io/driver/mysql"
|
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAddSliceIdColumn(t *testing.T) {
|
func TestAddSliceIdColumn(t *testing.T) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue