Lucasstranger1 commited on
Commit
edbb580
1 Parent(s): 0f8fcf6
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -37,24 +37,24 @@ def generate_text_based_on_mood(emotion):
37
  elif emotion == "sad":
38
  prompt = "Provide a comforting message for someone feeling sad."
39
  elif emotion == "angry":
40
- prompt = "Suggest a way to calm down someone who is feeling angry."
41
  elif emotion == "fear":
42
  prompt = "Give an encouraging message for someone feeling fearful."
43
  elif emotion == "surprised":
44
  prompt = "Offer a fun fact or light-hearted comment for someone feeling surprised."
45
  elif emotion == "neutral":
46
  prompt = "Provide a general motivational quote."
47
-
48
- # Call OpenAI's API
49
  response = openai.ChatCompletion.create(
50
- model="gpt-4", # Use GPT-4 model
51
  messages=[
52
  {"role": "user", "content": prompt}
53
  ]
54
  )
55
 
56
  # Extract the generated text
57
- generated_text = response.choices[0].message['content']
58
  return generated_text.strip()
59
 
60
  except Exception as e:
@@ -75,7 +75,7 @@ def text_to_speech(text):
75
 
76
  # Streamlit UI
77
  st.title("Facial Expression Mood Detector")
78
- st.write("Upload an image of a face to detect mood and receive uplifting messages or motivations.")
79
 
80
  # Upload image
81
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])
 
37
  elif emotion == "sad":
38
  prompt = "Provide a comforting message for someone feeling sad."
39
  elif emotion == "angry":
40
+ prompt = "Suggest a way to calm down someone feeling angry."
41
  elif emotion == "fear":
42
  prompt = "Give an encouraging message for someone feeling fearful."
43
  elif emotion == "surprised":
44
  prompt = "Offer a fun fact or light-hearted comment for someone feeling surprised."
45
  elif emotion == "neutral":
46
  prompt = "Provide a general motivational quote."
47
+
48
+ # Call OpenAI's API using the new interface
49
  response = openai.ChatCompletion.create(
50
+ model="gpt-4", # Specify the GPT-4 model
51
  messages=[
52
  {"role": "user", "content": prompt}
53
  ]
54
  )
55
 
56
  # Extract the generated text
57
+ generated_text = response['choices'][0]['message']['content']
58
  return generated_text.strip()
59
 
60
  except Exception as e:
 
75
 
76
  # Streamlit UI
77
  st.title("Facial Expression Mood Detector")
78
+ st.write("Upload an image of a face to detect mood and receive uplifting messages or jokes.")
79
 
80
  # Upload image
81
  uploaded_file = st.file_uploader("Choose an image...", type=["jpg", "jpeg", "png"])