From 0f38e3ebcda7617cded669e0dde63fb6b6a4ec4f Mon Sep 17 00:00:00 2001 From: "Ganesh, Mohan" Date: Thu, 9 Apr 2026 19:30:51 -0400 Subject: [PATCH] docs: update firestore session service dependency versions and artifact identifiers --- contrib/firestore-session-service/README.md | 121 +++++++++++++++----- 1 file changed, 91 insertions(+), 30 deletions(-) diff --git a/contrib/firestore-session-service/README.md b/contrib/firestore-session-service/README.md index 65aaae7cf..2092d8183 100644 --- a/contrib/firestore-session-service/README.md +++ b/contrib/firestore-session-service/README.md @@ -14,13 +14,13 @@ To integrate this Firestore session service into your ADK project, add the follo com.google.adk google-adk - 0.4.0-SNAPSHOT + 1.0.0 - com.google.adk.contrib - firestore-session-service - 0.4.0-SNAPSHOT + com.google.adk + google-adk-firestore-session-service + 1.0.0 ``` @@ -28,9 +28,9 @@ To integrate this Firestore session service into your ADK project, add the follo ```gradle dependencies { // ADK Core - implementation 'com.google.adk:google-adk:0.4.0-SNAPSHOT' + implementation 'com.google.adk:google-adk:1.0.0' // Firestore Session Service - implementation 'com.google.adk.contrib:firestore-session-service:0.4.0-SNAPSHOT' + implementation 'com.google.adk:google-adk-firestore-session-service:1.0.0' } ``` @@ -42,49 +42,110 @@ Sample Property Settings: ```properties # Firestore collection name for storing session data -adk.firestore.collection.name=adk-session +firebase.root.collection.name=adk-session # Google Cloud Storage bucket name for artifact storage -adk.gcs.bucket.name=your-gcs-bucket-name +gcs.adk.bucket.name=your-gcs-bucket-name #stop words for keyword extraction -adk.stop.words=a,about,above,after,again,against,all,am,an,and,any,are,aren't,as,at,be,because,been,before,being,below,between,both,but,by,can't,cannot,could,couldn't,did,didn't,do,does,doesn't,doing,don't,down,during,each,few,for,from,further,had,hadn't,has,hasn't,have,haven't,having,he,he'd,he'll,he's,her,here,here's,hers,herself,him,himself,his,how,i,i'd,i'll,i'm,i've,if,in,into,is +keyword.extraction.stopwords=a,about,above,after,again,against,all,am,an,and,any,are,aren't,as,at,be,because,been,before,being,below,between,both,but,by,can't,cannot,could,couldn't,did,didn't,do,does,doesn't,doing,don't,down,during,each,few,for,from,further,had,hadn't,has,hasn't,have,haven't,having,he,he'd,he'll,he's,her,here,here's,hers,herself,him,himself,his,how,i,i'd,i'll,i'm,i've,if,in,into,is ``` Then, you can use the `FirestoreDatabaseRunner` to start your ADK application with Firestore session management: ```java -import com.google.adk.agents.YourAgent; // Replace with your actual agent class -import com.google.adk.plugins.BasePlugin; +import com.google.adk.agents.BaseAgent; +import com.google.adk.agents.LlmAgent; +import com.google.adk.agents.RunConfig; import com.google.adk.runner.FirestoreDatabaseRunner; import com.google.cloud.firestore.Firestore; import com.google.cloud.firestore.FirestoreOptions; -import java.util.ArrayList; -import java.util.List; -import com.google.adk.sessions.GetSessionConfig; -import java.util.Optional; +import io.reactivex.rxjava3.core.Flowable; +import java.util.Map; +import com.google.adk.sessions.FirestoreSessionService; +import com.google.adk.sessions.Session; +import com.google.adk.tools.Annotations.Schema; +import com.google.adk.tools.FunctionTool; +import com.google.genai.types.Content; +import com.google.genai.types.Part; +import com.google.adk.events.Event; +import java.util.Scanner; +import static java.nio.charset.StandardCharsets.UTF_8; + +/*** + * + */ +public class YourAgentApplication { + public static void main(String[] args) { + System.out.println("Starting YourAgentApplication..."); + RunConfig runConfig = RunConfig.builder().build(); + String appName = "hello-time-agent"; -public class YourApp { - public static void main(String[] args) { - Firestore firestore = FirestoreOptions.getDefaultInstance().getService(); - List plugins = new ArrayList<>(); - // Add any plugins you want to use + BaseAgent timeAgent = initAgent(); + // Initialize Firestore + FirestoreOptions firestoreOptions = FirestoreOptions.getDefaultInstance(); + Firestore firestore = firestoreOptions.getService(); - FirestoreDatabaseRunner firestoreRunner = new FirestoreDatabaseRunner( - new YourAgent(), // Replace with your actual agent instance - "YourAppName", - plugins, - firestore + // Use FirestoreDatabaseRunner to persist session state + FirestoreDatabaseRunner runner = new FirestoreDatabaseRunner( + timeAgent, + appName, + firestore ); - GetSessionConfig config = GetSessionConfig.builder().build(); - // Example usage of session service - firestoreRunner.sessionService().getSession("APP_NAME","USER_ID","SESSION_ID", Optional.of(config)); + + Session session = new FirestoreSessionService(firestore) + .createSession(appName,"user1234",null,"12345") + .blockingGet(); + + + try (Scanner scanner = new Scanner(System.in, UTF_8)) { + while (true) { + System.out.print("\nYou > "); + String userInput = scanner.nextLine(); + if ("quit".equalsIgnoreCase(userInput)) { + break; + } + + Content userMsg = Content.fromParts(Part.fromText(userInput)); + Flowable events = runner.runAsync(session.userId(), session.id(), userMsg, runConfig); + + System.out.print("\nAgent > "); + events.blockingForEach(event -> { + if (event.finalResponse()) { + System.out.println(event.stringifyContent()); + } + }); + } + } + + + } + + /** Mock tool implementation */ + @Schema(description = "Get the current time for a given city") + public static Map getCurrentTime( + @Schema(name = "city", description = "Name of the city to get the time for") String city) { + return Map.of( + "city", city, + "forecast", "The time is 10:30am." + ); + } + private static BaseAgent initAgent() { + return LlmAgent.builder() + .name("hello-time-agent") + .description("Tells the current time in a specified city") + .instruction(""" + You are a helpful assistant that tells the current time in a city. + Use the 'getCurrentTime' tool for this purpose. + """) + .model("gemini-3.1-pro-preview") + .tools(FunctionTool.create(YourAgentApplication.class, "getCurrentTime")) + .build(); } + } ``` - -Make sure to replace `YourAgent` and `"YourAppName"` with your actual agent class and application name.