nagur-shareef-shaik commited on
Commit
be92417
·
1 Parent(s): 28baf2e

Updated Agent Orchestrator Plan Recommender

Browse files
insucompass/core/agent_orchestrator.py CHANGED
@@ -1,6 +1,7 @@
1
  import logging
2
  import json
3
  import uuid
 
4
  import sqlite3
5
  from typing import List, Dict, Any
6
  from typing_extensions import TypedDict
@@ -80,17 +81,50 @@ def plan_recommender_node(state: AgentState) -> Dict[str, Any]:
80
  logger.info("---NODE: PLAN RECOMMENDER---")
81
  user_profile = state["user_profile"]
82
 
83
- # Formulate a generic query to retrieve a broad set of plan documents
84
- initial_plan_query = f"Find general health insurance plan options available in {user_profile.get('state', 'the US')} suitable for a {user_profile.get('age')}-year-old."
85
 
86
- # Retrieve documents
87
- documents = transformer.transform_and_retrieve(initial_plan_query)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
- # Generate structured recommendations
90
- recommendations = planner.generate_recommendations(user_profile, documents)
91
 
92
  # Create a human-friendly message to present the plans
93
- generation_message = "Thank you! I've completed your profile and based on your information, here are a few initial plan recommendations for you to consider. You can ask me more detailed questions about them."
94
 
95
  history = state["conversation_history"]
96
  # history.append(f"Agent: {generation_message}")
 
1
  import logging
2
  import json
3
  import uuid
4
+ import datetime
5
  import sqlite3
6
  from typing import List, Dict, Any
7
  from typing_extensions import TypedDict
 
81
  logger.info("---NODE: PLAN RECOMMENDER---")
82
  user_profile = state["user_profile"]
83
 
84
+ # # Formulate a generic query to retrieve a broad set of plan documents
85
+ # initial_plan_query = f"Find general health insurance plan options available in {user_profile.get('state', 'the US')} suitable for a {user_profile.get('age')}-year-old."
86
 
87
+ # # Retrieve documents
88
+ # documents = transformer.transform_and_retrieve(initial_plan_query)
89
+
90
+ # # Generate structured recommendations
91
+ # recommendations = planner.generate_recommendations(user_profile, documents)
92
+
93
+ # 1. Formulate a search query to find up-to-date plans
94
+
95
+
96
+ # ------------ 1) Capture today's date in a friendly format ------------
97
+ current_date = datetime.date.today().strftime("%B %d %Y") # e.g., "July 21 2025"
98
+
99
+ # ------------ 2) Tavern / Tavily search-query template ------------
100
+ query_template = (
101
+ '"Individual health-insurance plans" '
102
+ '"{county} County {state} {zip_code}" "{current_date}" '
103
+ '"{age}-year-old" "household size {household_size}" "income {income}" '
104
+ '"employment {employment_status}" "citizenship {citizenship}" '
105
+ '"coverage for {medical_history}" "formulary {medications}" "{special_cases}" '
106
+ '"ACA marketplace OR Healthcare.gov OR CMS Landscape File" '
107
+ '"off-exchange OR private health insurance OR direct-to-consumer plan OR short-term medical" '
108
+ '"premium" "deductible" "out-of-pocket max" "metal tier bronze silver gold platinum" '
109
+ '"network HMO PPO EPO" "Summary of Benefits and Coverage" "CMS 2025 final rate filings"'
110
+ )
111
+
112
+ # ------------ 3) Inject user-specific values ------------
113
+ search_query = query_template.format(current_date=current_date, **user_profile)
114
+ logger.info(f"Plan Recommender search query: '{search_query}'")
115
+
116
+ # 2. Use the SearchAgent to get live, up-to-date information
117
+ documents = searcher.search(search_query)
118
+
119
+ # Optional: Ingest these newly found documents for future reference
120
+ if documents:
121
+ ingestor.ingest_documents(documents)
122
 
123
+ # 3. Generate structured recommendations from the live search results
124
+ recommendations = searcher.generate_recommendations(user_profile, documents)
125
 
126
  # Create a human-friendly message to present the plans
127
+ generation_message = "Great, your profile is all set! I've prepared a few initial plan recommendations just for you. \n Ask me anything about these plans or any questions you have related to Health Insurance!"
128
 
129
  history = state["conversation_history"]
130
  # history.append(f"Agent: {generation_message}")