Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
|