hpyapali commited on
Commit
9477700
Β·
verified Β·
1 Parent(s): d8b2f66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -46,8 +46,8 @@ def get_pipeline():
46
 
47
 
48
  # βœ… AI Function - Processes and ranks workouts
 
49
  def analyze_workouts(last_workouts: str):
50
- """Generates AI-based workout rankings based on heart rate recovery."""
51
  pipe = get_pipeline()
52
  if pipe is None:
53
  return "❌ AI model is not loaded."
@@ -60,11 +60,20 @@ def analyze_workouts(last_workouts: str):
60
  f"\n\n{last_workouts}\n\nOnly return rankings. No extra text."
61
  )
62
 
 
 
63
  try:
64
  result = pipe(instruction, max_new_tokens=200, temperature=0.3, top_p=0.9)
 
 
 
 
65
  response_text = result[0]["generated_text"].strip()
 
 
66
  return response_text
67
  except Exception as e:
 
68
  return f"❌ Error: {str(e)}"
69
 
70
 
 
46
 
47
 
48
  # βœ… AI Function - Processes and ranks workouts
49
+
50
  def analyze_workouts(last_workouts: str):
 
51
  pipe = get_pipeline()
52
  if pipe is None:
53
  return "❌ AI model is not loaded."
 
60
  f"\n\n{last_workouts}\n\nOnly return rankings. No extra text."
61
  )
62
 
63
+ print(f"πŸ“¨ Sending prompt to AI: {instruction}") # βœ… Debug log
64
+
65
  try:
66
  result = pipe(instruction, max_new_tokens=200, temperature=0.3, top_p=0.9)
67
+ if not result or "generated_text" not in result[0]:
68
+ print("❌ AI response is empty or malformed!")
69
+ return "❌ AI did not return a valid response."
70
+
71
  response_text = result[0]["generated_text"].strip()
72
+ print(f"πŸ” AI Response: {response_text}") # βœ… Debug log
73
+
74
  return response_text
75
  except Exception as e:
76
+ print(f"❌ AI Error: {str(e)}") # βœ… Debug AI errors
77
  return f"❌ Error: {str(e)}"
78
 
79