refactor(prompts-core): 重构代码结构和优化工具函数
This commit is contained in:
@@ -21,8 +21,8 @@ import (
|
||||
|
||||
// Callback 会话回调
|
||||
func Callback(ctx context.Context, req *dto.SessionCallbackReq) (*dto.SessionCallbackRes, error) {
|
||||
fmt.Println("打印会话回调", req)
|
||||
req.Messages["role"] = "assistant"
|
||||
|
||||
// 1) 更新 DB
|
||||
_, err := dao.ComposeSession.Update(ctx, &entity.ComposeSession{
|
||||
SQLBaseDO: beans.SQLBaseDO{Id: req.EpicycleId},
|
||||
@@ -163,23 +163,15 @@ func DeleteSession(ctx context.Context, req *dto.DeleteSessionReq) (*dto.DeleteS
|
||||
|
||||
// entityToHistoryRound entity → HistoryRound
|
||||
func entityToHistoryRound(s *entity.ComposeSession) *dto.HistoryRound {
|
||||
reqMsgs := util.ConvertToMessages(s.RequestContent)
|
||||
respMsgs := util.ConvertToMessages(s.ResponseContent)
|
||||
|
||||
round := &dto.HistoryRound{
|
||||
return &dto.HistoryRound{
|
||||
Id: s.Id,
|
||||
SessionId: s.SessionId,
|
||||
NodeId: s.NodeId,
|
||||
CreatedAt: gconv.String(s.CreatedAt),
|
||||
UpdatedAt: gconv.String(s.UpdatedAt),
|
||||
User: s.RequestContent,
|
||||
Assistant: s.ResponseContent,
|
||||
}
|
||||
if len(reqMsgs) > 0 {
|
||||
round.User = reqMsgs[0]
|
||||
}
|
||||
if len(respMsgs) > 0 {
|
||||
round.Assistant = respMsgs[0]
|
||||
}
|
||||
return round
|
||||
}
|
||||
|
||||
// sessionsToHistoryRounds 批量转换
|
||||
|
||||
Reference in New Issue
Block a user