import gradio as gr import os import requests # Google AI Studio / Gemini Connections GEMINI_API_KEY = os.getenv("GEMINI_API_KEY") def opencode_agent_engine(user_prompt): if not GEMINI_API_KEY: return "Error: Gemini API Key is missing! Please add it in Space Settings." # OpenCode Core Logic combined with Gemini Brain payload = { "contents": [{"parts": [{"text": f"Act as OpenCode AI Agent. Task: {user_prompt}"}]}] } url = f"https://googleapis.com{GEMINI_API_KEY}" try: response = requests.post(url, json=payload) result = response.json() return result['candidates'][0]['content']['parts'][0]['text'] except Exception as e: return f"OpenCode Connection Error: {str(e)}" # Premium Dark Theme UI for your Factory with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("# 🚀 OpenCode AI Cloud Agent Factory") gr.Markdown("Your limitless automated software factory running 24/7 on cloud.") with gr.Row(): input_box = gr.Textbox(label="Instruct OpenCode (e.g., Build a responsive website)", placeholder="Type your software requirements here...") submit_btn = gr.Button("Execute OpenCode Engine", variant="primary") output_box = gr.Code(label="Generated Software Code / Output", language="html") submit_btn.click(fn=opencode_agent_engine, inputs=input_box, outputs=output_box) demo.launch()