Update app.py
Browse files9 unmodified lines10111213141542 unmodified lines5859606162636460 unmodified lines12512612712812913013169 unmodified lines2012022032042052062072082092102112122132142152162172182192209 unmodified lines# Gemini API Key -> Hugging Face Space ke Secrets mein 'GEMINI_API_KEY' naam se save kareinGEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")GEMINI_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={GEMINI_API_KEY}"# ==========================================42 unmodified linesreturn f"Execution Error: {str(e)}"def run_terminal_command(command: str) -> str:"""VS Code workspace ya terminal par Android compile/build commands run karne ke liye."""try:result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=300)output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"60 unmodified lines},{"name": "run_terminal_command","description": "Run terminal commands inside VS Code workspace like compilation, gradle build, or file navigation.","parameters": {"type": "OBJECT","properties": {"command": {"type": "STRING", "description": "The bash command to run"}},69 unmodified linesreturn f"Gemini Flash Execution Error: Kripya check karein ki GEMINI_API_KEY valid hai ya nahi. Details: {str(e)}"# ==========================================# 4. GRADIO INTERFACE + MULTI-PORT UI LINK# ==========================================with gr.Blocks(theme="soft") as demo:gr.Markdown("# 📦 LobeHub-Style Docker Agent + VS Code Server")gr.Markdown("### 🛠️ [👉 CLICK HERE TO OPEN VS CODE (CODE-SERVER) 👈](https://huggingface.co/spaces/" + os.environ.get("SPACE_ID", "") + "/?preview=true)")gr.Markdown("_Agar upar wala link kaam na kare, toh space URL ke peeche `direct/` laga kar direct check karein._")chat = gr.ChatInterface(fn=run_agent,description="Docker container backend ke sath chalne wala Agent: Search, Browser, Math aur Python Interpreter sab free!",)if __name__ == "__main__":# Launching Gradio on Port 7860 as required by Hugging Facedemo.launch(server_name="0.0.0.0", server_port=7860)9 unmodified lines1011121314151642 unmodified lines5960616263646560 unmodified lines12612712812913013113269 unmodified lines2022032042052062072082092102112122132142152162179 unmodified lines# Gemini API Key -> Hugging Face Space ke Secrets mein 'GEMINI_API_KEY' naam se save kareinGEMINI_API_KEY = os.environ.get("GEMINI_API_KEY")# Using Gemini 1.5 Flash for quick backend toolsGEMINI_URL = f"https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash:generateContent?key={GEMINI_API_KEY}"# ==========================================42 unmodified linesreturn f"Execution Error: {str(e)}"def run_terminal_command(command: str) -> str:"""Terminal par Android compile/build commands run karne ke liye."""try:result = subprocess.run(command, shell=True, capture_output=True, text=True, timeout=300)output = f"STDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"60 unmodified lines},{"name": "run_terminal_command","description": "Run terminal commands inside workspace like compilation, gradle build, etc.","parameters": {"type": "OBJECT","properties": {"command": {"type": "STRING", "description": "The bash command to run"}},69 unmodified linesreturn f"Gemini Flash Execution Error: Kripya check karein ki GEMINI_API_KEY valid hai ya nahi. Details: {str(e)}"# ==========================================# 4. ORIGINAL GRADIO INTERFACE (NO CHANGES)# ==========================================demo = gr.ChatInterface(fn=run_agent,title="📦 LobeHub-Style Docker Agent",description="Docker container backend ke sath chalne wala Agent: Search, Browser, Math aur Python Interpreter sab free!",theme="soft")if __name__ == "__main__":demo.launch()
app.py+11-14