import gradio as gr # Predefined team lead data team_leads = [ "Neeraj (Healthcare)", "Ramya (Finance)", "Sita (E-commerce)", "Arjun (Logistics)" ] # Predefined team members for Neeraj neeraj_team = [ "Abhi", "Bharat", "Keerthi", "Ramya", "Pranay", "Gopal" ] # Chatbot logic to handle user input def chatbot(user_input, conversation_state=None): # Initialize conversation state if None if conversation_state is None: conversation_state = {"step": "initial"} user_input = user_input.lower().strip() # Step 1: Handle "hi" input if conversation_state["step"] == "initial" and user_input == "hi": conversation_state["step"] = "options" return ( "Hi! Welcome to Sathkrutha Solutions. Please select an option:\n" "1. Available Teams\n" "2. Current Projects\n" "3. Sales Team\n" "4. Delivery Team", conversation_state ) # Step 2: Handle option selection elif conversation_state["step"] == "options": if user_input == "1": conversation_state["step"] = "team_leads" # Add numbering to team leads numbered_leads = [f"{i+1}. {lead}" for i, lead in enumerate(team_leads)] return ( "Available Team Leads:\n" + "\n".join(numbered_leads) + "\n\nType the name of a team lead (e.g., 'Neeraj') to see their team members.", conversation_state ) elif user_input in ["2", "3", "4"]: conversation_state["step"] = "initial" return ( f"You selected option {user_input}. This feature is under development.", conversation_state ) else: return ( "Please select a valid option (1, 2, 3, or 4).", conversation_state ) # Step 3: Handle team lead selection elif conversation_state["step"] == "team_leads": if user_input == "neeraj": conversation_state["step"] = "initial" # Reset for next interaction # Add numbering to team members numbered_members = [f"{i+1}. {member}" for i, member in enumerate(neeraj_team)] return ( "Neeraj's Team Members:\n" + "\n".join(numbered_members), conversation_state ) else: conversation_state["step"] = "initial" # Reset if invalid return ( "Please select a valid team lead name (e.g., 'Neeraj'). Type 'hi' to start over.", conversation_state ) # Default response for invalid input return ( "Please type 'hi' to start the conversation.", conversation_state ) # Gradio interface for the chatbot iface = gr.Interface( fn=chatbot, inputs=[ gr.Textbox(lines=2, placeholder="Type 'hi' or select an option..."), gr.State() ], outputs=["text", gr.State()], title="Sathkrutha Solutions Chatbot", description="Type 'hi' to start and select options to interact." ) # Launch the interface if __name__ == "__main__": iface.launch()