Metadata-Version: 2.4
Name: ors-sdk
Version: 0.1.0
Summary: Python SDK for the Open Reward Standard (ORS) — an HTTP protocol for connecting AI agents to RL environments
Project-URL: Homepage, https://openrewardstandard.io
Project-URL: Repository, https://github.com/openreward/ors-sdk
Project-URL: Documentation, https://openrewardstandard.io
Author: ORS Contributors
License-Expression: Apache-2.0
License-File: LICENSE
Keywords: agents,ai,environments,ors,reinforcement-learning,rl
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: aiohttp>=3.8
Requires-Dist: fastapi>=0.100
Requires-Dist: pydantic>=2.0
Requires-Dist: sse-starlette>=1.0
Requires-Dist: structlog>=23.0
Requires-Dist: tenacity>=8.0
Requires-Dist: typing-extensions>=4.0
Requires-Dist: uvicorn>=0.20
Provides-Extra: dev
Requires-Dist: httpx>=0.24; extra == 'dev'
Requires-Dist: mypy>=1.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: ruff>=0.1; extra == 'dev'
Description-Content-Type: text/markdown

# ORS SDK

[![Docs](https://img.shields.io/badge/docs-openrewardstandard.io-blue)](https://openrewardstandard.io)

Python SDK for the [Open Reward Standard](https://openrewardstandard.io) (ORS) — an HTTP-based protocol for connecting AI agents to reinforcement learning environments.

## Installation

```bash
pip install ors-sdk
```

## Quick Start

### Server (hosting an environment)

```python
from pydantic import BaseModel
from ors import Environment, Server, tool, ToolOutput, TextBlock, Split


class SubmitInput(BaseModel):
    answer: str


class MathEnv(Environment):
    @classmethod
    def list_splits(cls):
        return [Split(name="test", type="test")]

    @classmethod
    def list_tasks(cls, split: str):
        return [{"question": "What is 2+2?", "answer": "4"}]

    def get_prompt(self):
        return [TextBlock(text=self.task_spec["question"])]

    @tool
    def submit(self, params: SubmitInput) -> ToolOutput:
        correct = params.answer.strip() == self.task_spec["answer"]
        return ToolOutput(
            blocks=[TextBlock(text="Correct!" if correct else "Incorrect")],
            reward=1.0 if correct else 0.0,
            finished=True,
        )


if __name__ == "__main__":
    Server([MathEnv]).run(port=8080)
```

### Client (connecting to an environment)

```python
from ors.client import ORS

client = ORS(base_url="http://localhost:8080")
env = client.environment("mathenv")
tasks = env.list_tasks(split="test")

with env.session(task=tasks[0]) as session:
    prompt = session.get_prompt()
    print(f"Question: {prompt[0].text}")

    result = session.call_tool("submit", {"answer": "4"})
    print(f"Reward: {result.reward}, Finished: {result.finished}")
```

## Links

- [ORS Specification](https://openrewardstandard.io)
- [ORS HTTP API](https://openrewardstandard.io/specification/http-api)

## License

Apache 2.0
