|  |  | 
					
						
						|  | """ | 
					
						
						|  | Test the consilium_roundtable component | 
					
						
						|  | """ | 
					
						
						|  |  | 
					
						
						|  | import gradio as gr | 
					
						
						|  | import json | 
					
						
						|  | from gradio_consilium_roundtable import consilium_roundtable | 
					
						
						|  |  | 
					
						
						|  | def test_roundtable(): | 
					
						
						|  | """Test the roundtable with different avatar formats""" | 
					
						
						|  |  | 
					
						
						|  | with gr.Blocks() as demo: | 
					
						
						|  | gr.Markdown("# Testing Consilium Roundtable Component") | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | test_state_emoji = { | 
					
						
						|  | "participants": [ | 
					
						
						|  | {"name": "Ueli", "avatar": "🇨🇭", "message": "Hallo!", "is_thinking": False, "is_current_speaker": True}, | 
					
						
						|  | {"name": "Sepp", "avatar": "🥨", "message": "Servus!", "is_thinking": False, "is_current_speaker": False}, | 
					
						
						|  | {"name": "Karl", "avatar": "🏰", "message": "Grüß Gott!", "is_thinking": False, "is_current_speaker": False}, | 
					
						
						|  | ], | 
					
						
						|  | "current_speaker": "Ueli", | 
					
						
						|  | "round": 1 | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | test_state_no_avatar = { | 
					
						
						|  | "participants": [ | 
					
						
						|  | {"name": "Ueli", "message": "Hallo!", "is_thinking": False, "is_current_speaker": True}, | 
					
						
						|  | {"name": "Sepp", "message": "Servus!", "is_thinking": False, "is_current_speaker": False}, | 
					
						
						|  | {"name": "Karl", "message": "Grüß Gott!", "is_thinking": False, "is_current_speaker": False}, | 
					
						
						|  | ], | 
					
						
						|  | "current_speaker": "Ueli", | 
					
						
						|  | "round": 1 | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | test_state_url = { | 
					
						
						|  | "participants": [ | 
					
						
						|  | {"name": "Ueli", "avatar": "https://via.placeholder.com/50", "message": "Hallo!", "is_thinking": False, "is_current_speaker": True}, | 
					
						
						|  | {"name": "Sepp", "avatar": "https://via.placeholder.com/50", "message": "Servus!", "is_thinking": False, "is_current_speaker": False}, | 
					
						
						|  | ], | 
					
						
						|  | "current_speaker": "Ueli", | 
					
						
						|  | "round": 1 | 
					
						
						|  | } | 
					
						
						|  |  | 
					
						
						|  | gr.Markdown("## Test 1: Emoji Avatars") | 
					
						
						|  | rt1 = consilium_roundtable( | 
					
						
						|  | value=json.dumps(test_state_emoji), | 
					
						
						|  | label="Emoji Avatars" | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  | gr.Markdown("## Test 2: No Avatars") | 
					
						
						|  | rt2 = consilium_roundtable( | 
					
						
						|  | value=json.dumps(test_state_no_avatar), | 
					
						
						|  | label="No Avatars" | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  | gr.Markdown("## Test 3: URL Avatars") | 
					
						
						|  | rt3 = consilium_roundtable( | 
					
						
						|  | value=json.dumps(test_state_url), | 
					
						
						|  | label="URL Avatars" | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  |  | 
					
						
						|  | update_btn = gr.Button("Update States") | 
					
						
						|  |  | 
					
						
						|  | def update_all(): | 
					
						
						|  | new_state = { | 
					
						
						|  | "participants": [ | 
					
						
						|  | {"name": "Test1", "avatar": "🎯", "message": "Updated!", "is_thinking": True, "is_current_speaker": False}, | 
					
						
						|  | {"name": "Test2", "avatar": "🎨", "message": "Changed!", "is_thinking": False, "is_current_speaker": True}, | 
					
						
						|  | ], | 
					
						
						|  | "current_speaker": "Test2", | 
					
						
						|  | "round": 2 | 
					
						
						|  | } | 
					
						
						|  | return json.dumps(new_state), json.dumps(new_state), json.dumps(new_state) | 
					
						
						|  |  | 
					
						
						|  | update_btn.click( | 
					
						
						|  | update_all, | 
					
						
						|  | outputs=[rt1, rt2, rt3] | 
					
						
						|  | ) | 
					
						
						|  |  | 
					
						
						|  | return demo | 
					
						
						|  |  | 
					
						
						|  | if __name__ == "__main__": | 
					
						
						|  | print("Testing consilium_roundtable component...") | 
					
						
						|  | demo = test_roundtable() | 
					
						
						|  | demo.launch() |