Skip to main content

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 app_file: space.py

gradio_consilium_roundtable

PyPI - Version

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": [],
        "showBubbles": []
    }

    states = [
        # 1. Claude starts thinking
        {
            "participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
            "messages": [],
            "currentSpeaker": None,
            "thinking": ["Claude"],
            "showBubbles": []
        },
        
        # 32. GPT-4 and Search start thinking - Claude's bubble should stay visible
        {
            "participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
            "messages": [
                {"speaker": "Claude", "text": "This is a very long response that should demonstrate the scrolling functionality. I'm going to explain multiple points in detail. First, we need to consider the primary factors that influence this decision. Second, we must evaluate the potential risks and benefits. Third, there are several implementation strategies we could pursue. Fourth, the timeline and resource allocation are critical considerations. Finally, we should establish clear success metrics and monitoring procedures to ensure we achieve our objectives effectively."}
            ],
            "currentSpeaker": None,
            "thinking": ["GPT-4", "Search"],
            "showBubbles": ["Claude"]  # KEEP CLAUDE'S BUBBLE VISIBLE
        },
        
        # 3. GPT-4 responds - both Claude and GPT-4 bubbles visible
        {
            "participants": ["Claude", "GPT-4", "Mistral", "Gemini", "Search"],
            "messages": [
                {"speaker": "Claude", "text": "Here's my analysis:\n\n**Key Points:**\n- Point 1\n- Point 2\n\n`Code example` and [link](https://example.com)\n\n> This is a blockquote"},
                {"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": [],
            "showBubbles": ["Claude"]  # CLAUDE'S BUBBLE STILL VISIBLE
        },
        
        # 4. Multiple models thinking - previous responses stay visible
        {
            "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"],
            "showBubbles": ["Claude", "GPT-4"]  # BOTH PREVIOUS RESPONSES VISIBLE
        },
        
        # 5. Search agent responds with data - all previous responses visible
        {
            "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": [],
            "showBubbles": ["Claude", "GPT-4"]  # PREVIOUS RESPONSES STAY VISIBLE
        }
    ]
    
    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

gradio_consilium_roundtable-0.0.2.tar.gz (81.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_consilium_roundtable-0.0.2-py3-none-any.whl (21.3 kB view details)

Uploaded Python 3

File details

Details for the file gradio_consilium_roundtable-0.0.2.tar.gz.

File metadata

File hashes

Hashes for gradio_consilium_roundtable-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4b526719c71250807c18d3c7d6a7b9d2292d60dff7290581c88bb060b5454af9
MD5 0ef3366bd03a726bb22ed8496a0353e3
BLAKE2b-256 4bb1792b0ec472c31e5199483c1950c9ee13972aaa162941f76fa2eb35288f3d

See more details on using hashes here.

File details

Details for the file gradio_consilium_roundtable-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_consilium_roundtable-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ba1d17fd16c465bbeaa7e92ae6d21c41183d734aefd32feb695452d39ccc48c2
MD5 d47e44556a3138997165cdf827fb2f07
BLAKE2b-256 eb928bd0db1be87aff0fc717cc8502c484ffa332243ddbc1de0f1cf992c88636

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page