feat: use listrun as get latest runIDs func
This commit is contained in:
@ -20,12 +20,13 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
crossconversation "github.com/coze-dev/coze-studio/backend/crossdomain/contract/conversation"
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
"runtime/debug"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
crossconversation "github.com/coze-dev/coze-studio/backend/crossdomain/contract/conversation"
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/workflow"
|
||||
@ -592,6 +593,7 @@ func (w *ApplicationService) OpenAPIChatFlowRun(ctx context.Context, req *workfl
|
||||
AgentID: agentID,
|
||||
ConversationID: ptr.Of(conversationID),
|
||||
RoundID: ptr.Of(roundID),
|
||||
InitRoundID: ptr.Of(roundID),
|
||||
})
|
||||
if err != nil {
|
||||
uErr := unbinding()
|
||||
@ -655,8 +657,9 @@ func (w *ApplicationService) OpenAPIChatFlowRun(ctx context.Context, req *workfl
|
||||
BizType: vo.BizTypeWorkflow,
|
||||
ConversationID: ptr.Of(conversationID),
|
||||
RoundID: ptr.Of(roundID),
|
||||
InitRoundID: ptr.Of(roundID),
|
||||
UserMessage: userSchemaMessage,
|
||||
Cancellable: isDebug == true,
|
||||
Cancellable: isDebug,
|
||||
}
|
||||
|
||||
parameters["USER_INPUT"], err = w.makeChatFlowUserInput(ctx, lastUserMessage)
|
||||
|
||||
@ -18,10 +18,13 @@ package crossagentrun
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
)
|
||||
|
||||
type AgentRun interface {
|
||||
Delete(ctx context.Context, runID []int64) error
|
||||
List(ctx context.Context, ListMeta *entity.ListRunRecordMeta) ([]*entity.RunRecordMeta, error)
|
||||
}
|
||||
|
||||
var defaultSVC AgentRun
|
||||
|
||||
@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
|
||||
crossagentrun "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agentrun"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
agentrun "github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/service"
|
||||
)
|
||||
|
||||
@ -44,3 +45,7 @@ func InitDomainService(c agentrun.Run) crossagentrun.AgentRun {
|
||||
func (c *impl) Delete(ctx context.Context, runID []int64) error {
|
||||
return c.DomainSVC.Delete(ctx, runID)
|
||||
}
|
||||
|
||||
func (c *impl) List(ctx context.Context, meta *entity.ListRunRecordMeta) ([]*entity.RunRecordMeta, error) {
|
||||
return c.DomainSVC.List(ctx, meta)
|
||||
}
|
||||
|
||||
@ -24,8 +24,10 @@ import (
|
||||
"github.com/cloudwego/eino/schema"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/conversation/common"
|
||||
"github.com/coze-dev/coze-studio/backend/api/model/crossdomain/message"
|
||||
crossagentrun "github.com/coze-dev/coze-studio/backend/crossdomain/contract/agentrun"
|
||||
crossconversation "github.com/coze-dev/coze-studio/backend/crossdomain/contract/conversation"
|
||||
crossmessage "github.com/coze-dev/coze-studio/backend/crossdomain/contract/message"
|
||||
agententity "github.com/coze-dev/coze-studio/backend/domain/conversation/agentrun/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/conversation/conversation/entity"
|
||||
msgentity "github.com/coze-dev/coze-studio/backend/domain/conversation/message/entity"
|
||||
"github.com/coze-dev/coze-studio/backend/domain/workflow/crossdomain/conversation"
|
||||
@ -147,7 +149,25 @@ func (c *ConversationRepository) EditMessage(ctx context.Context, req *conversat
|
||||
}
|
||||
|
||||
func (c *ConversationRepository) GetLatestRunIDs(ctx context.Context, req *conversation.GetLatestRunIDsRequest) ([]int64, error) {
|
||||
return []int64{0}, nil
|
||||
listMeta := &agententity.ListRunRecordMeta{
|
||||
ConversationID: req.ConversationID,
|
||||
AgentID: req.AppID,
|
||||
Limit: int32(req.Rounds),
|
||||
}
|
||||
|
||||
if req.InitRunID != nil {
|
||||
listMeta.BeforeID = *req.InitRunID
|
||||
}
|
||||
|
||||
runRecords, err := crossagentrun.DefaultSVC().List(ctx, listMeta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
runIDs := make([]int64, 0, len(runRecords))
|
||||
for _, record := range runRecords {
|
||||
runIDs = append(runIDs, record.ID)
|
||||
}
|
||||
return runIDs, nil
|
||||
}
|
||||
|
||||
func (c *ConversationRepository) GetMessagesByRunIDs(ctx context.Context, req *conversation.GetMessagesByRunIDsRequest) (*conversation.GetMessagesByRunIDsResponse, error) {
|
||||
|
||||
@ -96,6 +96,7 @@ type GetLatestRunIDsRequest struct {
|
||||
UserID int64
|
||||
AppID int64
|
||||
Rounds int64
|
||||
InitRunID *int64
|
||||
}
|
||||
type ClearConversationHistoryReq struct {
|
||||
ConversationID int64
|
||||
|
||||
@ -40,6 +40,7 @@ type ExecuteConfig struct {
|
||||
Cancellable bool
|
||||
WorkflowMode WorkflowMode
|
||||
RoundID *int64 // if workflow is chat flow, conversation round id is required
|
||||
InitRoundID *int64 // if workflow is chat flow, init conversation round id is required
|
||||
ConversationID *int64 // if workflow is chat flow, conversation id is required
|
||||
UserMessage *schema.Message
|
||||
ConversationHistory []*conversation.Message
|
||||
|
||||
@ -75,6 +75,7 @@ func (ch *ConversationHistory) Invoke(ctx context.Context, input map[string]any)
|
||||
connectorID = execCtx.ExeCfg.ConnectorID
|
||||
userID = execCtx.ExeCfg.Operator
|
||||
version = execCtx.ExeCfg.Version
|
||||
initRunID = execCtx.ExeCfg.InitRoundID
|
||||
)
|
||||
if agentID != nil {
|
||||
return nil, vo.WrapError(errno.ErrConversationNodesNotAvailable, fmt.Errorf("in the agent scenario, query conversation list is not available"))
|
||||
@ -137,6 +138,7 @@ func (ch *ConversationHistory) Invoke(ctx context.Context, input map[string]any)
|
||||
UserID: userID,
|
||||
AppID: *appID,
|
||||
Rounds: rounds,
|
||||
InitRunID: initRunID,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
|
||||
@ -275,6 +275,12 @@ table "api_key" {
|
||||
default = 0
|
||||
comment = "Used Time in Milliseconds"
|
||||
}
|
||||
column "ak_type" {
|
||||
null = false
|
||||
type = tinyint
|
||||
default = 0
|
||||
comment = "api key type "
|
||||
}
|
||||
primary_key {
|
||||
columns = [column.id]
|
||||
}
|
||||
@ -3127,6 +3133,17 @@ table "single_agent_draft" {
|
||||
type = json
|
||||
comment = "Agent Database Base Configuration"
|
||||
}
|
||||
column "bot_mode" {
|
||||
null = false
|
||||
type = tinyint
|
||||
default = 0
|
||||
comment = "bot mode,0:single mode 2:chatflow mode"
|
||||
}
|
||||
column "layout_info" {
|
||||
null = true
|
||||
type = text
|
||||
comment = "chatflow layout info"
|
||||
}
|
||||
column "shortcut_command" {
|
||||
null = true
|
||||
type = json
|
||||
@ -3288,6 +3305,17 @@ table "single_agent_version" {
|
||||
unsigned = true
|
||||
comment = "Create Time in Milliseconds"
|
||||
}
|
||||
column "bot_mode" {
|
||||
null = false
|
||||
type = tinyint
|
||||
default = 0
|
||||
comment = "bot mode,0:single mode 2:chatflow mode"
|
||||
}
|
||||
column "layout_info" {
|
||||
null = true
|
||||
type = text
|
||||
comment = "chatflow layout info"
|
||||
}
|
||||
column "updated_at" {
|
||||
null = false
|
||||
type = bigint
|
||||
|
||||
Reference in New Issue
Block a user