aymnsk commited on
Commit
b9b41a6
·
verified ·
1 Parent(s): 86f2250

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -9
app.py CHANGED
@@ -5,32 +5,51 @@ from agents.philosopher import PhilosopherAgent
5
  from agents.historian import HistorianAgent
6
  from agents.hacker import HackerAgent
7
  from agents.comedian import ComedianAgent
 
 
 
 
8
  from agents.base_agent import ACPMessage
9
 
10
- # Instantiate agents
11
- agents = [
12
  PhilosopherAgent(),
13
  HistorianAgent(),
14
  HackerAgent(),
15
- ComedianAgent()
 
 
 
 
16
  ]
17
 
18
- def chat(prompt):
 
 
 
19
  responses = {}
20
- for agent in agents:
 
21
  try:
22
  output = agent.generate([ACPMessage(role="user", content=prompt)])
23
  except Exception as e:
24
  output = f"[ERROR] {e}"
25
- responses[agent.name] = output
26
  return responses
27
 
28
  iface = gr.Interface(
29
  fn=chat,
30
- inputs=gr.Textbox(label="Ask Something", lines=3, placeholder="Type your message here..."),
 
 
 
 
 
 
 
31
  outputs="json",
32
- title="🤖 Multi-Agent Chatroom (Groq Edition)",
33
- description="Talk to 4 AI agents at once using free Groq-powered LLaMA3 API."
34
  )
35
 
36
  iface.launch()
 
5
  from agents.historian import HistorianAgent
6
  from agents.hacker import HackerAgent
7
  from agents.comedian import ComedianAgent
8
+ from agents.lawyer import LawyerAgent
9
+ from agents.scientist import ScientistAgent
10
+ from agents.journalist import JournalistAgent
11
+ from agents.trader import TraderAgent
12
  from agents.base_agent import ACPMessage
13
 
14
+ # Initialize all agents
15
+ all_agents = [
16
  PhilosopherAgent(),
17
  HistorianAgent(),
18
  HackerAgent(),
19
+ ComedianAgent(),
20
+ LawyerAgent(),
21
+ ScientistAgent(),
22
+ JournalistAgent(),
23
+ TraderAgent()
24
  ]
25
 
26
+ agent_map = {agent.name: agent for agent in all_agents}
27
+
28
+
29
+ def chat(prompt, selected_agents):
30
  responses = {}
31
+ for name in selected_agents:
32
+ agent = agent_map[name]
33
  try:
34
  output = agent.generate([ACPMessage(role="user", content=prompt)])
35
  except Exception as e:
36
  output = f"[ERROR] {e}"
37
+ responses[name] = output
38
  return responses
39
 
40
  iface = gr.Interface(
41
  fn=chat,
42
+ inputs=[
43
+ gr.Textbox(label="Ask Something", lines=3, placeholder="Type your message here..."),
44
+ gr.CheckboxGroup(
45
+ choices=list(agent_map.keys()),
46
+ label="Select Agents",
47
+ value=list(agent_map.keys()) # Default: all selected
48
+ )
49
+ ],
50
  outputs="json",
51
+ title="🧠 Multi-Agent Chatroom (Groq Edition)",
52
+ description="Talk to multiple AI agents at once, each with a unique personality and role. Powered by Groq."
53
  )
54
 
55
  iface.launch()