Spaces:
Sleeping
Sleeping
# app.py | |
import gradio as gr | |
from agents.philosopher import PhilosopherAgent | |
from agents.historian import HistorianAgent | |
from agents.hacker import HackerAgent | |
from agents.comedian import ComedianAgent | |
from agents.lawyer import LawyerAgent | |
from agents.scientist import ScientistAgent | |
from agents.journalist import JournalistAgent | |
from agents.trader import TraderAgent | |
from agents.base_agent import ACPMessage | |
# Initialize all agents | |
all_agents = [ | |
PhilosopherAgent(), | |
HistorianAgent(), | |
HackerAgent(), | |
ComedianAgent(), | |
LawyerAgent(), | |
ScientistAgent(), | |
JournalistAgent(), | |
TraderAgent() | |
] | |
agent_map = {agent.name: agent for agent in all_agents} | |
def chat(prompt, selected_agents): | |
responses = {} | |
for name in selected_agents: | |
agent = agent_map[name] | |
try: | |
output = agent.generate([ACPMessage(role="user", content=prompt)]) | |
except Exception as e: | |
output = f"[ERROR] {e}" | |
responses[name] = output | |
return responses | |
iface = gr.Interface( | |
fn=chat, | |
inputs=[ | |
gr.Textbox(label="Ask Something", lines=3, placeholder="Type your message here..."), | |
gr.CheckboxGroup( | |
choices=list(agent_map.keys()), | |
label="Select Agents", | |
value=list(agent_map.keys()) # Default: all selected | |
) | |
], | |
outputs="json", | |
title="🧠 Multi-Agent Chatroom (Groq Edition)", | |
description="Talk to multiple AI agents at once, each with a unique personality and role. Powered by Groq." | |
) | |
iface.launch() | |