nagur-shareef-shaik commited on
Commit
1a26d13
·
1 Parent(s): 8756a36

Updated Query Reformulator

Browse files
insucompass/core/agent_orchestrator.py CHANGED
@@ -76,11 +76,11 @@ def reformulate_query_node(state: AgentState) -> Dict[str, Any]:
76
  history = state["conversation_history"]
77
  user_profile = state["user_profile"]
78
 
79
- profile_summary = f"User profile context: State={user_profile.get('state')}, Age={user_profile.get('age')}, History={user_profile.get('medical_history')}"
80
  prompt = load_prompt("query_reformulator")
81
  history_str = "\n".join(history)
82
 
83
- full_prompt = f"{prompt}\n\n### User Profile Summary\n{profile_summary}\n\n### Conversation History:\n{history_str}\n\n### Follow-up Question:\n{question}"
84
 
85
  response = llm.invoke(full_prompt)
86
  standalone_question = response.content.strip()
 
76
  history = state["conversation_history"]
77
  user_profile = state["user_profile"]
78
 
79
+ profile_str = str(user_profile)
80
  prompt = load_prompt("query_reformulator")
81
  history_str = "\n".join(history)
82
 
83
+ full_prompt = f"{prompt}\n\n### User Profile\n{profile_str}\n\n### Conversation History:\n{history_str}\n\n### Follow-up Question:\n{question}"
84
 
85
  response = llm.invoke(full_prompt)
86
  standalone_question = response.content.strip()
insucompass/prompts/query_reformulator.txt CHANGED
@@ -143,30 +143,4 @@ You are an expert query assistant. Your task is to take a conversation history,
143
  - **Your Correct Output:** "What documents are needed to enroll a spouse under 65 in Medicare in Miami-Dade County, Florida, zip code 33101, for a 64-year-old female, retired, with an income of $60,000 and no reported medical history?"
144
 
145
  ### YOUR TASK
146
- Reformulate the `Follow-up Question` into a self-contained question using the `Conversation History` and `User Profile`. Ensure the question captures all relevant details from the history and profile (e.g., location, timeframe, specific entities, or constraints) to make it contextual, precise, and suitable for accurate document retrieval or response generation. Output only the reformulated question.
147
-
148
- ### YOUR INPUT
149
- **Conversation History:**
150
- - User: "What are the best health insurance plans for a single 30-year-old in New York with no pre-existing conditions?"
151
- - Agent: "For a single 30-year-old in New York with no pre-existing conditions, top health insurance plans include Blue Cross Blue Shield’s HMO plans and Oscar’s EPO plans, available through the ACA marketplace, with premiums ranging from $300 to $600 per month."
152
- - User: "Which of these have the best coverage for preventive care?"
153
- **User Profile:**
154
- ```json
155
- {
156
- "zip_code": "30303",
157
- "county": "Fulton",
158
- "state": "Georgia",
159
- "age": 34,
160
- "gender": "Female",
161
- "household_size": 1,
162
- "income": 65000,
163
- "employment_status": "employed_without_coverage",
164
- "citizenship": "US Citizen",
165
- "medical_history": "None reported.",
166
- "medications": null,
167
- "special_cases": "Reports smoking tobacco."
168
- }
169
- ```
170
- **Follow-up Question:** "What about dental coverage?"
171
-
172
- **Your Correct Output:** "Which health insurance plans for a single 34-year-old female in Fulton County, Georgia, zip code 30303, employed without coverage, with an income of $65,000, no reported medical history, and who reports smoking tobacco, such as Blue Cross Blue Shield’s HMO plans or Oscar’s EPO plans, offer the best dental coverage through the ACA marketplace?"
 
143
  - **Your Correct Output:** "What documents are needed to enroll a spouse under 65 in Medicare in Miami-Dade County, Florida, zip code 33101, for a 64-year-old female, retired, with an income of $60,000 and no reported medical history?"
144
 
145
  ### YOUR TASK
146
+ Reformulate the `Follow-up Question` into a self-contained question using the `Conversation History` and `User Profile`. Ensure the question captures all relevant details from the history and profile (e.g., location, timeframe, specific entities, or constraints) to make it contextual, precise, and suitable for accurate document retrieval or response generation. Output only the reformulated question.