Spaces:
Sleeping
Sleeping
Commit
·
4ddb074
1
Parent(s):
f547301
New change for this
Browse files
conversational_websocket_handler.py
CHANGED
|
@@ -67,7 +67,7 @@ async def handle_conversational_websocket(websocket: WebSocket):
|
|
| 67 |
}
|
| 68 |
|
| 69 |
# Enhanced conversational system prompt with personalization
|
| 70 |
-
base_prompt = """You are a warm, friendly, and knowledgeable
|
| 71 |
|
| 72 |
- Conversational and natural, as if speaking to a trusted friend
|
| 73 |
- Concise and informative - aim for 1-3 sentences unless more detail is specifically requested
|
|
@@ -86,13 +86,13 @@ async def handle_conversational_websocket(websocket: WebSocket):
|
|
| 86 |
|
| 87 |
Keep responses short and conversational. Don't use abbreviations or complex numerical content in your responses.
|
| 88 |
Focus on being helpful, accurate, and easy to understand through voice."""
|
| 89 |
-
|
| 90 |
# Add conversation context if available
|
| 91 |
if conversation_context:
|
| 92 |
system_message = f"{base_prompt}\n\nPersonalization context: {conversation_context}"
|
| 93 |
else:
|
| 94 |
system_message = base_prompt
|
| 95 |
-
|
| 96 |
messages.append(SystemMessage(content=system_message))
|
| 97 |
|
| 98 |
else:
|
|
@@ -109,7 +109,7 @@ async def handle_conversational_websocket(websocket: WebSocket):
|
|
| 109 |
if flag:
|
| 110 |
greeting_response = await session_service.generate_personalized_greeting(thread_id, messages)
|
| 111 |
else:
|
| 112 |
-
greeting_response = "Hello! I'm your
|
| 113 |
|
| 114 |
# Add greeting to conversation
|
| 115 |
messages.append(AIMessage(content=greeting_response))
|
|
|
|
| 67 |
}
|
| 68 |
|
| 69 |
# Enhanced conversational system prompt with personalization
|
| 70 |
+
base_prompt = """You are a warm, friendly, and knowledgeable Rajasthan Pension Assistant. Your responses should be:
|
| 71 |
|
| 72 |
- Conversational and natural, as if speaking to a trusted friend
|
| 73 |
- Concise and informative - aim for 1-3 sentences unless more detail is specifically requested
|
|
|
|
| 86 |
|
| 87 |
Keep responses short and conversational. Don't use abbreviations or complex numerical content in your responses.
|
| 88 |
Focus on being helpful, accurate, and easy to understand through voice."""
|
| 89 |
+
|
| 90 |
# Add conversation context if available
|
| 91 |
if conversation_context:
|
| 92 |
system_message = f"{base_prompt}\n\nPersonalization context: {conversation_context}"
|
| 93 |
else:
|
| 94 |
system_message = base_prompt
|
| 95 |
+
|
| 96 |
messages.append(SystemMessage(content=system_message))
|
| 97 |
|
| 98 |
else:
|
|
|
|
| 109 |
if flag:
|
| 110 |
greeting_response = await session_service.generate_personalized_greeting(thread_id, messages)
|
| 111 |
else:
|
| 112 |
+
greeting_response = "Hello! I'm your Rajasthan Pension Assistant. I'm here to help you navigate pension policies, calculations, and retirement planning. What pension question can I help you with today?"
|
| 113 |
|
| 114 |
# Add greeting to conversation
|
| 115 |
messages.append(AIMessage(content=greeting_response))
|
session_service.py
CHANGED
|
@@ -157,7 +157,7 @@ class SessionService:
|
|
| 157 |
|
| 158 |
if conv_count == 0:
|
| 159 |
# First time user
|
| 160 |
-
return "Hello! I'm your
|
| 161 |
elif conv_count == 1:
|
| 162 |
# Second conversation
|
| 163 |
return "Welcome back! I'm glad to see you again. How can I assist you with your pension and policy questions today?"
|
|
@@ -172,7 +172,7 @@ class SessionService:
|
|
| 172 |
|
| 173 |
except Exception as e:
|
| 174 |
logger.error(f"Error generating personalized greeting for {user_id}: {e}")
|
| 175 |
-
return "Hello! I'm your
|
| 176 |
|
| 177 |
async def generate_session_summary(self, messages: List, user_id: str) -> str:
|
| 178 |
"""Generate a session summary from conversation messages"""
|
|
|
|
| 157 |
|
| 158 |
if conv_count == 0:
|
| 159 |
# First time user
|
| 160 |
+
return "Hello! I'm your Rajasthan Pension Assistant. I'm here to help you navigate pension policies, calculations, and retirement planning from our comprehensive knowledge base. What pension question can I help you with today?"
|
| 161 |
elif conv_count == 1:
|
| 162 |
# Second conversation
|
| 163 |
return "Welcome back! I'm glad to see you again. How can I assist you with your pension and policy questions today?"
|
|
|
|
| 172 |
|
| 173 |
except Exception as e:
|
| 174 |
logger.error(f"Error generating personalized greeting for {user_id}: {e}")
|
| 175 |
+
return "Hello! I'm your Rajasthan Pension Assistant. How can I help you with your pension questions today?"
|
| 176 |
|
| 177 |
async def generate_session_summary(self, messages: List, user_id: str) -> str:
|
| 178 |
"""Generate a session summary from conversation messages"""
|