Akshayram1 commited on
Commit
d1eb12b
·
verified ·
1 Parent(s): 5a6431d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -2
app.py CHANGED
@@ -38,8 +38,26 @@ def get_song_recommendations(mood, api_key):
38
  try:
39
  genai.configure(api_key=api_key)
40
  model = genai.GenerativeModel('gemini-pro')
41
- prompt = f"Suggest 3 popular Indian {mood} songs."
42
- response = model.generate_content(prompt)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
  return response.text
44
  except Exception as e:
45
  st.error(f"Error using Gemini API: {e}")
 
38
  try:
39
  genai.configure(api_key=api_key)
40
  model = genai.GenerativeModel('gemini-pro')
41
+
42
+ # System prompt to guide the AI
43
+ system_prompt = """
44
+ You are a music recommendation assistant specialized in Indian songs. Your task is to suggest popular Indian songs based on the user's mood.
45
+ - If the mood is "happy," suggest upbeat and joyful Bollywood or Indian pop songs.
46
+ - If the mood is "sad," suggest emotional and soulful Indian songs.
47
+ - If the mood is "energetic," suggest high-energy dance or workout songs.
48
+ - If the mood is "romantic," suggest romantic Bollywood or Indian love songs.
49
+ - If the mood is "calm," suggest soothing Indian classical or instrumental music.
50
+ Always suggest 3 songs and provide the song title and artist name in the format:
51
+ 1. Song Title - Artist Name
52
+ 2. Song Title - Artist Name
53
+ 3. Song Title - Artist Name
54
+ """
55
+
56
+ # User prompt
57
+ user_prompt = f"Suggest 3 popular Indian {mood} songs."
58
+
59
+ # Combine system and user prompts
60
+ response = model.generate_content([system_prompt, user_prompt])
61
  return response.text
62
  except Exception as e:
63
  st.error(f"Error using Gemini API: {e}")