""" Enterprise Agent Gradio Application Web interface for the Enterprise Agent """ import gradio as gr import asyncio import logging from .enterprise_agent import EnterpriseAgent class EnterpriseApp: """Gradio web application for Enterprise Agent.""" def __init__(self): self.agent = EnterpriseAgent() 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="šŸ¢ Enterprise Agent - Secure AI Suite", theme=gr.themes.Soft( primary_hue="blue", 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; } """ ) as app: # Header gr.HTML("""

šŸ¢ Enterprise Agent

Automate CRM, Tickets & Calendar with AI

šŸ” Secure AI Agents Suite

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

šŸ’¬ Chat with Enterprise Agent

") chatbot = gr.Chatbot( label="Enterprise Assistant", height=400, elem_classes=["chatbot"], avatar_images=(None, "šŸ¢") ) with gr.Row(): msg_input = gr.Textbox( placeholder="Ask me about CRM updates, ticket creation, or calendar scheduling...", 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 - Tools and Status with gr.Column(scale=1): gr.HTML("

šŸ› ļø Available Tools

") tools_info = gr.HTML("""

šŸ—ƒļø CRM Operations

• Update customer information
• Search contacts and accounts
• Modify customer records

šŸŽ« Support Tickets

• Create support tickets
• Set priority levels
• Categorize issues

šŸ“… Calendar Management

• Schedule meetings
• Manage appointments
• View calendar events

""") gr.HTML("

šŸ“Š System Status

") status_display = gr.HTML() # 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) return history def clear_conversation(): """Clear conversation history.""" return [] def update_status(): """Update status display.""" status = self.agent.get_status() return f"""

āœ… System Status

Agent: {status['name']}

Status: {status['status']}

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

Audit Logging: {'šŸ“Š Enabled' if status['audit_logging'] else 'āŒ Disabled'}

Tools: {', '.join(status['tools'])}

""" # Connect events send_btn.click( user, inputs=[msg_input, chatbot], outputs=[chatbot, msg_input] ).then( bot_response, inputs=[chatbot, msg_input], outputs=[chatbot] ) msg_input.submit( user, inputs=[msg_input, chatbot], outputs=[chatbot, msg_input] ).then( bot_response, inputs=[chatbot, msg_input], outputs=[chatbot] ) clear_btn.click(clear_conversation, outputs=chatbot) # 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=7860, share=False, show_error=True, quiet=False, **kwargs ) # Example usage and quick commands EXAMPLE_QUERIES = [ "Update customer 001 email to newemail@company.com", "Create ticket about login issues - high priority", "Schedule team meeting for tomorrow at 2 PM", "Search for john contacts", "Show calendar events for today", "Check system status" ] def main(): """Main function to run the Enterprise Agent app.""" print("šŸ¢ Starting Enterprise Agent...") print("šŸ“” Connecting to MCP servers...") print("šŸ›”ļø Security middleware initialized") print("šŸ”§ Available tools: CRM, Tickets, Calendar") app = EnterpriseApp() print("\n" + "="*60) print("šŸ¢ ENTERPRISE AGENT - SECURE AI SUITE") print("="*60) print("\nšŸ’” Example queries 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:7860") print("\n" + "="*60) app.launch() if __name__ == "__main__": main()