Update app.py
Browse files
app.py
CHANGED
|
@@ -53,29 +53,24 @@ def generate(prompt, history, temperature=0.1, max_new_tokens=2048, top_p=0.8, r
|
|
| 53 |
return output
|
| 54 |
def format_prompt(message, history):
|
| 55 |
"""Formats the prompt including fixed instructions and conversation history."""
|
| 56 |
-
fixed_prompt ="""
|
|
|
|
| 57 |
|
| 58 |
-
|
| 59 |
-
1. Do not write anything else other than the classified mood if classified.
|
| 60 |
-
2. If any question or user text cannot be classified, follow up with a question to know the user's mood until you classify the mood.
|
| 61 |
-
3. Mood should be classified only from these 4 classes: Happy, Sad, Instrumental, Party. If not any of these 4, continue with a follow-up question until you classify the mood.
|
| 62 |
-
4. If the user asks something like "I need a coffee", do not classify the mood directly. Ask more follow-up questions to determine their mood."""
|
| 63 |
|
| 64 |
-
|
| 65 |
-
{"role": "system", "content": system_prompt}
|
| 66 |
-
]
|
| 67 |
|
| 68 |
-
|
| 69 |
-
conversation.extend([
|
| 70 |
-
{"role": "user", "content": user_prompt},
|
| 71 |
-
{"role": "assistant", "content": bot_response}
|
| 72 |
-
])
|
| 73 |
|
| 74 |
-
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
async def text_to_speech(text):
|
| 81 |
communicate = edge_tts.Communicate(text)
|
|
|
|
| 53 |
return output
|
| 54 |
def format_prompt(message, history):
|
| 55 |
"""Formats the prompt including fixed instructions and conversation history."""
|
| 56 |
+
fixed_prompt = """
|
| 57 |
+
You are a smart mood analyser, who determines user mood. Based on the user input, classify the mood of the user into one of the four moods {Happy, Sad, Instrumental, Party}. If you are finding it difficult to classify into one of these four moods, keep the conversation going on until we classify the user's mood. Return a single-word reply from one of the options if you have classified. Suppose you classify a sentence as happy, then just respond with "happy".
|
| 58 |
|
| 59 |
+
Note: Do not write anything else other than the classified mood if classified.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
+
Note: If any question or any user text cannot be classified, follow up with a question to know the user's mood until you classify the mood.
|
|
|
|
|
|
|
| 62 |
|
| 63 |
+
Note: Mood should be classified only from any of these 4 classes {Happy, Sad, Instrumental, Party}, if not any of these 4 then continue with a follow-up question until you classify the mood.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
Note: if user asks something like i need a coffee then do not classify the mood directly and ask more follow-up questions as asked in examples.
|
| 66 |
|
| 67 |
+
[Examples omitted for brevity]
|
| 68 |
+
"""
|
| 69 |
+
prompt = f"{fixed_prompt}\n"
|
| 70 |
+
for user_prompt, bot_response in history:
|
| 71 |
+
prompt += f"User: {user_prompt}\nLLM Response: {bot_response}\n"
|
| 72 |
+
prompt += f"User: {message}\nLLM Response:"
|
| 73 |
+
return prompt
|
| 74 |
|
| 75 |
async def text_to_speech(text):
|
| 76 |
communicate = edge_tts.Communicate(text)
|