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 Anything", | |
lines=4, | |
placeholder="Ask your question here...", | |
elem_id="chat-input" | |
), | |
gr.CheckboxGroup( | |
choices=list(agent_map.keys()), | |
label="Choose Which Personalities to Ask", | |
value=list(agent_map.keys()) | |
) | |
], | |
outputs=gr.JSON(label="Responses"), | |
title="Split Mind: Multi-Personality AI Chatroom", | |
description=( | |
"Engage with multiple distinct AI personas鈥擯hilosopher, Hacker, Scientist, and more." | |
" Each offers a different take on your question." | |
"\n\n" | |
"Created by Aymn: [LinkedIn](https://www.linkedin.com/in/aymnsk) 路 " | |
"[GitHub](https://github.com/aymnsk) 路 " | |
"[Instagram](https://www.instagram.com/damnn_aymn/) 路 " | |
"[X](https://x.com/Aymn51414199) 路 " | |
"[Hugging Face](https://huggingface.co/spaces/aymnsk)" | |
), | |
theme=gr.themes.Soft( | |
primary_hue="blue", | |
secondary_hue="gray", | |
font=[gr.themes.GoogleFont("Inter")], | |
radius_size=gr.themes.sizes.radius_md, | |
spacing_size=gr.themes.sizes.spacing_md | |
), | |
css=""" | |
#chat-input textarea { | |
font-size: 1.1rem; | |
padding: 12px; | |
background: #1e1e2f; | |
color: white; | |
border-radius: 12px; | |
} | |
body { | |
background-color: #111827; | |
color: white; | |
font-family: 'Inter', sans-serif; | |
} | |
.gr-box { | |
border: none; | |
} | |
""" | |
) | |
iface.launch() | |