Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions contract_env/env/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
from contract_env.env.models import Action, Observation
from contract_env.env.tasks import TASKS, NegotiationTask

random.seed(42)


class ContractEnv:
"""Multi-turn contract-negotiation environment.
Expand Down
2 changes: 2 additions & 0 deletions contract_env/server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ def step(req: StepRequest) -> dict[str, Any]:
"info": info,
}

except RuntimeError as e:
raise HTTPException(status_code=400, detail=str(e))
except ValidationError as e:
raise HTTPException(status_code=422, detail=e.errors())
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion hf_create.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

req = urllib.request.Request(url, headers=headers, data=data)
try:
with urllib.request.urlopen(req) as resp:
with urllib.request.urlopen(req, timeout=30) as resp:
print(resp.read().decode("utf-8"))
except Exception as e:
import traceback
Expand Down
5 changes: 4 additions & 1 deletion inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
def load_dotenv(*_a: Any, **_kw: Any) -> None: # type: ignore[misc]
pass

# Load .env BEFORE reading any environment variables so that .env-only
# configuration is picked up by the module-level constants below.
load_dotenv()

from openai import OpenAI

from contract_env.env.environment import ContractEnv
Expand Down Expand Up @@ -652,7 +656,6 @@ def run_episode(env, task_id: Optional[str] = None) -> tuple[float, str]:

# ── MAIN ─────────────────────────────────────────────────────────────────
def main() -> None:
load_dotenv()
random.seed(42)

parser = argparse.ArgumentParser(
Expand Down
4 changes: 4 additions & 0 deletions server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
"""

from contract_env.server.app import app # noqa: F401
from contract_env.server.app import main # noqa: F401

if __name__ == "__main__":
main()
Loading