Skip to content

Commit 0cbecbb

Browse files
committed
feat: enhance Daytona REPL examples and documentation
1 parent a4cb5d9 commit 0cbecbb

3 files changed

Lines changed: 31 additions & 18 deletions

File tree

‎examples/daytona_repl_example.py‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def main():
4949

5050
try:
5151
with DaytonaREPL(name="rlm-example") as repl:
52+
print(f"Daytona sandbox started with ID: {repl.sandbox.id}")
5253
result = repl.execute_code("x = 1 + 2")
5354
print("Executed: x = 1 + 2")
5455
print(f"Locals: {result.locals}")
@@ -74,6 +75,9 @@ def main():
7475
name="rlm-example-handler",
7576
lm_handler_address=handler.address,
7677
) as repl:
78+
print(f"Daytona sandbox started with ID: {repl.sandbox.id}")
79+
print(f"Broker URL: {repl.broker_url}")
80+
7781
# Single LLM query
7882
result = repl.execute_code('response = llm_query("What is 2+2?")')
7983
print("Executed: response = llm_query('What is 2+2?')")

‎examples/quickstart.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
verbose=True, # For printing to console with rich, disabled by default.
2525
)
2626

27-
result = rlm.completion("Print me the first 100 powers of two, each on a newline.")
27+
result = rlm.completion(
28+
"Print me the first 10 powers of two, each on a newline. Then, use `llm_query` to ask the LLM to write a haiku about the 3rd number."
29+
)
2830

2931
print(result)

‎rlm/environments/daytona_repl.py‎

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
"""
2+
Daytona REPL environment that runs Python code in Daytona sandboxes.
3+
4+
Uses the Daytona API (https://daytona.io/docs) for sandbox management.
5+
"""
6+
17
import base64
28
import json
39
import textwrap
@@ -9,6 +15,7 @@
915
CreateSandboxFromImageParams,
1016
Daytona,
1117
DaytonaConfig,
18+
Image,
1219
Resources,
1320
SessionExecuteRequest,
1421
)
@@ -22,22 +29,22 @@
2229
# =============================================================================
2330

2431

25-
def get_default_image() -> dict:
32+
def get_default_image() -> Image:
2633
"""
27-
Build a default Daytona image specification with common libraries for data science,
34+
Build a default Daytona image with common libraries for data science,
2835
math, and general Python work.
2936
"""
30-
return {
31-
"base_image": "python:3.11-slim",
32-
"system_packages": [
33-
"build-essential",
34-
"git",
35-
"curl",
36-
"wget",
37-
"libopenblas-dev",
38-
"liblapack-dev",
39-
],
40-
"python_packages": [
37+
return (
38+
Image.debian_slim("3.11")
39+
.run_commands(
40+
"apt-get update && apt-get install -y build-essential \
41+
git \
42+
curl \
43+
wget \
44+
libopenblas-dev \
45+
liblapack-dev",
46+
)
47+
.pip_install(
4148
# Data science essentials
4249
"numpy>=1.26.0",
4350
"pandas>=2.1.0",
@@ -57,8 +64,8 @@ def get_default_image() -> dict:
5764
"regex>=2023.0.0",
5865
# For state serialization
5966
"dill>=0.3.7",
60-
],
61-
}
67+
)
68+
)
6269

6370

6471
# =============================================================================
@@ -317,7 +324,7 @@ def __init__(
317324
memory: int = 2,
318325
disk: int = 5,
319326
auto_stop_interval: int = 0,
320-
image: dict | None = None,
327+
image: Image | None = None,
321328
lm_handler_address: tuple[str, int] | None = None,
322329
context_payload: dict | list | str | None = None,
323330
setup_code: str | None = None,
@@ -335,7 +342,7 @@ def __init__(
335342
memory: Memory in GB for the sandbox.
336343
disk: Disk space in GB for the sandbox.
337344
auto_stop_interval: Minutes of inactivity before auto-stop. 0 = run indefinitely.
338-
image: Image specification dict for declarative building. If None, uses default image.
345+
image: Daytona Image object for declarative building. If None, uses default image.
339346
lm_handler_address: (host, port) tuple for LM Handler server.
340347
context_payload: Initial context to load into the environment.
341348
setup_code: Optional code to run during setup.

0 commit comments

Comments
 (0)