zhou zhou
7 小时以前 82624affb0251b75b62b35567d3eb260c06efe78
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.vincent.rsf.server.ai.service.impl;
 
import com.vincent.rsf.server.ai.dto.AiChatMemoryDto;
import com.vincent.rsf.server.ai.dto.AiChatMessageDto;
import com.vincent.rsf.server.ai.dto.AiChatSessionDto;
import com.vincent.rsf.server.ai.dto.AiChatSessionPinRequest;
import com.vincent.rsf.server.ai.dto.AiChatSessionRenameRequest;
import com.vincent.rsf.server.ai.entity.AiChatSession;
import com.vincent.rsf.server.ai.service.AiChatMemoryService;
import com.vincent.rsf.server.ai.service.impl.conversation.AiConversationCommandService;
import com.vincent.rsf.server.ai.service.impl.conversation.AiConversationQueryService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
@RequiredArgsConstructor
public class AiChatMemoryServiceImpl implements AiChatMemoryService {
 
    private final AiConversationQueryService aiConversationQueryService;
    private final AiConversationCommandService aiConversationCommandService;
 
    @Override
    public AiChatMemoryDto getMemory(Long userId, Long tenantId, String promptCode, Long sessionId) {
        return aiConversationQueryService.getMemory(userId, tenantId, promptCode, sessionId);
    }
 
    @Override
    public List<AiChatSessionDto> listSessions(Long userId, Long tenantId, String promptCode, String keyword) {
        return aiConversationQueryService.listSessions(userId, tenantId, promptCode, keyword);
    }
 
    @Override
    public AiChatSession resolveSession(Long userId, Long tenantId, String promptCode, Long sessionId, String titleSeed) {
        return aiConversationCommandService.resolveSession(userId, tenantId, promptCode, sessionId, titleSeed);
    }
 
    @Override
    public void saveRound(AiChatSession session, Long userId, Long tenantId, List<AiChatMessageDto> memoryMessages, String assistantContent) {
        aiConversationCommandService.saveRound(session, userId, tenantId, memoryMessages, assistantContent);
    }
 
    @Override
    public void removeSession(Long userId, Long tenantId, Long sessionId) {
        aiConversationCommandService.removeSession(userId, tenantId, sessionId);
    }
 
    @Override
    public AiChatSessionDto renameSession(Long userId, Long tenantId, Long sessionId, AiChatSessionRenameRequest request) {
        return aiConversationCommandService.renameSession(userId, tenantId, sessionId, request);
    }
 
    @Override
    public AiChatSessionDto pinSession(Long userId, Long tenantId, Long sessionId, AiChatSessionPinRequest request) {
        return aiConversationCommandService.pinSession(userId, tenantId, sessionId, request);
    }
 
    @Override
    public void clearSessionMemory(Long userId, Long tenantId, Long sessionId) {
        aiConversationCommandService.clearSessionMemory(userId, tenantId, sessionId);
    }
 
    @Override
    public void retainLatestRound(Long userId, Long tenantId, Long sessionId) {
        aiConversationCommandService.retainLatestRound(userId, tenantId, sessionId);
    }
}