THED2 commited on
Commit
c23d803
·
verified ·
1 Parent(s): 5fc1945

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -15,7 +15,6 @@ class ChatRequest(BaseModel):
15
 
16
  def execute_in_sandbox(command: str):
17
  try:
18
- # /tmp directory me user ko bina sudo ke full write access milti hai
19
  full_command = f"cd /tmp && {command}"
20
 
21
  result = subprocess.run(
@@ -23,7 +22,7 @@ def execute_in_sandbox(command: str):
23
  shell=True,
24
  capture_output=True,
25
  text=True,
26
- timeout=600
27
  )
28
  return {
29
  "stdout": result.stdout,
@@ -33,17 +32,17 @@ def execute_in_sandbox(command: str):
33
  except Exception as e:
34
  return {"error": str(e)}
35
 
36
- @app.post("/chat")
37
  async def agent_chat(request: ChatRequest):
38
  user_prompt = request.message
39
 
40
- # AI ko strictly bol rahe hain ki sudo use na kare, balki /tmp me local tools setup kare
41
  system_instruction = (
42
- "You are an AI Agent Builder operating inside a limited Linux sandbox. "
43
- "You CANNOT use 'sudo' or root commands because the platform restricts it. "
44
- "Instead, you must install everything locally inside the `/tmp` directory using pre-compiled binaries, curl, or local zip extractions. "
45
- "For example, to use Flutter, download its tar.xz via curl into /tmp, extract it, and run it from there directly. "
46
- "If you want to execute any bash setup, return the exact script inside a triple backtick block starting with 'bash'."
 
47
  )
48
 
49
  try:
 
15
 
16
  def execute_in_sandbox(command: str):
17
  try:
 
18
  full_command = f"cd /tmp && {command}"
19
 
20
  result = subprocess.run(
 
22
  shell=True,
23
  capture_output=True,
24
  text=True,
25
+ timeout=900 # Timeout badhakar 15 mins kiya kyunki heavy downloads hain
26
  )
27
  return {
28
  "stdout": result.stdout,
 
32
  except Exception as e:
33
  return {"error": str(e)}
34
 
35
+ @app.post("/chat/")
36
  async def agent_chat(request: ChatRequest):
37
  user_prompt = request.message
38
 
 
39
  system_instruction = (
40
+ "You are an AI Agent Builder inside a limited Linux sandbox. "
41
+ "You CANNOT use 'sudo'. Always use `/tmp` for all operations. "
42
+ "IMPORTANT: Packages like `xz-utils` and `unzip` are already installed. "
43
+ "To build Flutter apps, download the stable tar.xz into `/tmp`, extract it using `tar -xf`, and export its bin to PATH. "
44
+ "Since disk space is limited, always clean up heavy installation folders from `/tmp` AFTER successfully uploading the compiled APK to gofile.io. "
45
+ "Return the exact script inside a triple backtick block starting with 'bash'."
46
  )
47
 
48
  try: