Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
|
| 3 |
from fastapi import FastAPI
|
| 4 |
from pydantic import BaseModel
|
|
|
|
| 5 |
from supabase import create_client
|
| 6 |
|
| 7 |
import torch
|
|
@@ -64,6 +65,15 @@ class MultiHeadDistilBERT(nn.Module):
|
|
| 64 |
class PredictRequest(BaseModel):
|
| 65 |
user_input: str
|
| 66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
class PredictResponse(BaseModel):
|
| 68 |
workout: str
|
| 69 |
workout_conf: float
|
|
@@ -71,27 +81,21 @@ class PredictResponse(BaseModel):
|
|
| 71 |
mood_conf: float
|
| 72 |
soreness: str
|
| 73 |
soreness_conf: float
|
|
|
|
|
|
|
| 74 |
|
| 75 |
def get_suitable_exercises(workout_type: int, mood: int, soreness: int):
|
| 76 |
supabase = create_client(os.getenv('SUPA_URL'), os.getenv('SUPA_KEY'))
|
| 77 |
|
| 78 |
-
mood = str(mood)
|
| 79 |
-
soreness = str(soreness)
|
| 80 |
-
|
| 81 |
-
print(f"Workout type {workout_type}")
|
| 82 |
-
print(f"mood type {mood}")
|
| 83 |
-
|
| 84 |
-
print(f"sorness type {soreness}")
|
| 85 |
-
|
| 86 |
response = (
|
| 87 |
supabase.table('exerciseai')
|
| 88 |
.select('*')
|
| 89 |
.eq('workout_type', workout_type)
|
| 90 |
-
.contains('suitable_moods', [mood])
|
| 91 |
-
.contains('suitable_soreness', [soreness])
|
| 92 |
.execute()
|
| 93 |
)
|
| 94 |
-
|
| 95 |
return response.data
|
| 96 |
|
| 97 |
@app.get("/")
|
|
|
|
| 2 |
|
| 3 |
from fastapi import FastAPI
|
| 4 |
from pydantic import BaseModel
|
| 5 |
+
from typing import List
|
| 6 |
from supabase import create_client
|
| 7 |
|
| 8 |
import torch
|
|
|
|
| 65 |
class PredictRequest(BaseModel):
|
| 66 |
user_input: str
|
| 67 |
|
| 68 |
+
class ExerciseResponse(BaseModel):
|
| 69 |
+
id: int
|
| 70 |
+
name: str
|
| 71 |
+
workout_type: int
|
| 72 |
+
difficulty: str
|
| 73 |
+
notes: str
|
| 74 |
+
suitable_moods: List[int]
|
| 75 |
+
suitable_soreness: List[int]
|
| 76 |
+
|
| 77 |
class PredictResponse(BaseModel):
|
| 78 |
workout: str
|
| 79 |
workout_conf: float
|
|
|
|
| 81 |
mood_conf: float
|
| 82 |
soreness: str
|
| 83 |
soreness_conf: float
|
| 84 |
+
exercises: List[ExerciseResponse]
|
| 85 |
+
|
| 86 |
|
| 87 |
def get_suitable_exercises(workout_type: int, mood: int, soreness: int):
|
| 88 |
supabase = create_client(os.getenv('SUPA_URL'), os.getenv('SUPA_KEY'))
|
| 89 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
response = (
|
| 91 |
supabase.table('exerciseai')
|
| 92 |
.select('*')
|
| 93 |
.eq('workout_type', workout_type)
|
| 94 |
+
.contains('suitable_moods', [str(mood)])
|
| 95 |
+
.contains('suitable_soreness', [str(soreness)])
|
| 96 |
.execute()
|
| 97 |
)
|
| 98 |
+
|
| 99 |
return response.data
|
| 100 |
|
| 101 |
@app.get("/")
|