Spaces:
Sleeping
Sleeping
Mahir commited on
Commit ·
687d4d6
1
Parent(s): 7ff4f6b
Fix inference.py: sync heuristic fallback, clamp all scores--2
Browse files- inference.py +8 -5
- openenv.yaml +14 -1
inference.py
CHANGED
|
@@ -270,7 +270,7 @@ async def run_task(client: OpenAI, task_id: str) -> dict:
|
|
| 270 |
print(f" [step {step:02d}] Error: {e}", file=sys.stderr); break
|
| 271 |
obs = result["observation"]
|
| 272 |
rewards.append(result["reward"]["total"])
|
| 273 |
-
print(f"[STEP] step={step} reward={result['reward']['total']:.
|
| 274 |
r = await http.post("/grader", params={"task_id": task_id})
|
| 275 |
r.raise_for_status()
|
| 276 |
score = r.json(); score["reward_history"] = rewards
|
|
@@ -330,19 +330,22 @@ async def main():
|
|
| 330 |
for i, task_id in enumerate(tasks_to_run):
|
| 331 |
if i > 0 and args.pause > 0:
|
| 332 |
time.sleep(args.pause)
|
| 333 |
-
print(f"[START] task={task_id}", flush=True)
|
| 334 |
try:
|
| 335 |
result = await run_task(client, task_id)
|
| 336 |
results[task_id] = result
|
| 337 |
status = "✓ PASS" if result["passed"] else "✗ FAIL"
|
| 338 |
-
|
|
|
|
|
|
|
|
|
|
| 339 |
metrics = {k:v for k,v in result.get("metrics",{}).items() if not isinstance(v,list) and k!="per_ticket_scores"}
|
| 340 |
if metrics: print(f" Metrics: {json.dumps(metrics, indent=2)}")
|
| 341 |
except Exception as e:
|
| 342 |
import traceback
|
| 343 |
print(f" ✗ CRASHED: {e}", file=sys.stderr); traceback.print_exc(file=sys.stderr)
|
| 344 |
results[task_id] = {"final_score":0.0001,"passed":False,"reward_history":[],"metrics":{},"error":str(e)}
|
| 345 |
-
print(f"[END]
|
| 346 |
# Clamp all individual task scores
|
| 347 |
for tid in results:
|
| 348 |
s = float(results[tid].get("final_score", 0.0001))
|
|
@@ -361,4 +364,4 @@ async def main():
|
|
| 361 |
print("\n Results saved to baseline_results.json")
|
| 362 |
|
| 363 |
if __name__ == "__main__":
|
| 364 |
-
asyncio.run(main())
|
|
|
|
| 270 |
print(f" [step {step:02d}] Error: {e}", file=sys.stderr); break
|
| 271 |
obs = result["observation"]
|
| 272 |
rewards.append(result["reward"]["total"])
|
| 273 |
+
print(f"[STEP] step={step} action={action_dict.get('action_type','no_op')} reward={result['reward']['total']:.2f} done={str(obs.get('episode_done', False)).lower()} error=null", flush=True)
|
| 274 |
r = await http.post("/grader", params={"task_id": task_id})
|
| 275 |
r.raise_for_status()
|
| 276 |
score = r.json(); score["reward_history"] = rewards
|
|
|
|
| 330 |
for i, task_id in enumerate(tasks_to_run):
|
| 331 |
if i > 0 and args.pause > 0:
|
| 332 |
time.sleep(args.pause)
|
| 333 |
+
print(f"[START] task={task_id} env=multi-domain-ai-agent model={MODEL_NAME}", flush=True)
|
| 334 |
try:
|
| 335 |
result = await run_task(client, task_id)
|
| 336 |
results[task_id] = result
|
| 337 |
status = "✓ PASS" if result["passed"] else "✗ FAIL"
|
| 338 |
+
rewards_str = ",".join(f"{r:.2f}" for r in result.get("reward_history", []))
|
| 339 |
+
success_val = str(result.get("passed", False)).lower()
|
| 340 |
+
steps_val = len(result.get("reward_history", []))
|
| 341 |
+
print(f"[END] success={success_val} steps={steps_val} score={result['final_score']:.3f} rewards={rewards_str or '0.00'}", flush=True)
|
| 342 |
metrics = {k:v for k,v in result.get("metrics",{}).items() if not isinstance(v,list) and k!="per_ticket_scores"}
|
| 343 |
if metrics: print(f" Metrics: {json.dumps(metrics, indent=2)}")
|
| 344 |
except Exception as e:
|
| 345 |
import traceback
|
| 346 |
print(f" ✗ CRASHED: {e}", file=sys.stderr); traceback.print_exc(file=sys.stderr)
|
| 347 |
results[task_id] = {"final_score":0.0001,"passed":False,"reward_history":[],"metrics":{},"error":str(e)}
|
| 348 |
+
print(f"[END] success=false steps=0 score=0.001 rewards=0.00", flush=True)
|
| 349 |
# Clamp all individual task scores
|
| 350 |
for tid in results:
|
| 351 |
s = float(results[tid].get("final_score", 0.0001))
|
|
|
|
| 364 |
print("\n Results saved to baseline_results.json")
|
| 365 |
|
| 366 |
if __name__ == "__main__":
|
| 367 |
+
asyncio.run(main())
|
openenv.yaml
CHANGED
|
@@ -19,54 +19,67 @@ tasks:
|
|
| 19 |
- id: ticket_classification
|
| 20 |
name: Ticket Classification & Routing
|
| 21 |
difficulty: easy
|
|
|
|
| 22 |
domain: customer_support
|
| 23 |
- id: response_drafting
|
| 24 |
name: Response Drafting & Quality
|
| 25 |
difficulty: medium
|
|
|
|
| 26 |
domain: customer_support
|
| 27 |
- id: queue_management
|
| 28 |
name: SLA Queue Management
|
| 29 |
difficulty: hard
|
|
|
|
| 30 |
domain: customer_support
|
| 31 |
- id: multi_turn_conversation
|
| 32 |
name: Multi-Turn De-escalation
|
| 33 |
difficulty: very_hard
|
|
|
|
| 34 |
domain: customer_support
|
| 35 |
- id: legal_clause_identification
|
| 36 |
name: Legal Clause Identification
|
| 37 |
difficulty: easy
|
|
|
|
| 38 |
domain: legal
|
| 39 |
- id: legal_risk_flagging
|
| 40 |
name: Legal Risk Flagging
|
| 41 |
difficulty: medium
|
|
|
|
| 42 |
domain: legal
|
| 43 |
- id: legal_clause_redlining
|
| 44 |
name: Legal Clause Redlining
|
| 45 |
difficulty: hard
|
|
|
|
| 46 |
domain: legal
|
| 47 |
- id: clinical_triage_classification
|
| 48 |
name: Clinical Triage Body System
|
| 49 |
difficulty: easy
|
|
|
|
| 50 |
domain: clinical
|
| 51 |
- id: clinical_esi_assignment
|
| 52 |
name: Clinical ESI Assignment
|
| 53 |
difficulty: medium
|
|
|
|
| 54 |
domain: clinical
|
| 55 |
- id: clinical_triage_note
|
| 56 |
name: Clinical Triage Note Generation
|
| 57 |
difficulty: hard
|
|
|
|
| 58 |
domain: clinical
|
| 59 |
- id: pr_type_classification
|
| 60 |
name: PR Type Classification
|
| 61 |
difficulty: easy
|
|
|
|
| 62 |
domain: engineering
|
| 63 |
- id: pr_bug_identification
|
| 64 |
name: PR Bug Identification
|
| 65 |
difficulty: medium
|
|
|
|
| 66 |
domain: engineering
|
| 67 |
- id: pr_review_comment
|
| 68 |
name: PR Code Review
|
| 69 |
difficulty: hard
|
|
|
|
| 70 |
domain: engineering
|
| 71 |
endpoints:
|
| 72 |
reset: POST /reset
|
|
@@ -77,4 +90,4 @@ endpoints:
|
|
| 77 |
baseline: POST /baseline
|
| 78 |
observation_schema: app.models.Observation
|
| 79 |
action_schema: app.models.Action
|
| 80 |
-
reward_schema: app.models.Reward
|
|
|
|
| 19 |
- id: ticket_classification
|
| 20 |
name: Ticket Classification & Routing
|
| 21 |
difficulty: easy
|
| 22 |
+
score_range: [0.001, 0.999]
|
| 23 |
domain: customer_support
|
| 24 |
- id: response_drafting
|
| 25 |
name: Response Drafting & Quality
|
| 26 |
difficulty: medium
|
| 27 |
+
score_range: [0.001, 0.999]
|
| 28 |
domain: customer_support
|
| 29 |
- id: queue_management
|
| 30 |
name: SLA Queue Management
|
| 31 |
difficulty: hard
|
| 32 |
+
score_range: [0.001, 0.999]
|
| 33 |
domain: customer_support
|
| 34 |
- id: multi_turn_conversation
|
| 35 |
name: Multi-Turn De-escalation
|
| 36 |
difficulty: very_hard
|
| 37 |
+
score_range: [0.001, 0.999]
|
| 38 |
domain: customer_support
|
| 39 |
- id: legal_clause_identification
|
| 40 |
name: Legal Clause Identification
|
| 41 |
difficulty: easy
|
| 42 |
+
score_range: [0.001, 0.999]
|
| 43 |
domain: legal
|
| 44 |
- id: legal_risk_flagging
|
| 45 |
name: Legal Risk Flagging
|
| 46 |
difficulty: medium
|
| 47 |
+
score_range: [0.001, 0.999]
|
| 48 |
domain: legal
|
| 49 |
- id: legal_clause_redlining
|
| 50 |
name: Legal Clause Redlining
|
| 51 |
difficulty: hard
|
| 52 |
+
score_range: [0.001, 0.999]
|
| 53 |
domain: legal
|
| 54 |
- id: clinical_triage_classification
|
| 55 |
name: Clinical Triage Body System
|
| 56 |
difficulty: easy
|
| 57 |
+
score_range: [0.001, 0.999]
|
| 58 |
domain: clinical
|
| 59 |
- id: clinical_esi_assignment
|
| 60 |
name: Clinical ESI Assignment
|
| 61 |
difficulty: medium
|
| 62 |
+
score_range: [0.001, 0.999]
|
| 63 |
domain: clinical
|
| 64 |
- id: clinical_triage_note
|
| 65 |
name: Clinical Triage Note Generation
|
| 66 |
difficulty: hard
|
| 67 |
+
score_range: [0.001, 0.999]
|
| 68 |
domain: clinical
|
| 69 |
- id: pr_type_classification
|
| 70 |
name: PR Type Classification
|
| 71 |
difficulty: easy
|
| 72 |
+
score_range: [0.001, 0.999]
|
| 73 |
domain: engineering
|
| 74 |
- id: pr_bug_identification
|
| 75 |
name: PR Bug Identification
|
| 76 |
difficulty: medium
|
| 77 |
+
score_range: [0.001, 0.999]
|
| 78 |
domain: engineering
|
| 79 |
- id: pr_review_comment
|
| 80 |
name: PR Code Review
|
| 81 |
difficulty: hard
|
| 82 |
+
score_range: [0.001, 0.999]
|
| 83 |
domain: engineering
|
| 84 |
endpoints:
|
| 85 |
reset: POST /reset
|
|
|
|
| 90 |
baseline: POST /baseline
|
| 91 |
observation_schema: app.models.Observation
|
| 92 |
action_schema: app.models.Action
|
| 93 |
+
reward_schema: app.models.Reward
|