Update app.py
Browse files
app.py
CHANGED
|
@@ -10,6 +10,7 @@ from bs4 import BeautifulSoup
|
|
| 10 |
|
| 11 |
# Gemini API Key -> Hugging Face Space ke Secrets mein 'GEMINI_API_KEY' naam se save karein
|
| 12 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
|
|
|
| 13 |
GEMINI_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={GEMINI_API_KEY}"
|
| 14 |
|
| 15 |
# ==========================================
|
|
@@ -58,7 +59,7 @@ def python_interpreter(code: str) -> str:
|
|
| 58 |
return f"Execution Error: {str(e)}"
|
| 59 |
|
| 60 |
def run_terminal_command(command: str) -> str:
|
| 61 |
-
"""
|
| 62 |
try:
|
| 63 |
result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=300)
|
| 64 |
output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
|
|
@@ -125,7 +126,7 @@ GEMINI_TOOLS = [{
|
|
| 125 |
},
|
| 126 |
{
|
| 127 |
"name": "run_terminal_command",
|
| 128 |
-
"description": "Run terminal commands inside
|
| 129 |
"parameters": {
|
| 130 |
"type": "OBJECT",
|
| 131 |
"properties": {"command": {"type": "STRING", "description": "The bash command to run"}},
|
|
@@ -201,20 +202,16 @@ def run_agent(message, history):
|
|
| 201 |
return f"Gemini Flash Execution Error: Kripya check karein ki GEMINI_API_KEY valid hai ya nahi. Details: {str(e)}"
|
| 202 |
|
| 203 |
# ==========================================
|
| 204 |
-
# 4. GRADIO INTERFACE
|
| 205 |
# ==========================================
|
| 206 |
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
fn=run_agent,
|
| 214 |
-
description="Docker container backend ke sath chalne wala Agent: Search, Browser, Math aur Python Interpreter sab free!",
|
| 215 |
-
)
|
| 216 |
|
| 217 |
if __name__ == "__main__":
|
| 218 |
-
|
| 219 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 220 |
|
|
|
|
| 10 |
|
| 11 |
# Gemini API Key -> Hugging Face Space ke Secrets mein 'GEMINI_API_KEY' naam se save karein
|
| 12 |
GEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")
|
| 13 |
+
# Using Gemini 1.5 Flash for quick backend tools
|
| 14 |
GEMINI_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={GEMINI_API_KEY}"
|
| 15 |
|
| 16 |
# ==========================================
|
|
|
|
| 59 |
return f"Execution Error: {str(e)}"
|
| 60 |
|
| 61 |
def run_terminal_command(command: str) -> str:
|
| 62 |
+
"""Terminal par Android compile/build commands run karne ke liye."""
|
| 63 |
try:
|
| 64 |
result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=300)
|
| 65 |
output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
|
|
|
|
| 126 |
},
|
| 127 |
{
|
| 128 |
"name": "run_terminal_command",
|
| 129 |
+
"description": "Run terminal commands inside workspace like compilation, gradle build, etc.",
|
| 130 |
"parameters": {
|
| 131 |
"type": "OBJECT",
|
| 132 |
"properties": {"command": {"type": "STRING", "description": "The bash command to run"}},
|
|
|
|
| 202 |
return f"Gemini Flash Execution Error: Kripya check karein ki GEMINI_API_KEY valid hai ya nahi. Details: {str(e)}"
|
| 203 |
|
| 204 |
# ==========================================
|
| 205 |
+
# 4. ORIGINAL GRADIO INTERFACE (NO CHANGES)
|
| 206 |
# ==========================================
|
| 207 |
|
| 208 |
+
demo = gr.ChatInterface(
|
| 209 |
+
fn=run_agent,
|
| 210 |
+
title="📦 LobeHub-Style Docker Agent",
|
| 211 |
+
description="Docker container backend ke sath chalne wala Agent: Search, Browser, Math aur Python Interpreter sab free!",
|
| 212 |
+
theme="soft"
|
| 213 |
+
)
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
if __name__ == "__main__":
|
| 216 |
+
demo.launch()
|
|
|
|
| 217 |
|