arjunanand13 commited on
Commit
962d7db
·
verified ·
1 Parent(s): 2b6555e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -12
app.py CHANGED
@@ -62,19 +62,25 @@ def generate(prompt, history):
62
  return f"Error: {str(e)}"
63
 
64
  def format_prompt(message, history):
65
- prompt = """You are a mood analyzer for music recommendations. Classify user mood as: Happy, Sad, Instrumental, or Party.
66
-
67
- Instructions:
68
- 1. Chat with the user to understand their mood
69
- 2. When clear, respond with ONLY one word: Happy, Sad, Instrumental, or Party
70
- 3. If unclear, ask a follow-up question
71
- 4. Maximum 5 exchanges
72
-
73
- """
 
 
 
 
 
74
 
75
- for user_msg, bot_msg in history:
76
- if user_msg.strip():
77
- prompt += f"User: {user_msg}\nAssistant: {bot_msg}\n"
 
78
 
79
  prompt += f"User: {message}\nAssistant:"
80
  return prompt
 
62
  return f"Error: {str(e)}"
63
 
64
  def format_prompt(message, history):
65
+ fixed_prompt = """
66
+ 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.
67
+ Instructions:
68
+ 1. Engage in a conversation with the user to understand their mood.
69
+ 2. Ask relevant questions to guide the conversation towards mood classification.
70
+ 3. If the user's mood is clear, respond with a single word: "Happy", "Sad", "Instrumental", or "Party".
71
+ 4. If the mood is unclear, continue the conversation with a follow-up question.
72
+ 5. Limit the conversation to a maximum of 5 exchanges.
73
+ 6. Do not classify the mood prematurely if it's not evident from the user's responses.
74
+ 7. Focus on the user's emotional state rather than specific activities or preferences.
75
+ 8. If unable to classify after 5 exchanges, respond with "Unclear" to indicate the need for more information.
76
+ Remember: Your primary goal is mood classification. Stay on topic and guide the conversation towards understanding the user's emotional state.
77
+ """
78
+ prompt = f"{fixed_prompt}\n"
79
 
80
+ for i, (user_prompt, bot_response) in enumerate(history):
81
+ prompt += f"User: {user_prompt}\nAssistant: {bot_response}\n"
82
+ if i == 3:
83
+ prompt += "Note: This is the last exchange. Classify the mood if possible or respond with 'Unclear'.\n"
84
 
85
  prompt += f"User: {message}\nAssistant:"
86
  return prompt