Delete app.py import gradio as gr # Brain of the AI (Handling Text, Image, and 3D) def ai_process(text_input, image_input, chat_history): # History array ko initialize karna if chat_history is None: chat_history = [] user_text = text_input.lower() if text_input else "" # 1. IMAGE-TO-3D LOGIC if image_input is not None: chat_history.append(("Image uploaded", "Generating 3D model from your image... π§")) # Jab API connect hogi, toh yahan real 3D file (.glb) ka path aayega output_3d_file = "dummy_model.glb" return chat_history, output_3d_file # 2. TEXT-TO-3D LOGIC elif "3d" in user_text or "render" in user_text: chat_history.append((text_input, f"Generating 3D model for '{text_input}'... π§")) # Same yahan bhi 3D file aayegi output_3d_file = "dummy_model.glb" return chat_history, output_3d_file # 3. HARD CODING & NORMAL CHAT elif text_input: reply = f"Logic understood. Here is your code:\n\n```python\nprint('V.O.I.D System Online')\n```" chat_history.append((text_input, reply)) return chat_history, None return chat_history, None # Professional UI Design with gr.Blocks with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("# π V.O.I.D - Ultimate AI (Coding + 3D Generation)") with gr.Row(): # Left Side: Chat, Text Input, and Image Upload with gr.Column(scale=2): chatbot = gr.Chatbot(label="V.O.I.D Terminal", height=400) text_input = gr.Textbox(placeholder="Type your prompt here or ask for a 3D model...", label="Text Prompt") image_input = gr.Image(type="filepath", label="Upload Image for Image-to-3D (Optional)") submit_btn = gr.Button("Generate / Chat π", variant="primary") # Right Side: 3D Model Viewer with gr.Column(scale=1): model_viewer = gr.Model3D(label="3D Model Viewer (.glb, .obj, .gltf)", height=400) # Button click logic connection submit_btn.click( fn=ai_process, inputs=[text_input, image_input, chatbot], outputs=[chatbot, model_viewer] ) # Launch the Application demo.launch()
verified