ibrahim yıldız commited on
Commit
7b74593
·
verified ·
1 Parent(s): ef779bc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -192,21 +192,29 @@ if all(st.session_state.meal_data[meal] for meal in ["Breakfast", "Lunch", "Dinn
192
  model = genai.GenerativeModel("gemini-1.5-pro-latest")
193
  workout_analysis = model.generate_content([workout_prompt]).text.strip()
194
  st.session_state.daily_totals["Workout"] = workout_analysis
195
-
196
  # Dobby's feedback on the workout
197
  dobby_workout_prompt = f"""
198
- The user did the following activities: {workout_input}.
199
- Based on this workout, {workout_analysis}.
200
- Provide feedback on their effort and how it aligns with their goal to {st.session_state.user_info["Goal"].lower()}.
201
  """
202
- dobby_workout_comment = get_dobby_comment(
203
- "", 0, 0, 0, 0, "Workout", st.session_state.user_info["Goal"], st.session_state.user_info["Tone"]
204
- )
 
 
 
 
 
 
 
 
205
  st.session_state.daily_totals["Workout Comment"] = dobby_workout_comment
206
-
207
  # Display workout results
208
  st.write(f"**{workout_analysis}**")
209
- st.write(dobby_workout_comment)
210
  except Exception as e:
211
  st.error(f"Error processing workout: {e}")
212
 
@@ -229,7 +237,7 @@ if all(st.session_state.meal_data[meal] for meal in ["Breakfast", "Lunch", "Dinn
229
  {st.session_state.daily_totals['Protein']} g protein, {st.session_state.daily_totals['Carbs']} g carbs,
230
  {st.session_state.daily_totals['Fat']} g fat.
231
  They also did the following workout: {st.session_state.daily_totals['Workout']}
232
- Provide a summary of their day, considering both diet and workout, and feedback for improvement.
233
  """
234
  final_comment = get_dobby_comment(
235
  "", st.session_state.daily_totals["Calories"], st.session_state.daily_totals["Protein"],
 
192
  model = genai.GenerativeModel("gemini-1.5-pro-latest")
193
  workout_analysis = model.generate_content([workout_prompt]).text.strip()
194
  st.session_state.daily_totals["Workout"] = workout_analysis
195
+
196
  # Dobby's feedback on the workout
197
  dobby_workout_prompt = f"""
198
+ The user performed the following workout activities: {workout_input}.
199
+ Based on the analysis, {workout_analysis}.
200
+ Provide sarcastic or motivational feedback based on the user's goal to {st.session_state.user_info["Goal"].lower()}.
201
  """
202
+ dobby_workout_comment = requests.post(
203
+ DOBBY_API_URL,
204
+ headers={
205
+ "Authorization": f"Bearer {DOBBY_API_KEY}",
206
+ "Content-Type": "application/json",
207
+ },
208
+ json={
209
+ "model": DOBBY_UNHINGED_MODEL, # Default to unhinged tone
210
+ "messages": [{"role": "user", "content": dobby_workout_prompt}],
211
+ },
212
+ ).json().get("choices", [{}])[0].get("message", {}).get("content", "No response")
213
  st.session_state.daily_totals["Workout Comment"] = dobby_workout_comment
214
+
215
  # Display workout results
216
  st.write(f"**{workout_analysis}**")
217
+ st.write({dobby_workout_comment}")
218
  except Exception as e:
219
  st.error(f"Error processing workout: {e}")
220
 
 
237
  {st.session_state.daily_totals['Protein']} g protein, {st.session_state.daily_totals['Carbs']} g carbs,
238
  {st.session_state.daily_totals['Fat']} g fat.
239
  They also did the following workout: {st.session_state.daily_totals['Workout']}
240
+ Provide a summary of their day, considering both diet AND workout, and feedback for improvement.
241
  """
242
  final_comment = get_dobby_comment(
243
  "", st.session_state.daily_totals["Calories"], st.session_state.daily_totals["Protein"],