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
28 changes: 28 additions & 0 deletions examples/e2b_repl_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os

from dotenv import load_dotenv

from rlm import RLM
from rlm.logger import RLMLogger

load_dotenv()

logger = RLMLogger(log_dir="./logs")

rlm = RLM(
backend="openai",
backend_kwargs={
"api_key": os.getenv("OPENAI_API_KEY"),
"model_name": "gpt-5-nano",
},
environment="e2b",
environment_kwargs={
"timeout": 300,
},
max_depth=1,
logger=logger,
verbose=True,
)

result = rlm.completion("Using your code, solve 2^(2^(2^(2))). Show your work in Python.")
print(result.response)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Issues = "https://github.com/alexzhang13/rlm/issues"

[project.optional-dependencies]
modal = ["modal>=0.73.0", "dill>=0.3.7"]
e2b = ["e2b-code-interpreter>=0.0.11", "dill>=0.3.7"]
daytona = ["daytona>=0.128.1", "dill>=0.3.7"]
prime = ["prime-sandboxes>=0.2.0", "dill>=0.3.7"]

Expand Down
2 changes: 1 addition & 1 deletion rlm/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"azure_openai",
"gemini",
]
EnvironmentType = Literal["local", "docker", "modal", "prime", "daytona"]
EnvironmentType = Literal["local", "docker", "modal", "prime", "daytona", "e2b"]


def _serialize_value(value: Any) -> Any:
Expand Down
10 changes: 7 additions & 3 deletions rlm/environments/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@


def get_environment(
environment: Literal["local", "modal", "docker", "daytona", "prime"],
environment: Literal["local", "modal", "docker", "daytona", "prime", "e2b"],
environment_kwargs: dict[str, Any],
) -> BaseEnv:
"""
Routes a specific environment and the args (as a dict) to the appropriate environment if supported.
Currently supported environments: ['local', 'modal', 'docker', 'daytona', 'prime']
Currently supported environments: ['local', 'modal', 'docker', 'daytona', 'prime', 'e2b']
"""
if environment == "local":
return LocalREPL(**environment_kwargs)
Expand All @@ -32,7 +32,11 @@ def get_environment(
from rlm.environments.prime_repl import PrimeREPL

return PrimeREPL(**environment_kwargs)
elif environment == "e2b":
from rlm.environments.e2b_repl import E2BREPL

return E2BREPL(**environment_kwargs)
else:
raise ValueError(
f"Unknown environment: {environment}. Supported: ['local', 'modal', 'docker', 'daytona', 'prime']"
f"Unknown environment: {environment}. Supported: ['local', 'modal', 'docker', 'daytona', 'prime', 'e2b']"
)
Loading