ATISHAY005 commited on
Commit
cfa64d1
·
1 Parent(s): f677895

Fix OpenEnv validation issues

Browse files
Files changed (4) hide show
  1. Dockerfile +1 -1
  2. pyproject.toml +5 -1
  3. server/app.py +33 -0
  4. uv.lock +0 -0
Dockerfile CHANGED
@@ -5,4 +5,4 @@ COPY . .
5
 
6
  RUN pip install --no-cache-dir numpy fastapi uvicorn
7
 
8
- CMD ["uvicorn", "inference:app", "--host", "0.0.0.0", "--port", "7860"]
 
5
 
6
  RUN pip install --no-cache-dir numpy fastapi uvicorn
7
 
8
+ CMD ["uvicorn", "server.app:app", "--host", "0.0.0.0", "--port", "7860"]
pyproject.toml CHANGED
@@ -8,9 +8,13 @@ authors = [
8
  dependencies = [
9
  "numpy",
10
  "fastapi",
11
- "uvicorn"
 
12
  ]
13
 
 
 
 
14
  [build-system]
15
  requires = ["setuptools"]
16
  build-backend = "setuptools.build_meta"
 
8
  dependencies = [
9
  "numpy",
10
  "fastapi",
11
+ "uvicorn",
12
+ "openenv-core>=0.2.0"
13
  ]
14
 
15
+ [project.scripts]
16
+ server = "server.app:app"
17
+
18
  [build-system]
19
  requires = ["setuptools"]
20
  build-backend = "setuptools.build_meta"
server/app.py ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ import json
3
+
4
+ from env.feed_env import FeedRankingEnv
5
+ from agents.random_agent import RandomAgent
6
+
7
+ app = FastAPI()
8
+
9
+ with open("data/posts.json", "r") as f:
10
+ posts = json.load(f)
11
+
12
+ env = FeedRankingEnv(posts, task="hard")
13
+ agent = RandomAgent()
14
+
15
+ @app.get("/")
16
+ def root():
17
+ return {"message": "OpenEnv server running"}
18
+
19
+ @app.post("/reset")
20
+ def reset():
21
+ state = env.reset()
22
+ return {"state": state.__dict__}
23
+
24
+ @app.post("/step")
25
+ def step():
26
+ action = agent.act(env.state(), env.posts)
27
+ state, reward, done, _ = env.step(action)
28
+
29
+ return {
30
+ "state": state.__dict__,
31
+ "reward": reward,
32
+ "done": done
33
+ }
uv.lock ADDED
The diff for this file is too large to render. See raw diff