Browse Source

Merge branch 'yhg_241210_dify' into debug

jimmyyem 3 months ago
parent
commit
553355f541

+ 2 - 0
desc/wechat/chat_records.api

@@ -98,6 +98,7 @@ type (
 		ConversationId *string `json:"conversationId,optional"`
 		FirstId *string `json:"firstId,optional"`
 		Limit *int `json:"limit"`
+		AgentId *uint64 `json:"agentId"`
 	}
 	GptMessageResp {
 		BaseDataInfo
@@ -118,6 +119,7 @@ type (
 	GptsSessionReq {
 		Limit *int `json:"limit"`
 		LastId *string `json:"lastId,optional"`
+		AgentId *uint64 `json:"agentId"`
 	}
 	GptsSessionResp {
 		BaseDataInfo

+ 4 - 1
internal/logic/chatrecords/gpts_get_api_message_logic.go

@@ -2,6 +2,7 @@ package chatrecords
 
 import (
 	"context"
+	"fmt"
 	"github.com/alibabacloud-go/tea/tea"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"github.com/zeromicro/go-zero/core/errorx"
@@ -55,7 +56,9 @@ func (l *GptsGetApiMessageLogic) GptsGetApiMessage(req *types.GptMessageReq, tok
 	if req.Limit != nil && *req.Limit > 0 {
 		limit = strconv.Itoa(*req.Limit)
 	}
-	response, err := dify.GetChatHistory(userId, *req.ConversationId, firstId, limit)
+
+	user := fmt.Sprintf("%s:%d", userId, *req.AgentId)
+	response, err := dify.GetChatHistory(user, *req.ConversationId, firstId, limit)
 	if err != nil {
 		return nil, err
 	}

+ 4 - 1
internal/logic/chatrecords/gpts_get_api_session_logic.go

@@ -2,6 +2,7 @@ package chatrecords
 
 import (
 	"context"
+	"fmt"
 	"github.com/alibabacloud-go/tea/tea"
 	"github.com/suyuan32/simple-admin-core/rpc/types/core"
 	"github.com/zeromicro/go-zero/core/errorx"
@@ -53,7 +54,9 @@ func (l *GptsGetApiSessionLogic) GptsGetApiSession(req *types.GptsSessionReq, to
 	if req.LastId != nil && *req.LastId != "" {
 		lastId = *req.LastId
 	}
-	response, err := dify.GetSessionList(userId, lastId, limit)
+
+	user := fmt.Sprintf("%s:%d", userId, *req.AgentId)
+	response, err := dify.GetSessionList(user, lastId, limit)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
internal/logic/chatrecords/gpts_submit_api_chat_logic.go

@@ -80,7 +80,7 @@ func (l *GptsSubmitApiChatLogic) GptsSubmitApiChat(tokenStr string, req *types.G
 	var chatReq dify.ChatReq
 	chatReq.ResponseMode = "streaming"
 	chatReq.Query = *req.Content
-	chatReq.User = userId
+	chatReq.User = fmt.Sprintf("%s:%d", userId, *req.AgentId)
 
 	chatReq.ConversationId = *req.ConversationId
 

+ 4 - 2
internal/types/types.go

@@ -2426,6 +2426,7 @@ type GptMessageReq struct {
 	ConversationId *string `json:"conversationId,optional"`
 	FirstId        *string `json:"firstId,optional"`
 	Limit          *int    `json:"limit"`
+	AgentId        *uint64 `json:"agentId"`
 }
 
 // swagger:model GptMessageResp
@@ -2450,8 +2451,9 @@ type Message struct {
 
 // swagger:model GptsSessionReq
 type GptsSessionReq struct {
-	Limit  *int    `json:"limit"`
-	LastId *string `json:"lastId,optional"`
+	Limit   *int    `json:"limit"`
+	LastId  *string `json:"lastId,optional"`
+	AgentId *uint64 `json:"agentId"`
 }
 
 // swagger:model GptsSessionResp