`Class InMemoryArtifactService`
java.lang.Object
com.google.adk.artifacts.InMemoryArtifactService
- All Implemented Interfaces:
BaseArtifactService
这是一个基于内存(in-memory)的实现方案……
BaseArtifactService.-
构造函数概述
Constructors -
方法概述
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletabledeleteArtifact(String appName, String userId, String sessionId, String filename) 删除给定资源的所有版本。io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(String appName, String userId, String sessionId) 列出该会话中存储的所有工件的文件名。io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(String appName, String userId, String sessionId, String filename) 列出指定工件的所有版本。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, @Nullable Integer version) 可以根据版本号或最新版本来加载相应的工件(artifact)。io.reactivex.rxjava3.core.Single<com.google.genai.types.Part> saveAndReloadArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact) 保存一个“artefact”(即某种数据或对象),并在文件数据(fileData)可用时将其一并返回。io.reactivex.rxjava3.core.Single<Integer> saveArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact) 将某个“工件”(artifact)保存在内存中,并为其分配一个新的版本号。Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseArtifactService
deleteArtifact, listArtifactKeys, listVersions, loadArtifact, loadArtifact, loadArtifact, loadArtifact, saveAndReloadArtifact, saveArtifactModifier and TypeMethodDescriptiondefault io.reactivex.rxjava3.core.CompletabledeleteArtifact(SessionKey sessionKey, String filename) default io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(SessionKey sessionKey) default io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(SessionKey sessionKey, String filename) default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(SessionKey sessionKey, String filename) 从服务中加载该“工件”(artifact)的最新版本。default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(SessionKey sessionKey, String filename, int version) default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename) 从服务中加载该“工件”(artifact)的最新版本。default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, int version) 从服务中加载某个特定版本的工件(artifact)。default io.reactivex.rxjava3.core.Single<com.google.genai.types.Part> saveAndReloadArtifact(SessionKey sessionKey, String filename, com.google.genai.types.Part artifact) 保存一个“artefact”(即某种数据或对象),并在文件数据(fileData)可用时将其一并返回。default io.reactivex.rxjava3.core.Single<Integer> saveArtifact(SessionKey sessionKey, String filename, com.google.genai.types.Part artifact) 用于保存某个“文物”(即某个具有特殊价值或历史意义的物品)。
-
构造函数详细信息
-
InMemoryArtifactService
public InMemoryArtifactService()
-
-
方法详细信息(Method Details)
-
saveArtifact
public io.reactivex.rxjava3.core.Single<Integer> saveArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact) 将某个“工件”(artifact)保存在内存中,并为其分配一个新的版本号。- Specified by:
saveArtifactin interfaceBaseArtifactService- Parameters:
appName- the app nameuserId- the user IDsessionId- the session IDfilename- the filenameartifact- the artifact- Returns:
- Single with assigned version number.
-
loadArtifact
public io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, @Nullable Integer version) 可以根据版本号或最新版本来加载相应的工件(artifact)。- Specified by:
loadArtifactin interfaceBaseArtifactService- Returns:
- Maybe with the artifact, or empty if not found.
-
listArtifactKeys
public io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(String appName, String userId, String sessionId) 列出该会话中存储的所有工件的文件名。- Specified by:
listArtifactKeysin interfaceBaseArtifactService- Parameters:
appName- the app nameuserId- the user IDsessionId- the session ID- Returns:
- Single with list of artifact filenames.
-
deleteArtifact
public io.reactivex.rxjava3.core.Completable deleteArtifact(String appName, String userId, String sessionId, String filename) 删除给定资源的所有版本。- Specified by:
deleteArtifactin interfaceBaseArtifactService- Parameters:
appName- the app nameuserId- the user IDsessionId- the session IDfilename- the filename- Returns:
- Completable indicating completion.
-
listVersions
public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(String appName, String userId, String sessionId, String filename) 列出指定工件的所有版本。- Specified by:
listVersionsin interfaceBaseArtifactService- Parameters:
appName- the app nameuserId- the user IDsessionId- the session IDfilename- the artifact filename- Returns:
- Single with list of version numbers.
-
saveAndReloadArtifact
public io.reactivex.rxjava3.core.Single<com.google.genai.types.Part> saveAndReloadArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact) 描述内容复制自接口文档:BaseArtifactService保存一个“artefact”(即某种数据或对象),并在文件数据(fileData)可用时将其一并返回。为了提高效率,实现类应该覆盖这个默认方法;因为默认方法会执行两次 I/O 操作(先保存数据,再读取数据)。
- Specified by:
saveAndReloadArtifactin interfaceBaseArtifactService- Parameters:
appName- the app nameuserId- the user IDsessionId- the session IDfilename- the filenameartifact- the artifact to save- Returns:
- the saved artifact with fileData if available.
-