Spaces:
Sleeping
Sleeping
File size: 21,994 Bytes
f5ee71d 8f2fa8b f5ee71d bfac33a f5ee71d 6761496 f5ee71d 6761496 f5ee71d 6761496 f5ee71d 6761496 f5ee71d 6761496 c985992 f5ee71d 0523f3a f5ee71d bfac33a f5ee71d 6761496 0523f3a c985992 f5ee71d 6761496 c985992 f5ee71d 6761496 c985992 f5ee71d 0523f3a f5ee71d 6761496 c985992 f5ee71d c985992 f5ee71d 6761496 c985992 f5ee71d c985992 f5ee71d c985992 6761496 f5ee71d c985992 f5ee71d 6588a35 138a69d c985992 138a69d 6761496 c985992 6761496 c985992 0523f3a c985992 6761496 138a69d c985992 138a69d 432f3b2 c985992 138a69d aea17da 138a69d c985992 138a69d c985992 6761496 138a69d 6761496 138a69d 6761496 138a69d f5ee71d ef1490e c985992 ef1490e f5ee71d 8bf473b f5ee71d 8bf473b f5ee71d 8f2fa8b f5ee71d bfac33a f5ee71d bfac33a c985992 bfac33a c985992 bfac33a c985992 bfac33a c985992 bfac33a c985992 bfac33a c985992 f5ee71d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
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() |