Class InMemoryArtifactService
java.lang.Object
com.google.adk.artifacts.InMemoryArtifactService
- All Implemented Interfaces:
BaseArtifactService
An in-memory implementation of the
BaseArtifactService.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.CompletabledeleteArtifact(String appName, String userId, String sessionId, String filename) Deletes all versions of the given artifact.io.reactivex.rxjava3.core.Single<ListArtifactsResponse> listArtifactKeys(String appName, String userId, String sessionId) Lists filenames of stored artifacts for the session.io.reactivex.rxjava3.core.Single<com.google.common.collect.ImmutableList<Integer>> listVersions(String appName, String userId, String sessionId, String filename) Lists all versions of the specified artifact.io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, @Nullable Integer version) Loads an artifact by version or latest.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) Saves an artifact and returns it with fileData if available.io.reactivex.rxjava3.core.Single<Integer> saveArtifact(String appName, String userId, String sessionId, String filename, com.google.genai.types.Part artifact) Saves an artifact in memory and assigns a new version.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) Loads the latest version of an artifact from the service.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) Loads the latest version of an artifact from the service.default io.reactivex.rxjava3.core.Maybe<com.google.genai.types.Part> loadArtifact(String appName, String userId, String sessionId, String filename, int version) Loads a specific version of an artifact from the service.default io.reactivex.rxjava3.core.Single<com.google.genai.types.Part> saveAndReloadArtifact(SessionKey sessionKey, String filename, com.google.genai.types.Part artifact) Saves an artifact and returns it with fileData if available.default io.reactivex.rxjava3.core.Single<Integer> saveArtifact(SessionKey sessionKey, String filename, com.google.genai.types.Part artifact) Saves an artifact.
-
Constructor Details
-
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) Saves an artifact in memory and assigns a new version.- 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) Loads an artifact by version or latest.- 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) Lists filenames of stored artifacts for the session.- 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) Deletes all versions of the given artifact.- 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) Lists all versions of the specified artifact.- 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) Description copied from interface:BaseArtifactServiceSaves an artifact and returns it with fileData if available.Implementations should override this default method for efficiency, as the default performs two I/O operations (save then load).
- 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.
-