Update app.py
Browse files
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=
|
| 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
|
| 43 |
-
"You CANNOT use 'sudo'
|
| 44 |
-
"
|
| 45 |
-
"
|
| 46 |
-
"
|
|
|
|
| 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:
|