应用程序(App)搜索内存服务(Service)

A persistent MemoryService backed by AndroidX AppSearch in the consumer app's private storage.

Ingested events and explicit memories survive process death and reboot, never leave the device, and are retrieved by AppSearch's native full-text relevance ranking. Use this in place of com.google.adk.kt.memory.InMemoryMemoryService when constructing a com.google.adk.kt.runners.Runner in an Android consumer app:

val memoryService = AppSearchMemoryService.fromContext(applicationContext)

Memory is scoped by (appName, userId): a search never returns another user's memory. All three write paths are supported and each event / explicit memory becomes its own retrievable document.

This class holds all behavior and delegates storage to a MemoryIndex so it can be unit-tested on the host JVM; fromContext wires it to the on-device LocalStorageMemoryIndex.

类型

Link copied to clipboard
object Companion

函数

Link copied to clipboard
open suspend override fun addEventsToMemory(appName: String, userId: String, events: List<Event>, sessionId: String? = null, customMetadata: Map<String, Any?>? = null)

向内存服务中添加一个明确指定的事件列表。

Link copied to clipboard
open suspend override fun addMemory(appName: String, userId: String, memories: List<MemoryEntry>, customMetadata: Map<String, Any?>? = null)

将明确指定的内存项直接添加到内存服务中。

Link copied to clipboard
open suspend override fun addSessionToMemory(session: Session)

将一个会话添加到内存服务中。

Link copied to clipboard
open override fun close()

释放底层的索引资源。主要用于测试场景。

Link copied to clipboard
open suspend override fun searchMemory(appName: String, userId: String, query: String): SearchMemoryResponse

异步地搜索与查询条件匹配的会话(session)。