TableStoreSessionHistoryService
public class TableStoreSessionHistoryService implements SessionHistoryService
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:47–373Table 存储会话历史服务,在多次调用之间保存和恢复会话与记忆数据。位于 io.agentscope.runtime.engine.services.memory.persistence.session 包,实现 SessionHistoryService。核心成员包括 start、stop、health、createSession、getSession、deleteSession。
TableStore-based implementation of session history service Uses Aliyun TableStore MemoryStore for persistent session and message storage
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public TableStoreSessionHistoryService(SyncClient client) | 初始化 `TableStoreSessionHistoryService` 实例。 Constructor with default table names |
public TableStoreSessionHistoryService(SyncClient client, String sessionTableName, String messageTableName, String sessionSecondaryIndexName, String messageSecondaryIndexName, List<Pair<String, MetaType>> sessionSecondaryIndexMeta) | 初始化 `TableStoreSessionHistoryService` 实例。 Constructor with custom table names and indexes |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public CompletableFuture<Void> start() | 返回启动。 Returns the start. |
public CompletableFuture<Void> stop() | 返回停止。 Returns the stop. |
public CompletableFuture<Boolean> health() | 返回健康状态。 Returns the health. |
public CompletableFuture<Session> createSession(String userId, Optional<String> sessionId) | 创建会话。 Creates the session. |
public CompletableFuture<Optional<Session>> getSession(String userId, String sessionId) | 获取会话。 Returns the session. |
public CompletableFuture<Void> deleteSession(String userId, String sessionId) | 删除会话。 Deletes the session. |
public CompletableFuture<List<Session>> listSessions(String userId) | 列出会话。 Lists the sessions. |
public CompletableFuture<Void> appendMessage(Session session, List<Message> messages) | 追加消息。 Performs the append message operation. |
构造器详情Constructor Detail
TableStoreSessionHistoryService
public TableStoreSessionHistoryService(SyncClient client)
初始化 TableStoreSessionHistoryService 实例。
Constructor with default table names
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | SyncClient | 客户端(类型 `SyncClient`)。TableStore sync client |
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:69–72TableStoreSessionHistoryService
public TableStoreSessionHistoryService(SyncClient client, String sessionTableName, String messageTableName, String sessionSecondaryIndexName, String messageSecondaryIndexName, List<Pair<String, MetaType>> sessionSecondaryIndexMeta)
初始化 TableStoreSessionHistoryService 实例。
Constructor with custom table names and indexes
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
client | SyncClient | 客户端(类型 `SyncClient`)。TableStore sync client |
sessionTableName | String | 会话 Table 名称(类型 `String`)。session table name |
messageTableName | String | 消息 Table 名称(类型 `String`)。message table name |
sessionSecondaryIndexName | String | 会话 Secondary 索引名称(类型 `String`)。session secondary index name |
messageSecondaryIndexName | String | 消息 Secondary 索引名称(类型 `String`)。message secondary index name |
sessionSecondaryIndexMeta | List<Pair<String, MetaType>> | 会话 Secondary 索引元数据(类型 `List >`)。session secondary index metadata |
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:84–94方法详情Method Detail
start
public CompletableFuture<Void> start()
返回启动。
Returns the start.
CompletableFuture<Void>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:96–115stop
public CompletableFuture<Void> stop()
返回停止。
Returns the stop.
CompletableFuture<Void>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:117–125health
public CompletableFuture<Boolean> health()
返回健康状态。
Returns the health.
CompletableFuture<Boolean>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:127–144createSession
public CompletableFuture<Session> createSession(String userId, Optional<String> sessionId)
创建会话。
Creates the session.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | Optional<String> | 会话标识(类型 `Optional`)。The session id. |
CompletableFuture<Session>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:146–162getSession
public CompletableFuture<Optional<Session>> getSession(String userId, String sessionId)
获取会话。
Returns the session.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
CompletableFuture<Optional<Session>>返回CompletableFuture>。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:164–193deleteSession
public CompletableFuture<Void> deleteSession(String userId, String sessionId)
删除会话。
Deletes the session.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
CompletableFuture<Void>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:195–201listSessions
public CompletableFuture<List<Session>> listSessions(String userId)
列出会话。
Lists the sessions.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
userId | String | 用户标识(类型 `String`)。The user id. |
CompletableFuture<List<Session>>返回CompletableFuture>。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:203–233appendMessage
public CompletableFuture<Void> appendMessage(Session session, List<Message> messages)
追加消息。
Performs the append message operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
session | Session | 会话(类型 `Session`)。The session. |
messages | List<Message> | 消息列表(类型 `List`)。The messages. |
CompletableFuture<Void>返回CompletableFuture。Returns completable future.
源码Source
io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:235–262