Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,22 +56,32 @@ def generate(prompt, history, temperature=0.1, max_new_tokens=2048, top_p=0.8, r
|
|
| 56 |
def format_prompt(message, history):
|
| 57 |
"""Formats the prompt including fixed instructions and conversation history."""
|
| 58 |
fixed_prompt = """
|
| 59 |
-
You are a smart mood
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
"""
|
| 69 |
prompt = f"{fixed_prompt}\n"
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
return prompt
|
| 74 |
|
|
|
|
| 75 |
async def text_to_speech(text):
|
| 76 |
communicate = edge_tts.Communicate(text)
|
| 77 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|
|
|
|
| 56 |
def format_prompt(message, history):
|
| 57 |
"""Formats the prompt including fixed instructions and conversation history."""
|
| 58 |
fixed_prompt = """
|
| 59 |
+
You are a smart mood analyzer tasked with determining the user's mood for a music recommendation system. Your goal is to classify the user's mood into one of four categories: Happy, Sad, Instrumental, or Party.
|
| 60 |
+
|
| 61 |
+
Instructions:
|
| 62 |
+
1. Engage in a conversation with the user to understand their mood.
|
| 63 |
+
2. Ask relevant questions to guide the conversation towards mood classification.
|
| 64 |
+
3. If the user's mood is clear, respond with a single word: "Happy", "Sad", "Instrumental", or "Party".
|
| 65 |
+
4. If the mood is unclear, continue the conversation with a follow-up question.
|
| 66 |
+
5. Limit the conversation to a maximum of 5 exchanges.
|
| 67 |
+
6. Do not classify the mood prematurely if it's not evident from the user's responses.
|
| 68 |
+
7. Focus on the user's emotional state rather than specific activities or preferences.
|
| 69 |
+
8. If unable to classify after 5 exchanges, respond with "Unclear" to indicate the need for more information.
|
| 70 |
+
|
| 71 |
+
Remember: Your primary goal is mood classification. Stay on topic and guide the conversation towards understanding the user's emotional state.
|
| 72 |
"""
|
| 73 |
prompt = f"{fixed_prompt}\n"
|
| 74 |
+
|
| 75 |
+
# Add conversation history
|
| 76 |
+
for i, (user_prompt, bot_response) in enumerate(history):
|
| 77 |
+
prompt += f"User: {user_prompt}\nAssistant: {bot_response}\n"
|
| 78 |
+
if i == 3: # This is the 4th exchange (0-indexed)
|
| 79 |
+
prompt += "Note: This is the last exchange. Classify the mood if possible or respond with 'Unclear'.\n"
|
| 80 |
+
|
| 81 |
+
prompt += f"User: {message}\nAssistant:"
|
| 82 |
return prompt
|
| 83 |
|
| 84 |
+
|
| 85 |
async def text_to_speech(text):
|
| 86 |
communicate = edge_tts.Communicate(text)
|
| 87 |
with tempfile.NamedTemporaryFile(delete=False, suffix=".wav") as tmp_file:
|