`GcsArtifactService` 类
java.lang.Object
com.google.adk.artifacts.GcsArtifactService
- All Implemented Interfaces:
BaseArtifactService
这是一个使用 Google Cloud Storage (GCS) 实现的工件(artifact)服务。
-
构造函数概述
ConstructorsConstructorDescriptionGcsArtifactService(String bucketName, com.google.cloud.storage.Storage storageClient) 用于初始化 GcsArtifactService 类。 -
方法概述
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletabledeleteArtifact(String appName, String userId, String sessionId, String filename) 从 GCS 中删除指定资源的所有版本。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) 列出给定软件包(artifact)的所有可用版本。io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, @Nullable Integer version) 从 GCS 加载一个工件(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)保存到 Google Cloud Storage (GCS) 并为其分配一个新的版本号。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) 用于保存某个“文物”(即某个具有特殊价值或历史意义的物品)。
-
构造函数详细信息
-
GcsArtifactService
用于初始化 GcsArtifactService 类。- Parameters:
bucketName- The name of the GCS bucket to use.storageClient- The GCS storage client instance.
-
-
方法详细信息(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)保存到 Google Cloud Storage (GCS) 并为其分配一个新的版本号。- Specified by:
saveArtifactin interfaceBaseArtifactService- Parameters:
appName- Application name.userId- User ID.sessionId- Session ID.filename- Artifact filename.artifact- Artifact content to save.- 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) 从 GCS 加载一个工件(artifact)。- Specified by:
loadArtifactin interfaceBaseArtifactService- Parameters:
appName- Application name.userId- User ID.sessionId- Session ID.filename- Artifact filename.version- Optional version to load. Loads latest if empty.- Returns:
- Maybe with loaded 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- Application name.userId- User ID.sessionId- Session ID.- Returns:
- Single with sorted list of artifact filenames.
-
deleteArtifact
public io.reactivex.rxjava3.core.Completable deleteArtifact(String appName, String userId, String sessionId, String filename) 从 GCS 中删除指定资源的所有版本。- Specified by:
deleteArtifactin interfaceBaseArtifactService- Parameters:
appName- Application name.userId- User ID.sessionId- Session ID.filename- Artifact filename.- Returns:
- Completable indicating operation completion.
-
listVersions
public io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(String appName, String userId, String sessionId, String filename) 列出给定软件包(artifact)的所有可用版本。- Specified by:
listVersionsin interfaceBaseArtifactService- Parameters:
appName- Application name.userId- User ID.sessionId- Session ID.filename- Artifact filename.- Returns:
- Single with sorted 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.
-