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
711from e2b_code_interpreter import Sandbox
812from kruise_agents .patch_e2b import patch_e2b
913
1014patch_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 " )
1317print (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