The roundtable for artificial minds
Project description
tags: [gradio-custom-component, custom-component-track, roundtable, consilium] title: gradio_consilium_roundtable short_description: The roundtable for artificial minds colorFrom: blue colorTo: yellow sdk: gradio pinned: false
gradio_consilium_roundtable
The roundtable for artificial minds
Installation
pip install gradio_consilium_roundtable
Usage
import gradio as gr
from gradio_consilium_roundtable import consilium_roundtable
import time
import random
import json
def simulate_discussion():
"""Simulate a live AI discussion"""
# Initial state - everyone ready
initial_state = {
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [],
"currentSpeaker": None,
"thinking": []
}
# Discussion states to cycle through
states = [
# 1. Claude starts thinking
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [],
"currentSpeaker": None,
"thinking": ["Claude"]
},
# 2. Claude responds
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [
{"speaker": "Claude", "text": "I think we should approach this problem from multiple angles. Let me analyze the key factors..."}
],
"currentSpeaker": "Claude",
"thinking": []
},
# 3. GPT-4 and Search start thinking
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [
{"speaker": "Claude", "text": "I think we should approach this problem from multiple angles. Let me analyze the key factors..."}
],
"currentSpeaker": None,
"thinking": ["GPT-4", "Search"]
},
# 4. GPT-4 responds
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [
{"speaker": "Claude", "text": "I think we should approach this problem from multiple angles. Let me analyze the key factors..."},
{"speaker": "GPT-4", "text": "That's a solid foundation, Claude. However, I'd like to add some statistical analysis to your reasoning..."}
],
"currentSpeaker": "GPT-4",
"thinking": []
},
# 5. Multiple models thinking
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [
{"speaker": "Claude", "text": "I think we should approach this problem from multiple angles. Let me analyze the key factors..."},
{"speaker": "GPT-4", "text": "That's a solid foundation, Claude. However, I'd like to add some statistical analysis to your reasoning..."}
],
"currentSpeaker": None,
"thinking": ["Mistral", "Gemini"]
},
# 6. Search agent responds with data
{
"participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
"messages": [
{"speaker": "Claude", "text": "I think we should approach this problem from multiple angles. Let me analyze the key factors..."},
{"speaker": "GPT-4", "text": "That's a solid foundation, Claude. However, I'd like to add some statistical analysis to your reasoning..."},
{"speaker": "Search", "text": "I found relevant data: According to recent studies, 73% of experts agree with this approach..."}
],
"currentSpeaker": "Search",
"thinking": []
}
]
return initial_state, states
def update_discussion_state(state_index, states):
"""Get the next state in the discussion"""
if state_index >= len(states):
state_index = 0
return states[state_index], state_index + 1
# Initialize the discussion
initial_state, discussion_states = simulate_discussion()
with gr.Blocks() as demo:
gr.Markdown("# 🎭 Consilium Roundtable Demo")
gr.Markdown("**Watch the AI discussion unfold!** Click 'Next State' to see different phases of the discussion.")
# State management
state_counter = gr.State(0)
# The roundtable component
roundtable = consilium_roundtable(
label="AI Discussion Roundtable",
show_label=True,
value=initial_state
)
with gr.Row():
next_btn = gr.Button("▶️ Next Discussion State", variant="primary")
reset_btn = gr.Button("🔄 Reset Discussion", variant="secondary")
# Status display
with gr.Row():
status_display = gr.Markdown("**Status:** Discussion ready to begin")
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
thinking_list = new_state.get("thinking", [])
current_speaker = new_state.get("currentSpeaker")
if thinking_list:
status = f"**Status:** {', '.join(thinking_list)} {'is' if len(thinking_list) == 1 else 'are'} thinking..."
elif current_speaker:
status = f"**Status:** {current_speaker} is responding..."
else:
status = "**Status:** Discussion in progress..."
return json_state, new_counter, status
def reset_discussion():
json_state = json.dumps(initial_state)
return json_state, 0, "**Status:** Discussion reset - ready to begin"
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()
consilium_roundtable
Initialization
| name | type | default | description |
|---|---|---|---|
value |
str | Callable | None
|
None |
JSON string containing the discussion state with participants, messages, current speaker, and thinking states. If a function is provided, it will be called each time the app loads to set the initial value. |
placeholder |
str | None
|
None |
Not used in this component (roundtable displays participants instead). |
label |
str | I18nData | None
|
None |
The label for this component, displayed above the roundtable. |
every |
Timer | float | None
|
None |
Continuously calls `value` to recalculate it if `value` is a function (useful for live discussion updates). |
inputs |
Component | Sequence[Component] | set[Component] | None
|
None |
Components that are used as inputs to calculate `value` if `value` is a function. |
show_label |
bool | None
|
None |
If True, will display the label above the roundtable. |
scale |
int | None
|
None |
Relative size compared to adjacent components in a Row or Blocks layout. |
min_width |
int
|
600 |
Minimum pixel width for the component (default 600px for proper roundtable display). |
interactive |
bool | None
|
None |
If True, avatars can be clicked to show speech bubbles manually. |
visible |
bool
|
True |
If False, component will be hidden. |
rtl |
bool
|
False |
Not used in this component. |
elem_id |
str | None
|
None |
An optional string assigned as the id of this component in the HTML DOM. |
elem_classes |
list[str] | str | None
|
None |
Optional list of CSS classes assigned to this component. |
render |
bool
|
True |
If False, component will not be rendered in the Blocks context initially. |
key |
int | str | tuple[int | str, ...] | None
|
None |
For gr.render() - components with the same key are treated as the same component across re-renders. |
preserved_by_key |
list[str] | str | None
|
"value" |
Parameters preserved across re-renders when using keys. |
Events
| name | description |
|---|---|
change |
Triggered when the value of the consilium_roundtable changes either because of user input (e.g. a user types in a textbox) OR because of a function update (e.g. an image receives a value from the output of an event trigger). See .input() for a listener that is only triggered by user input. |
input |
This listener is triggered when the user changes the value of the consilium_roundtable. |
submit |
This listener is triggered when the user presses the Enter key while the consilium_roundtable is focused. |
User function
The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).
- When used as an Input, the component only impacts the input signature of the user function.
- When used as an output, the component only impacts the return signature of the user function.
The code snippet below is accurate in cases where the component is used as both an input and an output.
- As output: Is passed, passes the JSON string value for processing.
- As input: Should return, discussion state as dict or JSON string containing:.
def predict(
value: str | None
) -> Any:
return value
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradio_consilium_roundtable-0.0.1.tar.gz.
File metadata
- Download URL: gradio_consilium_roundtable-0.0.1.tar.gz
- Upload date:
- Size: 80.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0695439c8debd0de09f6d71139c0141af366e8784991b340ddc8cdf9f6d143db
|
|
| MD5 |
ab962064cbf9f11e7645bd0233600879
|
|
| BLAKE2b-256 |
cff2bd62c71d048e0b9d8c47d452cd4e320ad2523a41a70c1bf38535d25fe774
|
File details
Details for the file gradio_consilium_roundtable-0.0.1-py3-none-any.whl.
File metadata
- Download URL: gradio_consilium_roundtable-0.0.1-py3-none-any.whl
- Upload date:
- Size: 20.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6d17d6e4cd8cfff2ae4cc55d0a1fa94d334ed145286409c629e8fb7fce9437b
|
|
| MD5 |
f5f6fb37470b426db0b2dd7d13be3679
|
|
| BLAKE2b-256 |
be04dec7c7517088783cc2d636b120cbf78ac59e32e78529c0a853c9cd4756cc
|