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.Completable
deleteArtifact
(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, Optional<Integer> version) Loads an artifact by version or latest.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.
-
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:
saveArtifact
in 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, Optional<Integer> version) Loads an artifact by version or latest.- Specified by:
loadArtifact
in interfaceBaseArtifactService
- Parameters:
appName
- the app nameuserId
- the user IDsessionId
- the session IDfilename
- the filenameversion
- Optional version number. If null, loads the latest version.- 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:
listArtifactKeys
in 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:
deleteArtifact
in 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:
listVersions
in interfaceBaseArtifactService
- Parameters:
appName
- the app nameuserId
- the user IDsessionId
- the session IDfilename
- the artifact filename- Returns:
- Single with list of version numbers.
-