INFO: Started server process [12345]INFO: Waiting for application startup.INFO: Application startup complete.INFO: Uvicorn running on http://0.0.0.0:8080
# test_environment.pyfrom openreward import OpenRewardor_client = OpenReward(base_url="http://localhost:8080") # you must point towards the environment if running locally# Connect to local server (no namespace = localhost)environment = or_client.environments.get(name="myenvironment")# List taskstasks = environment.list_tasks(split="train")print(f"Found {len(tasks)} tasks")# Create session and test toolwith environment.session(task=tasks[0]) as session: prompt = session.get_prompt() print(f"Prompt: {prompt[0].text}") result = session.call_tool("answer", {"answer": "4"}) print(f"Result: {result.blocks[0].text}") print(f"Reward: {result.reward}")
Alternatively, if you don’t want the whole client to point to http://localhost:8080just change the base_url when getting the environment, like this:
# Build Docker imagedocker build -t my-environment:local .# Run containerdocker run -p 8080:8080 my-environment:local# Test from another terminalpython test_environment.py