SessionHistoryService
public interface SessionHistoryService extends Service
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:30–75定义会话历史服务契约的接口。位于 io.agentscope.runtime.engine.services.memory.service 包,实现 Service。核心成员包括 createSession、getSession、deleteSession、listSessions、appendMessage。
Session history management service interface Defines standard interfaces for creating, retrieving, updating, and deleting dialogue sessions
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public CompletableFuture<Session> createSession(String userId, Optional<String> sessionId) | 创建会话。 Create a new session for the specified user |
public CompletableFuture<Optional<Session>> getSession(String userId, String sessionId) | 获取会话。 Retrieve a specific session |
public CompletableFuture<Void> deleteSession(String userId, String sessionId) | 删除会话。 Delete a specific session |
public CompletableFuture<List<Session>> listSessions(String userId) | 列出会话。 List all sessions for the specified user |
public CompletableFuture<Void> appendMessage(Session session, List<Message> messages) | 特定会话的追加消息到历史。 Append messages to the history of a specific session |
方法详情Method Detail
createSession
public CompletableFuture<Session> createSession(String userId, Optional<String> sessionId)
创建会话。
Create a new session for the specified user
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。User identifier |
sessionId | Optional<String> | 会话标识(类型 `Optional`)。Optional session ID, automatically generated if null |
CompletableFuture<Session>返回CompletableFuture。CompletableFuture Asynchronously created new session object
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:39getSession
public CompletableFuture<Optional<Session>> getSession(String userId, String sessionId)
获取会话。
Retrieve a specific session
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。User identifier |
sessionId | String | 会话标识(类型 `String`)。Session identifier to retrieve |
CompletableFuture<Optional<Session>>返回CompletableFuture>。CompletableFuture Asynchronous retrieval result, returns session object if found, otherwise returns empty
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:48deleteSession
public CompletableFuture<Void> deleteSession(String userId, String sessionId)
删除会话。
Delete a specific session
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。User identifier |
sessionId | String | 会话标识(类型 `String`)。Session identifier to delete |
CompletableFuture<Void>返回CompletableFuture。CompletableFuture Asynchronous deletion result
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:57listSessions
public CompletableFuture<List<Session>> listSessions(String userId)
列出会话。
List all sessions for the specified user
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。User identifier |
CompletableFuture<List<Session>>返回CompletableFuture>。CompletableFuture Asynchronous session list result
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:65appendMessage
public CompletableFuture<Void> appendMessage(Session session, List<Message> messages)
特定会话的追加消息到历史。
Append messages to the history of a specific session
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
session | Session | 会话(类型 `Session`)。Session to append messages to |
messages | List<Message> | 消息到追加的消息或列出。Message or list of messages to append |
CompletableFuture<Void>返回CompletableFuture。CompletableFuture Asynchronous append result
源码Source
io/agentscope/runtime/engine/services/memory/service/SessionHistoryService.java:74