diff --git a/examples/agents/bigtable-ai-health-concierge/.env.example b/examples/agents/bigtable-ai-health-concierge/.env.example index c091db15..1eae1a90 100644 --- a/examples/agents/bigtable-ai-health-concierge/.env.example +++ b/examples/agents/bigtable-ai-health-concierge/.env.example @@ -12,4 +12,7 @@ GOOGLE_CALLBACK_URL=http://127.0.0.1:5000/auth/callback BIGTABLE_INSTANCE_ID=your-bigtable-instance-id # Google Cloud Model Armor Configuration (Optional) -# MODEL_ARMOR_TEMPLATE_NAME=projects/your-google-cloud-project-id/locations/us-central1/templates/your-template-name \ No newline at end of file +# MODEL_ARMOR_TEMPLATE_NAME=projects/your-google-cloud-project-id/locations/us-central1/templates/your-template-name + +# Demo Mode Configuration +USE_DEMO_PATIENT=true \ No newline at end of file diff --git a/examples/agents/bigtable-ai-health-concierge/README.md b/examples/agents/bigtable-ai-health-concierge/README.md index 490ad472..395971c0 100644 --- a/examples/agents/bigtable-ai-health-concierge/README.md +++ b/examples/agents/bigtable-ai-health-concierge/README.md @@ -1,4 +1,4 @@ -# ADK Agent Web Chat with Memory Bank +# ADK Agent Web Chat with Bigtable and Memory Bank This project implements a personalized AI agent using Google Cloud's Agent Development Kit (ADK) and Agent Platform Memory Bank, integrated into a Next.js web application with Google OAuth 2.0 login. @@ -25,8 +25,12 @@ GOOGLE_CLIENT_ID=your-client-id GOOGLE_CLIENT_SECRET=your-client-secret GOOGLE_CALLBACK_URL=http://127.0.0.1:5000/auth/callback BIGTABLE_INSTANCE_ID=your-bigtable-instance-id +USE_DEMO_PATIENT=true ``` +> [!NOTE] +> Setting **`USE_DEMO_PATIENT=true`** forces the agent to query the default hardcoded demo patient profile (`john.doe@gmail.com`). Set this to `false` in your `.env` file to instruct the agent to dynamically utilize the email address of the logged-in Google OAuth user instead. + ### 2. Backend Setup (Flask) #### 2.1 Set up dependencies diff --git a/examples/agents/bigtable-ai-health-concierge/backend/agent.py b/examples/agents/bigtable-ai-health-concierge/backend/agent.py index a2fc5267..5f0aacf5 100644 --- a/examples/agents/bigtable-ai-health-concierge/backend/agent.py +++ b/examples/agents/bigtable-ai-health-concierge/backend/agent.py @@ -48,7 +48,8 @@ async def get_profile_info(callback_context: CallbackContext): """Returns the patient's demographic information such as age, gender, home zip code, and work zip code to help personalize responses. Use zip codes when searching for nearby medical facilities and pharmacies.""" if callback_context.state.get("_patient_demographics"): return None - query = f"SELECT profile FROM patients WHERE _key='john.doe@gmail.com'" + patient_key = str(callback_context.session.user_id or "").replace("'", "''") + query = f"SELECT profile FROM patients WHERE _key='{patient_key}'" res = await query_tool.execute_sql( project_id=PROJECT_ID, instance_id=BIGTABLE_INSTANCE_ID, diff --git a/examples/agents/bigtable-ai-health-concierge/backend/app.py b/examples/agents/bigtable-ai-health-concierge/backend/app.py index b688c769..9479134e 100644 --- a/examples/agents/bigtable-ai-health-concierge/backend/app.py +++ b/examples/agents/bigtable-ai-health-concierge/backend/app.py @@ -49,7 +49,10 @@ def chat(): message = data.get("message") user_name = session['name'] #user_id = session['google_id'] - user_email = os.getenv("DEMO_PATIENT_EMAIL", "john.doe@gmail.com") + if os.getenv("USE_DEMO_PATIENT", "true").lower() in ["true", "on", "1"]: + user_email = "john.doe@gmail.com" + else: + user_email = session.get('email', "john.doe@gmail.com") access_token = session.get('access_token') refresh_token = session.get('refresh_token')