-
Notifications
You must be signed in to change notification settings - Fork 239
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (29 loc) · 871 Bytes
/
main.py
File metadata and controls
40 lines (29 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import os
from dotenv import load_dotenv
from e2b import Sandbox
from app.template import template_name
def main():
load_dotenv()
sbx = Sandbox.create(
template_name,
envs={
"ANTHROPIC_API_KEY": os.getenv("ANTHROPIC_API_KEY"),
},
)
print("Sandbox created", sbx.sandbox_id)
# Print help for Claude Code
# result = sbx.commands.run('claude --help')
# print(result.stdout)
# Run a prompt with Claude Code
result = sbx.commands.run(
"echo 'Create a hello world index.html' | claude -p --dangerously-skip-permissions",
timeout=0,
)
print(result.stdout)
content = sbx.files.read('/home/user/index.html')
# Write file to local filesystem
with open('./index.html', 'w') as file:
file.write(content)
sbx.kill()
if __name__ == "__main__":
main()