Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse filesFiles changed (2)
19 unmodified lines202122232324252675 unmodified lines10210310410510510610710810710810911011119 unmodified linestry: from openai import AsyncOpenAIexcept ImportError: print("Please install openai: pip install openai") print("Please install openai: pip install openai", file=sys.stderr) sys.exit(1)
BASE_URL = os.getenv("OPENENV_URL", "http://127.0.0.1:8000")75 unmodified lines if output_format == "json": print(json.dumps({"baseline_results": results, "agent": "openai_api"})) else: print("\n=== Baseline Results ===") print("\n=== Baseline Results ===", file=sys.stderr) for r in results: print(f" {r['task_id']:15s} score={r['best_score']:.3f} steps={r['steps']}") print(f"\n avg score: {sum(r['best_score'] for r in results) / len(results):.3f}") print(f" {r['task_id']:15s} score={r['best_score']:.3f} steps={r['steps']}", file=sys.stderr) print(f"\n avg score: {sum(r['best_score'] for r in results) / len(results):.3f}", file=sys.stderr)
if __name__ == "__main__": output = "json" if "json" in sys.argv else "table"123 unmodified lines124125126127127128129130131132133134135136137133138139140141142143144123 unmodified lines Run the baseline agent on all tasks and return scores. This endpoint triggers the baseline inference script. """ import subprocess, sys, json import subprocess, sys, json, re try: result = subprocess.run( [sys.executable, "baseline/run_baseline.py", "--output", "json"], capture_output=True, text=True, timeout=120, ) # Robustly find JSON in potentially noisy stdout stdout = result.stdout.strip() match = re.search(r'(\{.*\})', stdout, re.DOTALL) if match: return json.loads(result.stdout) return json.loads(match.group(1)) raise ValueError(f"No JSON found in baseline output. Stdout: {stdout[:200]}") except Exception as e: raise HTTPException(status_code=500, detail=str(e))
baseline/run_baseline.py+4-4
server/app.py+10-2