aymnsk commited on
Commit
c363697
Β·
verified Β·
1 Parent(s): 48e5eb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -23
app.py CHANGED
@@ -1,35 +1,40 @@
1
  # app.py
2
 
 
3
  import gradio as gr
4
- # from inference import deepseek_query
5
- multi_inference import multi_query as deepseek_query in app.py
6
 
7
  from agents.philosopher import PhilosopherAgent
8
  from agents.historian import HistorianAgent
9
  from agents.hacker import HackerAgent
10
  from agents.comedian import ComedianAgent
11
 
12
- # Load agents
13
- agents = [
14
- PhilosopherAgent(),
15
- HistorianAgent(),
16
- HackerAgent(),
17
- ComedianAgent()
18
- ]
19
 
20
- # Main chat function
21
  def chat(prompt):
22
- responses = []
23
- for agent in agents:
24
- reply = agent.generate_response(prompt, deepseek_query)
25
- responses.append(f"{agent.name}: {reply.strip()}")
26
- return "\n\n".join(responses)
27
-
28
- # Gradio UI
29
- gr.Interface(
 
30
  fn=chat,
31
- inputs="text",
32
- outputs="text",
33
- title="🧠 Multi-Agent AI Chatroom",
34
- description="Talk to a Philosopher, Historian, Hacker, and Comedian β€” all at once!"
35
- ).launch()
 
 
 
 
 
 
1
  # app.py
2
 
3
+ from fastapi import FastAPI
4
  import gradio as gr
5
+ from multi_inference import multi_query as deepseek_query # βœ… Corrected import
 
6
 
7
  from agents.philosopher import PhilosopherAgent
8
  from agents.historian import HistorianAgent
9
  from agents.hacker import HackerAgent
10
  from agents.comedian import ComedianAgent
11
 
12
+ app = FastAPI()
13
+
14
+ philosopher = PhilosopherAgent()
15
+ historian = HistorianAgent()
16
+ hacker = HackerAgent()
17
+ comedian = ComedianAgent()
18
+
19
 
 
20
  def chat(prompt):
21
+ responses = {}
22
+ responses["πŸ§™β€β™‚οΈ Philosopher"] = philosopher.run(prompt, deepseek_query)
23
+ responses["πŸ‘¨β€πŸ« Historian"] = historian.run(prompt, deepseek_query)
24
+ responses["πŸ’» Hacker"] = hacker.run(prompt, deepseek_query)
25
+ responses["🎭 Comedian"] = comedian.run(prompt, deepseek_query)
26
+ return responses
27
+
28
+
29
+ interface = gr.Interface(
30
  fn=chat,
31
+ inputs=gr.Textbox(label="Ask a Question"),
32
+ outputs=gr.JSON(label="Responses from Agents"),
33
+ title="Multi-Agent AI Chatroom πŸ€–",
34
+ )
35
+
36
+ @app.get("/")
37
+ def read_root():
38
+ return {"message": "Welcome to the Multi-Agent AI Chatroom!"}
39
+
40
+ app = gr.mount_gradio_app(app, interface, path="/chat")