| | |
| | | |
| | | public interface AiSessionService { |
| | | |
| | | /** |
| | | * 查询当前用户可见的 AI 会话列表,按最近更新时间倒序返回。 |
| | | */ |
| | | List<AiChatSession> listSessions(Long tenantId, Long userId); |
| | | |
| | | /** |
| | | * 显式创建一个新会话,并根据传入模型或默认模型初始化会话元数据。 |
| | | */ |
| | | AiChatSession createSession(Long tenantId, Long userId, String title, String modelCode); |
| | | |
| | | /** |
| | | * 确保指定会话存在;如果会话不存在则自动创建,存在时可顺带更新模型偏好。 |
| | | */ |
| | | AiChatSession ensureSession(Long tenantId, Long userId, String sessionId, String modelCode); |
| | | |
| | | /** |
| | | * 按租户、用户和会话 ID 精确读取会话,避免跨租户/跨用户串会话。 |
| | | */ |
| | | AiChatSession getSession(Long tenantId, Long userId, String sessionId); |
| | | |
| | | /** |
| | | * 重命名会话标题。 |
| | | */ |
| | | AiChatSession renameSession(Long tenantId, Long userId, String sessionId, String title); |
| | | |
| | | /** |
| | | * 删除会话及其聊天消息。 |
| | | */ |
| | | void removeSession(Long tenantId, Long userId, String sessionId); |
| | | |
| | | /** |
| | | * 查询会话下的完整消息列表。 |
| | | */ |
| | | List<AiChatMessage> listMessages(Long tenantId, Long userId, String sessionId); |
| | | |
| | | /** |
| | | * 查询构造上下文所需的最近若干条消息。 |
| | | */ |
| | | List<AiChatMessage> listContextMessages(Long tenantId, Long userId, String sessionId, int maxCount); |
| | | |
| | | /** |
| | | * 追加一条聊天消息,并同步刷新会话最后消息、最后活跃时间和模型信息。 |
| | | */ |
| | | AiChatMessage appendMessage(Long tenantId, Long userId, String sessionId, String role, String content, String modelCode); |
| | | |
| | | /** |
| | | * 清除会话的“停止生成”标记,通常在一次流式对话收尾时调用。 |
| | | */ |
| | | void clearStopFlag(String sessionId); |
| | | |
| | | /** |
| | | * 标记会话需要停止生成,供流式编排线程轮询消费。 |
| | | */ |
| | | void requestStop(String sessionId); |
| | | |
| | | /** |
| | | * 判断当前会话是否已收到停止生成请求。 |
| | | */ |
| | | boolean isStopRequested(String sessionId); |
| | | |
| | | } |
| | | |