send application info to prompt
This commit is contained in:
parent
538ea04aa5
commit
d61aac5813
2 changed files with 18 additions and 1 deletions
|
|
@ -16,11 +16,17 @@ async def insurance_chat(request: models.InsuranceChatRequest):
|
|||
if request.context and request.context.page:
|
||||
page_id = str(request.context.page).lower()
|
||||
current_page = await get_page_description(page_id)
|
||||
|
||||
application = None
|
||||
if request.context and request.context.application:
|
||||
application = request.context.application
|
||||
|
||||
result = await chat_service.process_insurance_chat(
|
||||
message=request.message,
|
||||
session_id=request.session_id,
|
||||
uid=str(request.userId),
|
||||
current_page=current_page,
|
||||
application=application,
|
||||
)
|
||||
|
||||
return models.InsuranceChatResponse(
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class ChatService:
|
|||
# For now, return empty list - this would be populated when RAG is implemented
|
||||
return []
|
||||
|
||||
async def process_insurance_chat(self, message: str, session_id: Optional[str] = None, uid: Optional[int] = None, current_page: Optional[str] = None) -> Dict[str, Any]:
|
||||
async def process_insurance_chat(self, message: str, session_id: Optional[str] = None, uid: Optional[int] = None, current_page: Optional[str] = None, application: Optional[dict] = None) -> Dict[str, Any]:
|
||||
"""Process an insurance chat request"""
|
||||
try:
|
||||
if not session_id:
|
||||
|
|
@ -148,6 +148,17 @@ class ChatService:
|
|||
if uid:
|
||||
user_state = await self.get_user_state(uid)
|
||||
instructions += f"\n\n# User Information\nApplication state (None means that application was not sent or pending):\n{user_state}"
|
||||
if application:
|
||||
instructions += f"\n\n# User Application Info\n"
|
||||
if application.get("plans", []):
|
||||
plans_info = "User plans:\n"
|
||||
for p in application["plans"]:
|
||||
plans_info += f"{str(p)}\n"
|
||||
instructions += plans_info
|
||||
if application.get("phq", {}).get("effective_date", None):
|
||||
effective_date = application.get("phq", {}).get("effective_date", None)
|
||||
instructions += f"Plan effective date: {effective_date}"
|
||||
|
||||
if current_page:
|
||||
instructions += f"\n\n# User now is currently on page: {current_page}"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue