AS AgentScopeAPI 手册 / API Reference

TableStoreSessionHistoryService

public class TableStoreSessionHistoryService implements SessionHistoryService
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:47–373

Table 存储会话历史服务,在多次调用之间保存和恢复会话与记忆数据。位于 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
clientSyncClient客户端(类型 `SyncClient`)。TableStore sync client
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:69–72

TableStoreSessionHistoryService

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
clientSyncClient客户端(类型 `SyncClient`)。TableStore sync client
sessionTableNameString会话 Table 名称(类型 `String`)。session table name
messageTableNameString消息 Table 名称(类型 `String`)。message table name
sessionSecondaryIndexNameString会话 Secondary 索引名称(类型 `String`)。session secondary index name
messageSecondaryIndexNameString消息 Secondary 索引名称(类型 `String`)。message secondary index name
sessionSecondaryIndexMetaList<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.

返回Returns CompletableFuture<Void>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:96–115

stop

public CompletableFuture<Void> stop()

返回停止。

Returns the stop.

返回Returns CompletableFuture<Void>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:117–125

health

public CompletableFuture<Boolean> health()

返回健康状态。

Returns the health.

返回Returns CompletableFuture<Boolean>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:127–144

createSession

public CompletableFuture<Session> createSession(String userId, Optional<String> sessionId)

创建会话。

Creates the session.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdOptional<String>会话标识(类型 `Optional`)。The session id.
返回Returns CompletableFuture<Session>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:146–162

getSession

public CompletableFuture<Optional<Session>> getSession(String userId, String sessionId)

获取会话。

Returns the session.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns CompletableFuture<Optional<Session>>
返回CompletableFuture>。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:164–193

deleteSession

public CompletableFuture<Void> deleteSession(String userId, String sessionId)

删除会话。

Deletes the session.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
返回Returns CompletableFuture<Void>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:195–201

listSessions

public CompletableFuture<List<Session>> listSessions(String userId)

列出会话。

Lists the sessions.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
返回Returns CompletableFuture<List<Session>>
返回CompletableFuture>。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:203–233

appendMessage

public CompletableFuture<Void> appendMessage(Session session, List<Message> messages)

追加消息。

Performs the append message operation.

参数Parameters
名称Name类型Type说明Description
sessionSession会话(类型 `Session`)。The session.
messagesList<Message>消息列表(类型 `List`)。The messages.
返回Returns CompletableFuture<Void>
返回CompletableFuture。Returns completable future.
源码Source io/agentscope/runtime/engine/services/memory/persistence/session/TableStoreSessionHistoryService.java:235–262
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.