aymnsk commited on
Commit
7337f9c
Β·
verified Β·
1 Parent(s): 74b24d3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
app.py CHANGED
@@ -1,37 +1,36 @@
1
  # app.py
2
 
3
  import gradio as gr
4
- from multi_inference import multi_query as deepseek_query
5
-
6
  from agents.philosopher import PhilosopherAgent
7
  from agents.historian import HistorianAgent
8
  from agents.hacker import HackerAgent
9
  from agents.comedian import ComedianAgent
 
10
 
11
- # Initialize agent classes
12
- philosopher = PhilosopherAgent()
13
- historian = HistorianAgent()
14
- hacker = HackerAgent()
15
- comedian = ComedianAgent()
 
 
16
 
17
- # Chat function
18
  def chat(prompt):
19
  responses = {}
20
- responses["πŸ§™β€β™‚οΈ Philosopher"] = philosopher.run(prompt, deepseek_query)
21
- responses["πŸ‘¨β€πŸ« Historian"] = historian.run(prompt, deepseek_query)
22
- responses["πŸ’» Hacker"] = hacker.run(prompt, deepseek_query)
23
- responses["🎭 Comedian"] = comedian.run(prompt, deepseek_query)
 
 
24
  return responses
25
 
26
- # Gradio UI setup
27
- demo = gr.Interface(
28
  fn=chat,
29
- inputs=gr.Textbox(label="Ask a Question"),
30
- outputs=gr.JSON(label="Agent Responses"),
31
- title="🧠 Multi-Agent AI Chatroom",
32
- description="Ask anything. Each AI agent gives a unique answer!"
33
  )
34
 
35
- # Only launch if run directly (used by Hugging Face too)
36
- if __name__ == "__main__":
37
- demo.launch()
 
1
  # app.py
2
 
3
  import gradio as gr
 
 
4
  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()