pramodmisra Claude Opus 4.5 commited on
Commit
e72cd90
·
1 Parent(s): aacfb7c

Fix: Correct import paths and env factory pattern

Browse files

- app.py: Import from space_app instead of broken claims_env.server.app
- server/app.py: Pass ClaimsEnvironment class, not instance

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Files changed (3) hide show
  1. app.py +3 -3
  2. server/app.py +2 -4
  3. tasks/todo.md +67 -0
app.py CHANGED
@@ -2,10 +2,10 @@
2
  HuggingFace Spaces Entry Point
3
 
4
  This file is the entry point for HuggingFace Spaces deployment.
5
- It re-exports the app from server/app.py.
6
  """
7
 
8
- from claims_env.server.app import app
 
9
 
10
- # This is what HF Spaces will run
11
  __all__ = ["app"]
 
2
  HuggingFace Spaces Entry Point
3
 
4
  This file is the entry point for HuggingFace Spaces deployment.
5
+ Re-exports the app from space_app.py.
6
  """
7
 
8
+ # Import directly from space_app which has correct imports
9
+ from space_app import app
10
 
 
11
  __all__ = ["app"]
server/app.py CHANGED
@@ -15,11 +15,9 @@ except ImportError:
15
  from models import ClaimsAction, ClaimsObservation
16
  from server.claims_environment import ClaimsEnvironment
17
 
18
- # Create environment instance
19
- env = ClaimsEnvironment()
20
-
21
  # Create FastAPI app using OpenEnv helper
22
- app = create_fastapi_app(env, ClaimsAction, ClaimsObservation)
 
23
 
24
 
25
  # Add custom endpoints for environment info
 
15
  from models import ClaimsAction, ClaimsObservation
16
  from server.claims_environment import ClaimsEnvironment
17
 
 
 
 
18
  # Create FastAPI app using OpenEnv helper
19
+ # Note: Pass the CLASS, not an instance (OpenEnv creates instances per session)
20
+ app = create_fastapi_app(ClaimsEnvironment, ClaimsAction, ClaimsObservation)
21
 
22
 
23
  # Add custom endpoints for environment info
tasks/todo.md ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenEnv Hackathon - Insurance Claims RL Environment
2
+
3
+ ## Status: Local Testing Complete, HF Space Deploying
4
+
5
+ ### Completed
6
+ - [x] Environment design (10 actions, 8 scenarios, partial observability)
7
+ - [x] Pydantic models (ClaimsAction, ClaimsObservation, ClaimsState)
8
+ - [x] Mock systems (PolicyDB, ClaimsHistoryDB, FraudAPI, DocumentSystem, PayoutCalculator)
9
+ - [x] Plaid integration for transaction verification
10
+ - [x] Multi-component reward function (+10 correct, +5 fraud caught, -10 fraud missed)
11
+ - [x] Local server testing via WebSocket (WORKING)
12
+ - [x] GitHub repo: https://github.com/pramodmisra/claims-env-hackathon
13
+ - [x] Training notebook updated with WebSocket protocol
14
+ - [x] Demo script created (demo_claims.py)
15
+ - [x] PITCH.md prepared with 3-minute script
16
+
17
+ ### In Progress
18
+ - [ ] HF Space: https://huggingface.co/spaces/pramodmisra/claims-env (STATUS: APP_STARTING)
19
+
20
+ ### Pending (User Action Required)
21
+ - [ ] Run training notebook on Colab Pro (requires GPU)
22
+ - [ ] Save reward_curves.png from training
23
+ - [ ] Record 1-minute YouTube demo video
24
+ - [ ] Submit to hackathon portal: https://openenv-hackathon.devpost.com
25
+ - [ ] Deadline: Sunday 1PM Pacific
26
+
27
+ ## Key Finding: OpenEnv Session Management
28
+
29
+ **Important**: OpenEnv's REST endpoints (`/reset`, `/step`) are **stateless** - each request creates a new environment instance.
30
+
31
+ For stateful multi-step episodes, use **WebSocket** connection to `/ws`:
32
+ ```python
33
+ async with websockets.connect("wss://your-space.hf.space/ws") as ws:
34
+ await ws.send('{"type": "reset", "data": {}}')
35
+ response = await ws.recv()
36
+ # ... process claim ...
37
+ await ws.send('{"type": "step", "data": {"action_type": "query_policy"}}')
38
+ ```
39
+
40
+ ## Test Commands
41
+
42
+ ### Local Server
43
+ ```bash
44
+ cd /Users/pramodmisra/Claude/openenv-hackathon/claims_env
45
+ python3 -m uvicorn space_app:app --port 7860 --host 127.0.0.1
46
+
47
+ # In another terminal:
48
+ python3 demo_claims.py
49
+ ```
50
+
51
+ ### HF Space (when ready)
52
+ ```bash
53
+ # Test via WebSocket
54
+ python3 -c "
55
+ import asyncio, websockets, json
56
+ async def test():
57
+ async with websockets.connect('wss://pramodmisra-claims-env.hf.space/ws') as ws:
58
+ await ws.send(json.dumps({'type': 'reset', 'data': {}}))
59
+ print(await ws.recv())
60
+ asyncio.run(test())
61
+ "
62
+ ```
63
+
64
+ ## Links
65
+ - **GitHub**: https://github.com/pramodmisra/claims-env-hackathon
66
+ - **HF Space**: https://huggingface.co/spaces/pramodmisra/claims-env
67
+ - **Problem Statement**: 3.1 Professional Tasks + Scaler AI Labs