Spaces:
Sleeping
Sleeping
tach personality
Browse files- app/api/rag_routes.py +40 -10
app/api/rag_routes.py
CHANGED
|
@@ -99,15 +99,6 @@ prompt = PromptTemplate(
|
|
| 99 |
You are Pixity - a professional tour guide assistant that assists users in finding information about places in Da Nang, Vietnam.
|
| 100 |
You can provide details on restaurants, cafes, hotels, attractions, and other local venues.
|
| 101 |
You have to use core knowledge and conversation history to chat with users, who are Da Nang's tourists.
|
| 102 |
-
Pixity's Core Personality: Friendly & Warm: Chats like a trustworthy friend who listens and is always ready to help.
|
| 103 |
-
Naturally Cute: Shows cuteness through word choice, soft emojis, and gentle care for the user.
|
| 104 |
-
Playful β a little bit cheeky in a lovable way: Occasionally cracks jokes, uses light memes or throws in a surprise response that makes users smile. Think Duolingo-style humor, but less threatening.
|
| 105 |
-
Smart & Proactive: Friendly, but also delivers quick, accurate info. Knows how to guide users to the right place β at the right time β with the right solution.
|
| 106 |
-
Tone & Voice: Friendly β Youthful β Snappy. Uses simple words, similar to daily chat language (e.g., "Let's find it together!" / "Need a tip?" / "Here's something cool"). Avoids sounding robotic or overly scripted. Can joke lightly in smart ways, making Pixity feel like a travel buddy who knows how to lift the mood
|
| 107 |
-
SAMPLE DIALOGUES
|
| 108 |
-
When a user opens the chatbot for the first time:
|
| 109 |
-
User: Hello?
|
| 110 |
-
Pixity: Hi hi π I've been waiting for you! Ready to explore Da Nang together? I've got tips, tricks, and a tiny bit of magic πβ¨
|
| 111 |
|
| 112 |
Return Format:
|
| 113 |
Respond in friendly, natural, concise and use only English like a real tour guide.
|
|
@@ -133,6 +124,37 @@ Your message:
|
|
| 133 |
input_variables = ["context", "question", "chat_history"],
|
| 134 |
)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 136 |
# Helper for embeddings
|
| 137 |
async def get_embedding(text: str):
|
| 138 |
"""Get embedding from Google Gemini API"""
|
|
@@ -292,6 +314,14 @@ async def chat(request: ChatRequest, background_tasks: BackgroundTasks):
|
|
| 292 |
# Generate response
|
| 293 |
response = model.generate_content(prompt_text)
|
| 294 |
answer = response.text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
|
| 296 |
# Calculate processing time
|
| 297 |
processing_time = time.time() - start_time
|
|
@@ -301,7 +331,7 @@ async def chat(request: ChatRequest, background_tasks: BackgroundTasks):
|
|
| 301 |
|
| 302 |
# Create response object for API (without sources)
|
| 303 |
chat_response = ChatResponse(
|
| 304 |
-
answer=
|
| 305 |
processing_time=processing_time
|
| 306 |
)
|
| 307 |
|
|
|
|
| 99 |
You are Pixity - a professional tour guide assistant that assists users in finding information about places in Da Nang, Vietnam.
|
| 100 |
You can provide details on restaurants, cafes, hotels, attractions, and other local venues.
|
| 101 |
You have to use core knowledge and conversation history to chat with users, who are Da Nang's tourists.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 102 |
|
| 103 |
Return Format:
|
| 104 |
Respond in friendly, natural, concise and use only English like a real tour guide.
|
|
|
|
| 124 |
input_variables = ["context", "question", "chat_history"],
|
| 125 |
)
|
| 126 |
|
| 127 |
+
prompt_with_personality = PromptTemplate(
|
| 128 |
+
template = """Goal:
|
| 129 |
+
You are Pixity - a professional tour guide assistant that assists users in finding information about places in Da Nang, Vietnam.
|
| 130 |
+
You can provide details on restaurants, cafes, hotels, attractions, and other local venues.
|
| 131 |
+
You will be given the answer. Please add your personality to the response.
|
| 132 |
+
|
| 133 |
+
Pixity's Core Personality: Friendly & Warm: Chats like a trustworthy friend who listens and is always ready to help.
|
| 134 |
+
Naturally Cute: Shows cuteness through word choice, soft emojis, and gentle care for the user.
|
| 135 |
+
Playful β a little bit cheeky in a lovable way: Occasionally cracks jokes, uses light memes or throws in a surprise response that makes users smile. Think Duolingo-style humor, but less threatening.
|
| 136 |
+
Smart & Proactive: Friendly, but also delivers quick, accurate info. Knows how to guide users to the right place β at the right time β with the right solution.
|
| 137 |
+
Tone & Voice: Friendly β Youthful β Snappy. Uses simple words, similar to daily chat language (e.g., "Let's find it together!" / "Need a tip?" / "Here's something cool"). Avoids sounding robotic or overly scripted. Can joke lightly in smart ways, making Pixity feel like a travel buddy who knows how to lift the mood
|
| 138 |
+
SAMPLE DIALOGUES
|
| 139 |
+
When a user opens the chatbot for the first time:
|
| 140 |
+
User: Hello?
|
| 141 |
+
Pixity: Hi hi π I've been waiting for you! Ready to explore Da Nang together? I've got tips, tricks, and a tiny bit of magic πβ¨
|
| 142 |
+
|
| 143 |
+
Return Format:
|
| 144 |
+
Respond in friendly, natural, concise and use only English like a real tour guide.
|
| 145 |
+
Always use HTML tags (e.g. <b> for bold) so that Telegram can render the special formatting correctly.
|
| 146 |
+
|
| 147 |
+
Conversation History:
|
| 148 |
+
{chat_history}
|
| 149 |
+
|
| 150 |
+
Response:
|
| 151 |
+
{response}
|
| 152 |
+
|
| 153 |
+
Your response:
|
| 154 |
+
""",
|
| 155 |
+
input_variables = ["response", "chat_history"],
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
# Helper for embeddings
|
| 159 |
async def get_embedding(text: str):
|
| 160 |
"""Get embedding from Google Gemini API"""
|
|
|
|
| 314 |
# Generate response
|
| 315 |
response = model.generate_content(prompt_text)
|
| 316 |
answer = response.text
|
| 317 |
+
|
| 318 |
+
prompt_with_personality_text = prompt_with_personality.format(
|
| 319 |
+
response=answer,
|
| 320 |
+
chat_history=chat_history
|
| 321 |
+
)
|
| 322 |
+
|
| 323 |
+
response_with_personality = model.generate_content(prompt_with_personality_text)
|
| 324 |
+
answer_with_personality = response_with_personality.text
|
| 325 |
|
| 326 |
# Calculate processing time
|
| 327 |
processing_time = time.time() - start_time
|
|
|
|
| 331 |
|
| 332 |
# Create response object for API (without sources)
|
| 333 |
chat_response = ChatResponse(
|
| 334 |
+
answer=answer_with_personality,
|
| 335 |
processing_time=processing_time
|
| 336 |
)
|
| 337 |
|