Class VertexAiSessionService
java.lang.Object
com.google.adk.sessions.VertexAiSessionService
- All Implemented Interfaces:
BaseSessionService
TODO: Use the genai HttpApiClient and ApiResponse methods once they are public.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a session service with default configuration.VertexAiSessionService(String project, String location, HttpApiClient apiClient) Creates a new instance of the Vertex AI Session Service with a custom ApiClient for testing.VertexAiSessionService(String project, String location, Optional<com.google.auth.oauth2.GoogleCredentials> credentials, Optional<com.google.genai.types.HttpOptions> httpOptions) Creates a session service with specified project, location, credentials, and HTTP options. -
Method Summary
Modifier and TypeMethodDescriptionio.reactivex.rxjava3.core.Single<Event> appendEvent(Session session, Event event) Appends an event to an in-memory session object and updates the session's state based on the event's state delta, if applicable.io.reactivex.rxjava3.core.Single<Session> createSession(String appName, String userId, ConcurrentMap<String, Object> state, String sessionId) Creates a new session with the specified parameters.io.reactivex.rxjava3.core.CompletabledeleteSession(String appName, String userId, String sessionId) Deletes a specific session.io.reactivex.rxjava3.core.Maybe<Session> getSession(String appName, String userId, String sessionId, Optional<GetSessionConfig> config) Retrieves a specific session, optionally filtering the events included.io.reactivex.rxjava3.core.Single<ListEventsResponse> listEvents(String appName, String userId, String sessionId) Lists the events within a specific session.io.reactivex.rxjava3.core.Single<ListSessionsResponse> listSessions(String appName, String userId) Lists sessions associated with a specific application and user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.adk.sessions.BaseSessionService
closeSession, createSession
-
Constructor Details
-
VertexAiSessionService
Creates a new instance of the Vertex AI Session Service with a custom ApiClient for testing. -
VertexAiSessionService
public VertexAiSessionService()Creates a session service with default configuration. -
VertexAiSessionService
-
-
Method Details
-
createSession
public io.reactivex.rxjava3.core.Single<Session> createSession(String appName, String userId, @Nullable ConcurrentMap<String, Object> state, @Nullable String sessionId) Description copied from interface:BaseSessionServiceCreates a new session with the specified parameters.- Specified by:
createSessionin interfaceBaseSessionService- Parameters:
appName- The name of the application associated with the session.userId- The identifier for the user associated with the session.state- An optional map representing the initial state of the session. Can be null or empty.sessionId- An optional client-provided identifier for the session. If empty or null, the service should generate a unique ID.- Returns:
- The newly created
Sessioninstance.
-
listSessions
public io.reactivex.rxjava3.core.Single<ListSessionsResponse> listSessions(String appName, String userId) Description copied from interface:BaseSessionServiceLists sessions associated with a specific application and user.The
Sessionobjects in the response typically contain only metadata (like ID, creation time) and not the full event list or state to optimize performance.- Specified by:
listSessionsin interfaceBaseSessionService- Parameters:
appName- The name of the application.userId- The identifier of the user whose sessions are to be listed.- Returns:
- A
ListSessionsResponsecontaining a list of matching sessions.
-
listEvents
public io.reactivex.rxjava3.core.Single<ListEventsResponse> listEvents(String appName, String userId, String sessionId) Description copied from interface:BaseSessionServiceLists the events within a specific session. Supports pagination via the response object.- Specified by:
listEventsin interfaceBaseSessionService- Parameters:
appName- The name of the application.userId- The identifier of the user.sessionId- The unique identifier of the session whose events are to be listed.- Returns:
- A
ListEventsResponsecontaining a list of events and an optional token for retrieving the next page.
-
getSession
public io.reactivex.rxjava3.core.Maybe<Session> getSession(String appName, String userId, String sessionId, Optional<GetSessionConfig> config) Description copied from interface:BaseSessionServiceRetrieves a specific session, optionally filtering the events included.- Specified by:
getSessionin interfaceBaseSessionService- Parameters:
appName- The name of the application.userId- The identifier of the user.sessionId- The unique identifier of the session to retrieve.config- Optional configuration to filter the events returned within the session (e.g., limit number of recent events, filter by timestamp). If empty, default retrieval behavior is used (potentially all events or a service-defined limit).- Returns:
- An
Optionalcontaining theSessionif found, otherwiseOptional.empty().
-
deleteSession
public io.reactivex.rxjava3.core.Completable deleteSession(String appName, String userId, String sessionId) Description copied from interface:BaseSessionServiceDeletes a specific session.- Specified by:
deleteSessionin interfaceBaseSessionService- Parameters:
appName- The name of the application.userId- The identifier of the user.sessionId- The unique identifier of the session to delete.
-
appendEvent
Description copied from interface:BaseSessionServiceAppends an event to an in-memory session object and updates the session's state based on the event's state delta, if applicable.This method primarily modifies the passed
sessionobject in memory. Persisting these changes typically requires a separate call to an update/save method provided by the specific service implementation, or might happen implicitly depending on the implementation's design.If the event is marked as partial (e.g.,
event.isPartial() == true), it is returned directly without modifying the session state or event list. State delta keys starting withState.TEMP_PREFIXare ignored during state updates.- Specified by:
appendEventin interfaceBaseSessionService- Parameters:
session- TheSessionobject to which the event should be appended (will be mutated).event- TheEventto append.- Returns:
- The appended
Eventinstance (or the original event if it was partial).
-