""" Creative Agent Gradio Application Web interface for the Creative Agent - Content Creation Studio """ import gradio as gr import asyncio import logging from .creative_agent import CreativeAgent class CreativeApp: """Gradio web application for Creative Agent.""" def __init__(self): self.agent = CreativeAgent() self.conversation_history = [] # Set up logging logging.basicConfig(level=logging.INFO) # Create the interface self.interface = self._create_interface() def _create_interface(self): """Create the Gradio interface.""" with gr.Blocks( title="šŸŽØ Creative Agent - Secure AI Suite", theme=gr.themes.Soft( primary_hue="purple", secondary_hue="gray", neutral_hue="slate" ), css=""" .container { max-width: 1200px; margin: auto; } .chatbot { height: 500px; } .status-card { background: linear-gradient(90deg, #667eea 0%, #764ba2 100%); color: white; } .tool-card { border: 2px solid #e2e8f0; border-radius: 8px; padding: 12px; margin: 8px 0; } .preview-box { border: 2px dashed #cbd5e0; padding: 20px; text-align: center; background: #f7fafc; } """ ) as app: # Header gr.HTML("""

šŸŽØ Creative Agent

Content Creation Studio & Bilingual Assets

šŸ” Secure AI Agents Suite

""") with gr.Row(): # Left column - Chat interface with gr.Column(scale=2): gr.HTML("

šŸ’¬ Chat with Creative Agent

") chatbot = gr.Chatbot( label="Creative Content Assistant", height=400, elem_classes=["chatbot"], avatar_images=(None, "šŸŽØ") ) with gr.Row(): msg_input = gr.Textbox( placeholder="Ask me to create carousels, scripts, brand content, or bilingual materials...", lines=3, max_lines=5, label="Your Message" ) with gr.Column(scale=0): send_btn = gr.Button("Send", variant="primary") clear_btn = gr.Button("Clear", variant="secondary") # Right column - Creative Tools and Preview with gr.Column(scale=1): gr.HTML("

šŸ› ļø Creative Services

") tools_info = gr.HTML("""

šŸ“± Content Carousels

• Bilingual presentations
• Social media slides
• Product showcases

šŸ“ Script Writing

• Commercial scripts
• Video narratives
• Presentation content

šŸ¢ Brand Content

• Brand guidelines
• Logo packages
• Marketing materials

🌐 Bilingual Support

• English ↔ Nepali
• Cultural adaptation
• Localized content

""") gr.HTML("

šŸ“Š System Status

") status_display = gr.HTML() gr.HTML("

šŸŽØ Creative Preview

") preview_box = gr.HTML("""

šŸŽØ Latest Creation

Ready to create your next masterpiece!

Content will appear here after generation

""") # Event handlers def user(user_message, history): """Handle user input.""" if not user_message.strip(): return history, "" # Add user message to history history.append((user_message, None)) return history, "" async def bot_response(history, user_message): """Generate bot response.""" if not user_message.strip(): return history # Get response from agent response = await self.agent.handle_user_input(user_message) # Add bot response to history history[-1] = (user_message, response) # Update preview box with latest creation if "Created" in response or "Generated" in response or "Package" in response: preview_html = f"""

šŸŽØ Latest Creation

{response.replace(chr(10), '
')}
""" return history, preview_html return history, """

šŸŽØ Ready for Creation

Ask me to create content and I'll show you the results here!

""" def clear_conversation(): """Clear conversation history.""" return [], """

šŸŽØ Canvas Clean

Ready for your next creative project!

""" def update_status(): """Update status display.""" status = self.agent.get_status() return f"""

āœ… Creative Status

Agent: {status['name']}

Status: {status['status']}

Languages: English, Nepali, Bilingual

Services: Content, Scripts, Assets

Security: {'šŸ›”ļø Enabled' if status['security_enabled'] else 'āŒ Disabled'}

""" # Connect events send_btn.click( user, inputs=[msg_input, chatbot], outputs=[chatbot, msg_input] ).then( bot_response, inputs=[chatbot, msg_input], outputs=[chatbot, preview_box] ) msg_input.submit( user, inputs=[msg_input, chatbot], outputs=[chatbot, msg_input] ).then( bot_response, inputs=[chatbot, msg_input], outputs=[chatbot, preview_box] ) clear_btn.click(clear_conversation, outputs=[chatbot, preview_box]) # Initial status update app.load(update_status, outputs=status_display) return app def launch(self, **kwargs): """Launch the Gradio application.""" self.interface.launch( server_name="0.0.0.0", server_port=7862, share=False, show_error=True, quiet=False, **kwargs ) # Example usage and quick commands EXAMPLE_QUERIES = [ "Create a 5-slide carousel about our new product in English and Nepali", "Write a 60-second commercial script for a tech startup", "Design brand guidelines for 'TechCorp Nepal'", "Translate 'Hello, welcome to our website' to Nepali", "Package logo assets in high resolution", "Create a content calendar for social media" ] def main(): """Main function to run the Creative Agent app.""" print("šŸŽØ Starting Creative Agent...") print("šŸŽ­ Loading content creation tools...") print("🌐 Initializing bilingual services...") print("šŸ“¦ Preparing asset generation...") app = CreativeApp() print("\n" + "="*60) print("šŸŽØ CREATIVE AGENT - CONTENT CREATION STUDIO") print("="*60) print("\nšŸ’” Example creative requests you can try:") for i, query in enumerate(EXAMPLE_QUERIES, 1): print(f" {i}. {query}") print("\n🌐 Starting Gradio server...") print("šŸ”— Open your browser to: http://localhost:7862") print("\n" + "="*60) app.launch() if __name__ == "__main__": main()