import gradio as gr from gradio_consilium_roundtable import consilium_roundtable import json def simulate_travel_planning(): """Simulate the travel planning conversation from Turin to Philadelphia""" # Define avatar images for each agent avatar_images = { "User Proxy Agent": "https://upload.wikimedia.org/wikipedia/commons/9/99/Sample_User_Icon.png", "Floor Manager": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/250px-Robot_icon.svg.png", "Convener": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/250px-Robot_icon.svg.png", "Flight Assistant": "https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Plane-solid.svg/330px-Plane-solid.svg.png", "Hotel Assistant": "https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/Noun_Project_house_icon_475319_cc.svg/251px-Noun_Project_house_icon_475319_cc.svg.png", "Rental Car Assistant": "https://upload.wikimedia.org/wikipedia/commons/7/7e/Car_icon_transparent.png", "Philadelphia Activities Assistant": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Masks-theater-solid.svg/330px-Masks-theater-solid.svg.png" } # Initial state - empty, ready for user message initial_state = { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [], "currentSpeaker": None, "thinking": [], "showBubbles": [], "avatarImages": avatar_images } states = [ # 1. User Proxy Agent presents the user's request { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."} ], "currentSpeaker": None, "thinking": [], "showBubbles": ["User Proxy Agent"], "avatarImages": avatar_images }, # 2. Floor Manager coordinates and Convener starts thinking { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."}, {"speaker": "Floor Manager", "text": "🎯 **FLOOR ACTIVATED** - Travel Planning Session\n\nInitiating specialist coordination for Turin → Philadelphia trip..."} ], "currentSpeaker": "Floor Manager", "thinking": ["Convener"], "showBubbles": ["User Proxy Agent"], "avatarImages": avatar_images }, # 2. Convener invites all travel specialists { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."}, {"speaker": "Floor Manager", "text": "🎯 FLOOR ACTIVATED - Travel Planning Session"}, {"speaker": "Convener", "text": "📋 **CONVENING TRAVEL SPECIALISTS**\n\nInviting all specialists to join the floor:\n✈️ Flight Assistant\n🏨 Hotel Assistant\n🚗 Rental Car Assistant\n🎭 Philadelphia Activities Assistant"} ], "currentSpeaker": "Convener", "thinking": ["Flight Assistant", "Hotel Assistant"], "showBubbles": ["User Proxy Agent", "Floor Manager"], "avatarImages": avatar_images }, # 4. Flight Assistant provides flight options { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."}, {"speaker": "Floor Manager", "text": "🎯 FLOOR coordinating travel specialists"}, {"speaker": "Convener", "text": "📋 All travel specialists invited to the floor"}, {"speaker": "Flight Assistant", "text": "✈️ **FLIGHT OPTIONS**\n\nTurin → Philadelphia, December 5:\n• Via Rome: €850 (12h 15m)\n• Via Paris: €920 (13h 10m)\n\nMultiple options available!"} ], "currentSpeaker": "Flight Assistant", "thinking": ["Hotel Assistant", "Rental Car Assistant"], "showBubbles": ["User Proxy Agent", "Floor Manager", "Convener"], "avatarImages": avatar_images }, # 5. Hotel Assistant provides accommodation options { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."}, {"speaker": "Flight Assistant", "text": "✈️ Flight options: €850-920, multiple routes"}, {"speaker": "Hotel Assistant", "text": "🏨 **PHILADELPHIA HOTELS**\n\nDecember 5-10 (5 nights):\n• Center City: $195-280/night\n• Airport area: $140-165/night\n\nGreat options in both areas!"} ], "currentSpeaker": "Hotel Assistant", "thinking": ["Rental Car Assistant", "Philadelphia Activities Assistant"], "showBubbles": ["User Proxy Agent", "Flight Assistant"], "avatarImages": avatar_images }, # 6. Rental Car Assistant provides transportation options { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "I need to make plans for my trip from Turin to Philadelphia from December 5 to December 10. It'll just be me."}, {"speaker": "Flight Assistant", "text": "✈️ Flights: €850-920, multiple routing options"}, {"speaker": "Hotel Assistant", "text": "🏨 Hotels: $140-280/night, city center and airport"}, {"speaker": "Rental Car Assistant", "text": "🚗 **RENTAL CARS**\n\nDecember 5-10 pickup at airport:\n• Economy: $45-52/day\n• Mid-size: $65-68/day\n• Premium: $95/day\n\nAlso excellent public transit available!"} ], "currentSpeaker": "Rental Car Assistant", "thinking": ["Philadelphia Activities Assistant"], "showBubbles": ["Flight Assistant", "Hotel Assistant"], "avatarImages": avatar_images }, # 7. Philadelphia Activities Assistant completes initial planning { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "Sounds good to me!"}, {"speaker": "Flight Assistant", "text": "✈️ Flight options available"}, {"speaker": "Hotel Assistant", "text": "🏨 Hotel accommodations ready"}, {"speaker": "Rental Car Assistant", "text": "🚗 Ground transportation sorted"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎭 **PHILADELPHIA ACTIVITIES**\n\nGreat options for December 5-10:\n• Christmas Village at Love Park\n• Philadelphia Museum of Art\n• Independence Hall & Liberty Bell\n• Reading Terminal Market\n• Amazing cheesesteaks!\n\nPhiladelphia will be wonderful!"} ], "currentSpeaker": "Philadelphia Activities Assistant", "thinking": [], "showBubbles": ["Flight Assistant", "Hotel Assistant", "Rental Car Assistant"], "avatarImages": avatar_images }, # 8. User decides to book the original plan { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "Flight Assistant", "text": "✈️ Flight options available (€850-920)"}, {"speaker": "Hotel Assistant", "text": "🏨 Hotel accommodations ready ($140-280/night)"}, {"speaker": "Rental Car Assistant", "text": "🚗 Ground transportation sorted ($45-95/day)"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎭 Philadelphia activities planned for December 5-10"}, {"speaker": "User Proxy Agent", "text": "Perfect! This all looks great. Please go ahead and book the flights, hotel, and rental car for December 5-10. I'm ready to finalize everything!"} ], "currentSpeaker": "User Proxy Agent", "thinking": ["Philadelphia Activities Assistant"], "showBubbles": ["Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Floor Manager"], "avatarImages": avatar_images }, # 9. Activities Assistant suggests Bocelli concert AFTER user wants to book { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "Perfect! This all looks great. Please go ahead and book the flights, hotel, and rental car for December 5-10. I'm ready to finalize everything!"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎼 **Wait! Before we book...** I just noticed something incredible!\n\nAndrea Bocelli is performing December 11th at Kimmel Center. Since you're from Italy, this could be a once-in-a-lifetime opportunity! Consider staying one extra day?"} ], "currentSpeaker": "Philadelphia Activities Assistant", "thinking": ["Flight Assistant", "Hotel Assistant", "Rental Car Assistant"], "showBubbles": ["User Proxy Agent", "Floor Manager"], "avatarImages": avatar_images }, # 10. Other agents hear Bocelli suggestion and adapt their recommendations { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "Perfect! This all looks great. Please go ahead and book the flights, hotel, and rental car for December 5-10. I'm ready to finalize everything!"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎼 **Bocelli concert December 11th!** Consider extending one day?"}, {"speaker": "Hotel Assistant", "text": "🏨 **Hearing about Bocelli!** 👂\nKimmel area hotel available Dec 11th - same $195 rate. Worth extending!"}, {"speaker": "Flight Assistant", "text": "✈️ **Concert suggestion noted!** 🎵\nMonday Dec 12 flights are €100+ cheaper than Sunday! Extend and save money."}, {"speaker": "Rental Car Assistant", "text": "🚗 **Adapting to concert plan!**\nWeekly rate is better anyway - only +$55 for 2 extra days."} ], "currentSpeaker": None, "thinking": ["User Proxy Agent"], "showBubbles": ["Floor Manager", "Convener", "Philadelphia Activities Assistant"], "avatarImages": avatar_images }, # 11. User says YES to the enhanced plan { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "Philadelphia Activities Assistant", "text": "🎼 Bocelli concert December 11th! Consider extending?"}, {"speaker": "Hotel Assistant", "text": "🏨 Hotel extension available, same rate!"}, {"speaker": "Flight Assistant", "text": "✈️ Monday flights cheaper - extend and save!"}, {"speaker": "Rental Car Assistant", "text": "🚗 Weekly rental rate is better anyway!"}, {"speaker": "User Proxy Agent", "text": "YES! Absolutely! Bocelli from my home country performing in Philadelphia? And I save money on flights? This is perfect - let's extend the trip!"} ], "currentSpeaker": "User Proxy Agent", "thinking": ["Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "showBubbles": ["Floor Manager"], "avatarImages": avatar_images }, # 12. All agents process the enhanced bookings { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "User Proxy Agent", "text": "YES! Absolutely! Bocelli from my home country performing in Philadelphia? And I save money on flights? This is perfect - let's extend the trip!"}, {"speaker": "Flight Assistant", "text": "✈️ **Extended flights booked!**\nTRN→PHL Dec 5, return Dec 12\nTotal: €780 (saved €70!)"}, {"speaker": "Hotel Assistant", "text": "🏨 **Extended stay confirmed!**\nKimmel Center area, Dec 5-12\n7 nights, $1,365 total"}, {"speaker": "Rental Car Assistant", "text": "🚗 **Extended rental confirmed!**\nHonda Accord, Dec 5-12\n7 days, $315 total"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎼 **Bocelli concert booked!**\nDec 11, 8pm, Orchestra section\nConfirmation: KIMMEL-456"} ], "currentSpeaker": None, "thinking": [], "showBubbles": ["User Proxy Agent"], "avatarImages": avatar_images }, # 13. Final celebration and completion { "participants": ["User Proxy Agent", "Floor Manager", "Convener", "Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant"], "messages": [ {"speaker": "Flight Assistant", "text": "✈️ Enhanced flights with savings (€780)"}, {"speaker": "Hotel Assistant", "text": "🏨 Extended stay confirmed ($1,365)"}, {"speaker": "Rental Car Assistant", "text": "🚗 Extended rental confirmed ($315)"}, {"speaker": "Philadelphia Activities Assistant", "text": "🎼 Bocelli concert secured!"}, {"speaker": "Floor Manager", "text": "🎯 **Trip enhanced through collaboration!**\nOriginal: 5 days, ~$2,100\nNew: 7 days + Bocelli, ~$2,650\nAgent teamwork created amazing value! 🎼"}, {"speaker": "User Proxy Agent", "text": "This collaborative planning is incredible! You saved me money on flights and gave me Bocelli - thank you all!"} ], "currentSpeaker": None, "thinking": [], "showBubbles": ["Flight Assistant", "Hotel Assistant", "Rental Car Assistant", "Philadelphia Activities Assistant", "Floor Manager", "User Proxy Agent"], "avatarImages": avatar_images } ] return initial_state, states def update_discussion_state(state_index, states): """Get the next state in the travel planning discussion""" if state_index >= len(states): state_index = 0 return states[state_index], state_index + 1 # Initialize the travel planning discussion initial_state, discussion_states = simulate_travel_planning() with gr.Blocks(title="🗣️ Open Floor Protocol - Roundtable Demo") as demo: gr.Markdown(""" # 🗣️ Open Floor Protocol - Roundtable Demo **Watch AI travel specialists collaborate and adapt!** This simulates a conversation flow using the Open Floor Protocol: a user requests trip planning from Turin to Philadelphia, and specialist agents not only provide recommendations but **listen to each other** and **dynamically improve** the plan together. 🎯 **Key Feature:** Notice how the Activities Assistant discovers a special concert opportunity, and ALL other agents immediately adapt their recommendations based on what they heard - creating a better trip that actually saves money! **Read more about [Open Floor](https://github.com/open-voice-interoperability/openfloor-docs) and the [official Python library](https://github.com/open-voice-interoperability/openfloor-python)** """) # State management state_counter = gr.State(0) # The roundtable component roundtable = consilium_roundtable( label="Shared Conversational Space", show_label=True, label_icon="https://avatars.githubusercontent.com/u/46052400?s=48&v=4", value=initial_state ) with gr.Row(): next_btn = gr.Button("▶️ Next Planning Step", variant="primary") reset_btn = gr.Button("🔄 Reset Planning Session", variant="secondary") # Status display with gr.Row(): status_display = gr.Markdown("**Status:** 🎯 Travel planning floor ready - awaiting user request") # Trip details display with gr.Row(): trip_info = gr.Markdown(""" ### 🧳 Trip Overview **Route:** Turin, Italy → Philadelphia, USA **Dates:** December 5-10, 2024 **Traveler:** Solo trip **Specialists:** Flight, Hotel, Car Rental, Activities """) gr.Markdown(""" Avatar Images from Wikimedia: * User Proxy Agent: https://upload.wikimedia.org/wikipedia/commons/9/99/Sample_User_Icon.png * Floor Manager: https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/250px-Robot_icon.svg.png * Convener: https://upload.wikimedia.org/wikipedia/commons/thumb/0/05/Robot_icon.svg/250px-Robot_icon.svg.png * Flight Assistant: https://upload.wikimedia.org/wikipedia/commons/thumb/e/e4/Plane-solid.svg/330px-Plane-solid.svg.png * Hotel Assistant: https://upload.wikimedia.org/wikipedia/commons/thumb/5/59/Noun_Project_house_icon_475319_cc.svg/251px-Noun_Project_house_icon_475319_cc.svg.png * Rental Car Assistant: https://upload.wikimedia.org/wikipedia/commons/7/7e/Car_icon_transparent.png * Philadelphia Activities Assistant: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Masks-theater-solid.svg/330px-Masks-theater-solid.svg.png """) def next_state(current_counter): new_state, new_counter = update_discussion_state(current_counter, discussion_states) # Convert to proper JSON string json_state = json.dumps(new_state) # Create status message based on current state thinking_list = new_state.get("thinking", []) current_speaker = new_state.get("currentSpeaker") # Custom status messages for travel planning context if current_counter == 0: status = "**Status:** 🎯 Floor Manager activating coordination protocols" elif current_counter == 1: status = "**Status:** 📋 Convener inviting specialist agents to the floor" elif current_counter == 6: status = "**Status:** 📝 User decides to book original 5-day plan..." elif current_counter == 7: status = "**Status:** 🎼 Activities Assistant makes last-minute discovery!" elif current_counter == 8: status = "**Status:** 🤝 All agents adapting after hearing concert suggestion" elif current_counter == 9: status = "**Status:** ✅ User says YES to the enhanced plan!" elif current_counter == 10: status = "**Status:** 📋 All agents processing enhanced bookings..." elif current_counter == 11: status = "**Status:** 🎼 User celebrating collaborative success - conversation complete!" elif thinking_list: agents = ', '.join(thinking_list) status = f"**Status:** 💭 {agents} {'is' if len(thinking_list) == 1 else 'are'} preparing recommendations..." elif current_speaker: status = f"**Status:** 🎤 {current_speaker} has the floor..." else: status = "**Status:** 🎯 Travel coordination in progress on the shared floor" return json_state, new_counter, status def reset_discussion(): json_state = json.dumps(initial_state) return json_state, 0, "**Status:** 🎯 Travel planning floor reset - ready for new requests" next_btn.click( next_state, inputs=[state_counter], outputs=[roundtable, state_counter, status_display] ) reset_btn.click( reset_discussion, outputs=[roundtable, state_counter, status_display] ) if __name__ == "__main__": demo.launch()