init
This commit is contained in:
commit
66729f7d08
24 files changed
+907
No files matched your search
@@ -0,0 +1,72 @@
|
||||
# exercise_tracker/tasks.py
|
||||
from core.base import TaskModule
|
||||
from .models import Session, Exercise, Set
|
||||
|
||||
|
||||
class ExerciseTracker(TaskModule):
|
||||
MODULE_NAME = "exercise_tracker"
|
||||
DESCRIPTION = "Log workouts, exercises, and training sets (strength & cardio)"
|
||||
|
||||
TOOLS = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "log_workout",
|
||||
"description": "Record a complete workout session with exercises and sets",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"session_name": {"type": "string"},
|
||||
"date": {"type": "string", "format": "date"},
|
||||
"exercises": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"exercise_name": {"type": "string"},
|
||||
"sets": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
# Strength options
|
||||
"reps": {"type": "integer"},
|
||||
"weight_kg": {"type": "number"},
|
||||
|
||||
# Cardio options
|
||||
"duration_seconds": {"type": "integer"},
|
||||
"distance_meters": {"type": "number"}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["exercise_name"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["session_name", "date", "exercises"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def execute_tool(cls, tool_name: str, arguments: dict) -> dict:
|
||||
if tool_name == "log_workout":
|
||||
session = Session.objects.create(name=arguments["session_name"], date=arguments["date"])
|
||||
|
||||
for ex_data in arguments.get("exercises", []):
|
||||
exercise = Exercise.objects.create(session=session, name=ex_data["exercise_name"])
|
||||
|
||||
for set_data in ex_data.get("sets", []):
|
||||
Set.objects.create(
|
||||
exercise=exercise,
|
||||
reps=set_data.get("reps"),
|
||||
weight_kg=set_data.get("weight_kg"),
|
||||
duration_seconds=set_data.get("duration_seconds"),
|
||||
distance_meters=set_data.get("distance_meters")
|
||||
)
|
||||
|
||||
return {"status": "success", "message": f"Logged workout: {session.name}"}
|
||||
|
||||
raise ValueError(f"Unknown tool: {tool_name}")
|
||||
Reference in new issue
Block a user