Core components for OpenEnv - HTTP-based agentic environments
Project description
OpenEnv Core
Core components for OpenEnv - a framework for building HTTP-based agentic environments.
Overview
openenv-core provides the foundational building blocks for creating and interacting with containerized environments over HTTP. It enables you to build agent environments that can be deployed as Docker containers and accessed via a simple HTTP API.
Features
- HTTPEnvClient: Generic HTTP client for interacting with remote environments
- HTTPEnvServer: FastAPI-based server wrapper for exposing environments over HTTP
- Container Providers: Pluggable architecture for running containers (Docker, Kubernetes, etc.)
- Type System: Strongly-typed Action/Observation/State interfaces
- Web Interface: Optional web UI for interacting with environments
Installation
pip install openenv-core
For development:
pip install openenv-core[dev]
Quick Start
Creating an Environment Client
from openenv_core import HTTPEnvClient, StepResult
from dataclasses import dataclass
@dataclass
class MyAction:
text: str
@dataclass
class MyObservation:
response: str
class MyEnvClient(HTTPEnvClient[MyAction, MyObservation]):
def _step_payload(self, action: MyAction) -> dict:
return {"text": action.text}
def _parse_result(self, payload: dict) -> StepResult[MyObservation]:
obs_data = payload["observation"]
return StepResult(
observation=MyObservation(**obs_data),
reward=payload.get("reward"),
done=payload.get("done", False)
)
def _parse_state(self, payload: dict) -> Any:
return payload
# Use with Docker
env = MyEnvClient.from_docker_image("my-env:latest")
result = env.reset()
step_result = env.step(MyAction(text="hello"))
env.close()
Creating an Environment Server
from openenv_core.env_server import Environment, HTTPEnvServer, create_app
from dataclasses import dataclass
@dataclass
class MyAction:
text: str
@dataclass
class MyObservation:
response: str
reward: float = 0.0
done: bool = False
class MyEnvironment(Environment):
def reset(self) -> MyObservation:
return MyObservation(response="Ready")
def step(self, action: MyAction) -> MyObservation:
return MyObservation(
response=f"Echo: {action.text}",
reward=1.0,
done=False
)
# Create FastAPI app
env = MyEnvironment()
app = create_app(env, MyAction, MyObservation)
# Run with: uvicorn module:app --host 0.0.0.0 --port 8000
Container Providers
OpenEnv Core supports multiple container providers:
Local Docker Provider
from openenv_core.containers.runtime import LocalDockerProvider
provider = LocalDockerProvider()
base_url = provider.start_container("my-env:latest")
provider.wait_for_ready(base_url)
# Use environment...
provider.stop_container()
Kubernetes Provider (Coming Soon)
from openenv_core.containers.runtime import KubernetesProvider
provider = KubernetesProvider(namespace="envs")
base_url = provider.start_container("my-env:latest")
# Use environment...
provider.stop_container()
Architecture
OpenEnv Core follows a client-server architecture:
┌─────────────────┐ HTTP ┌─────────────────┐
│ │◄─────────────────────►│ │
│ HTTPEnvClient │ /reset, /step │ HTTPEnvServer │
│ │ /state, /health │ │
└─────────────────┘ └─────────────────┘
│ │
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ Container │ │ Environment │
│ Provider │ │ Implementation │
└─────────────────┘ └─────────────────┘
API Reference
HTTPEnvClient
Base class for environment clients with these abstract methods:
_step_payload(action): Convert action to JSON_parse_result(payload): Parse response to StepResult_parse_state(payload): Parse state response
HTTPEnvServer
Server wrapper with these methods:
register_routes(app): Register endpoints on FastAPI app_deserialize_action(data): Convert JSON to Action_serialize_observation(obs): Convert Observation to JSON
Environment Interface
Base interface for environment implementations:
reset(): Reset environment and return initial observationstep(action): Execute action and return observationstate: Property returning current environment state
License
This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please see the main OpenEnv repository for contribution guidelines.
Links
- Homepage: https://github.com/facebookresearch/OpenEnv
- Documentation: https://github.com/facebookresearch/OpenEnv/blob/main/README.md
- Bug Tracker: https://github.com/facebookresearch/OpenEnv/issues
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openenv_core-0.1.0.tar.gz.
File metadata
- Download URL: openenv_core-0.1.0.tar.gz
- Upload date:
- Size: 26.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4e8bf4f2f3b7eba1c3a212e6e2dc7d980b8350015ae6c250a3ce93000f1d7c
|
|
| MD5 |
8613651a1273a5c5b0623ff879db2a86
|
|
| BLAKE2b-256 |
7f1874d2aedbf099a86de772364260827a12b4b4a56711db4caa3caa078588d7
|
File details
Details for the file openenv_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openenv_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 30.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d02513f26518f98ab1f35a875f7493d2983cf87f8b0e4b0af6634ec63edfd4b
|
|
| MD5 |
9e0973ecb98bffe4c3643dad19a25c2f
|
|
| BLAKE2b-256 |
3a4885afcd090eeaadf00e6f88ac92a866cb9238eaf6246820d1bc6564f5bc97
|