Skip to content

Commit 9fb09c8

Browse files
author
dingrong.wwk
committed
update main.py
Change-Id: I3f0b1ea2d4b1ff711feae60c35b109a30eb7b78d
1 parent 21845e8 commit 9fb09c8

1 file changed

Lines changed: 15 additions & 11 deletions

File tree

sdk/customized_e2b/main.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
1-
# export E2B_DOMAIN=3000-sandbox1234.example.com
1+
# Optional: export instead of using defaults below
2+
# export E2B_DOMAIN=sae.sandbox.com
23
# export E2B_API_KEY=admin-987654321
3-
# 120.79.183.30 3000-sandbox1234.example.com
44

5+
import os
6+
7+
os.environ.setdefault("E2B_DOMAIN", "sae.sandbox.com")
8+
os.environ.setdefault("E2B_API_KEY", "admin-987654321")
59

610
# Import the E2B SDK
711
from e2b_code_interpreter import Sandbox
812
from kruise_agents.patch_e2b import patch_e2b
913

1014
patch_e2b(https=False) # patch sdk
1115

12-
sbx: Sandbox = Sandbox.create(template="sandbox-nginx-complex-1-202604071748")
16+
sbx: Sandbox = Sandbox.create(template="code-interpreter")
1317
print(f"sandbox id: {sbx.sandbox_id}")
14-
# result = sbx.run_code("print('hello, world')")
15-
# print(f"run code result: {result}")
16-
# text = input("enter some text to be saved to file 'text.txt' inside sandbox: ")
17-
# sbx.files.write("text.txt", text)
18-
# print(f"read file from sandbox via files api: [{sbx.files.read('text.txt')}]")
19-
# print(f"read file from sandbox via commands api: [{sbx.commands.run('cat text.txt')}]")
20-
# input("press ENTER to kill the sandbox")
21-
# print(sbx.kill())
18+
result = sbx.run_code("print('hello, world')")
19+
print(f"run code result: {result}")
20+
text = input("enter some text to be saved to file 'text.txt' inside sandbox: ")
21+
sbx.files.write("text.txt", text)
22+
print(f"read file from sandbox via files api: [{sbx.files.read('text.txt')}]")
23+
print(f"read file from sandbox via commands api: [{sbx.commands.run('cat text.txt')}]")
24+
input("press ENTER to kill the sandbox")
25+
print(sbx.kill())

0 commit comments

Comments
 (0)