THED2 commited on
Commit
febeda1
·
verified ·
1 Parent(s): e06a25b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -14
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
- """VS Code workspace ya terminal par Android compile/build commands run karne ke liye."""
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 VS Code workspace like compilation, gradle build, or file navigation.",
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 + MULTI-PORT UI LINK
205
  # ==========================================
206
 
207
- with gr.Blocks(theme="soft") as demo:
208
- gr.Markdown("# 📦 LobeHub-Style Docker Agent + VS Code Server")
209
- gr.Markdown("### 🛠️ [👉 CLICK HERE TO OPEN VS CODE (CODE-SERVER) 👈](https://huggingface.co/spaces/" + os.environ.get("SPACE_ID", "") + "/?preview=true)")
210
- gr.Markdown("_Agar upar wala link kaam na kare, toh space URL ke peeche `direct/` laga kar direct check karein._")
211
-
212
- chat = gr.ChatInterface(
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
- # Launching Gradio on Port 7860 as required by Hugging Face
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