syedmudassir16 commited on
Commit
01982db
1 Parent(s): ae7f809

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -12
app.py CHANGED
@@ -56,20 +56,29 @@ 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 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".
60
-
61
- Note: Do not write anything else other than the classified mood if classified.
62
-
63
- 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.
64
-
65
- 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.
66
-
67
- 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.
 
 
 
 
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):
 
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
  async def text_to_speech(text):