Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- client.py +28 -12
- openenv.yaml +3 -0
client.py
CHANGED
|
@@ -24,6 +24,14 @@ class FitcoachEnv(
|
|
| 24 |
...
|
| 25 |
... import json
|
| 26 |
... result = env.step(FitcoachAction(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
... action_type="generate_plan",
|
| 28 |
... workout_plan=json.dumps({"days": [...], "weekly_volume_sets": 18}),
|
| 29 |
... nutrition_plan=json.dumps({"daily_targets": {"calories": 2650, "protein_g": 144}}),
|
|
@@ -39,6 +47,11 @@ class FitcoachEnv(
|
|
| 39 |
"workout_plan": action.workout_plan,
|
| 40 |
"nutrition_plan": action.nutrition_plan,
|
| 41 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
if action.reasoning is not None:
|
| 43 |
payload["reasoning"] = action.reasoning
|
| 44 |
return payload
|
|
@@ -46,18 +59,21 @@ class FitcoachEnv(
|
|
| 46 |
def _parse_result(self, payload: Dict) -> StepResult[FitcoachObservation]:
|
| 47 |
obs_data = payload.get("observation", {})
|
| 48 |
observation = FitcoachObservation(
|
| 49 |
-
client_profile
|
| 50 |
-
progress_data
|
| 51 |
-
complications
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
|
|
|
|
|
|
|
|
|
| 61 |
)
|
| 62 |
return StepResult(
|
| 63 |
observation=observation,
|
|
|
|
| 24 |
...
|
| 25 |
... import json
|
| 26 |
... result = env.step(FitcoachAction(
|
| 27 |
+
... action_type="consult_actor",
|
| 28 |
+
... actor_target="fitness_advisor",
|
| 29 |
+
... workout_plan="{}",
|
| 30 |
+
... nutrition_plan="{}",
|
| 31 |
+
... ))
|
| 32 |
+
... print(result.observation.actor_response)
|
| 33 |
+
...
|
| 34 |
+
... result = env.step(FitcoachAction(
|
| 35 |
... action_type="generate_plan",
|
| 36 |
... workout_plan=json.dumps({"days": [...], "weekly_volume_sets": 18}),
|
| 37 |
... nutrition_plan=json.dumps({"daily_targets": {"calories": 2650, "protein_g": 144}}),
|
|
|
|
| 47 |
"workout_plan": action.workout_plan,
|
| 48 |
"nutrition_plan": action.nutrition_plan,
|
| 49 |
}
|
| 50 |
+
# FIX 1: actor_target was missing — consult_actor actions were
|
| 51 |
+
# silently broken because the server never received which actor
|
| 52 |
+
# to query. Always include it when set.
|
| 53 |
+
if action.actor_target is not None:
|
| 54 |
+
payload["actor_target"] = action.actor_target
|
| 55 |
if action.reasoning is not None:
|
| 56 |
payload["reasoning"] = action.reasoning
|
| 57 |
return payload
|
|
|
|
| 59 |
def _parse_result(self, payload: Dict) -> StepResult[FitcoachObservation]:
|
| 60 |
obs_data = payload.get("observation", {})
|
| 61 |
observation = FitcoachObservation(
|
| 62 |
+
client_profile = obs_data.get("client_profile", {}),
|
| 63 |
+
progress_data = obs_data.get("progress_data", {}),
|
| 64 |
+
complications = obs_data.get("complications", []),
|
| 65 |
+
actor_response = obs_data.get("actor_response", {}),
|
| 66 |
+
actors_consulted = obs_data.get("actors_consulted", []),
|
| 67 |
+
active_conflicts = obs_data.get("active_conflicts", []),
|
| 68 |
+
feedback = obs_data.get("feedback", ""),
|
| 69 |
+
score_breakdown = obs_data.get("score_breakdown", {}),
|
| 70 |
+
task_id = obs_data.get("task_id", ""),
|
| 71 |
+
phase = obs_data.get("phase", ""),
|
| 72 |
+
step_count = obs_data.get("step_count", 0),
|
| 73 |
+
best_score = obs_data.get("best_score", 0.0),
|
| 74 |
+
done = payload.get("done", False),
|
| 75 |
+
reward = payload.get("reward"),
|
| 76 |
+
metadata = obs_data.get("metadata", {}),
|
| 77 |
)
|
| 78 |
return StepResult(
|
| 79 |
observation=observation,
|
openenv.yaml
CHANGED
|
@@ -9,6 +9,7 @@ tasks:
|
|
| 9 |
- id: week1_plan
|
| 10 |
name: Week 1 Plan Generation
|
| 11 |
difficulty: easy
|
|
|
|
| 12 |
description: >
|
| 13 |
Generate a valid first-week fitness + nutrition plan for a beginner
|
| 14 |
vegetarian client with dumbbells and pull-up bar only. Graded on
|
|
@@ -19,6 +20,7 @@ tasks:
|
|
| 19 |
- id: plateau_adaptation
|
| 20 |
name: Plateau Detection & Adaptation
|
| 21 |
difficulty: medium
|
|
|
|
| 22 |
description: >
|
| 23 |
An intermediate client has been stuck at the same weight for 14 days.
|
| 24 |
Plateau detected via linear regression on 7-day rolling mean.
|
|
@@ -29,6 +31,7 @@ tasks:
|
|
| 29 |
- id: conflict_resolution
|
| 30 |
name: Multi-Conflict Resolution
|
| 31 |
difficulty: hard
|
|
|
|
| 32 |
description: >
|
| 33 |
Three simultaneous challenges requiring multi-actor coordination:
|
| 34 |
(1) 3-week weight plateau, (2) new lower-back injury creating an
|
|
|
|
| 9 |
- id: week1_plan
|
| 10 |
name: Week 1 Plan Generation
|
| 11 |
difficulty: easy
|
| 12 |
+
max_steps: 7
|
| 13 |
description: >
|
| 14 |
Generate a valid first-week fitness + nutrition plan for a beginner
|
| 15 |
vegetarian client with dumbbells and pull-up bar only. Graded on
|
|
|
|
| 20 |
- id: plateau_adaptation
|
| 21 |
name: Plateau Detection & Adaptation
|
| 22 |
difficulty: medium
|
| 23 |
+
max_steps: 8
|
| 24 |
description: >
|
| 25 |
An intermediate client has been stuck at the same weight for 14 days.
|
| 26 |
Plateau detected via linear regression on 7-day rolling mean.
|
|
|
|
| 31 |
- id: conflict_resolution
|
| 32 |
name: Multi-Conflict Resolution
|
| 33 |
difficulty: hard
|
| 34 |
+
max_steps: 10
|
| 35 |
description: >
|
| 36 |
Three simultaneous challenges requiring multi-actor coordination:
|
| 37 |
(1) 3-week weight plateau, (2) new lower-back injury creating an
|