aymnsk commited on
Commit
c80e1d9
Β·
verified Β·
1 Parent(s): deb653c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -11
app.py CHANGED
@@ -9,7 +9,7 @@ from agents.journalist import JournalistAgent
9
  from agents.trader import TraderAgent
10
  from agents.base_agent import ACPMessage
11
 
12
- # βœ… Initialize all 8 agents
13
  all_agents = [
14
  PhilosopherAgent(),
15
  HistorianAgent(),
@@ -21,11 +21,9 @@ all_agents = [
21
  TraderAgent()
22
  ]
23
 
24
- # βœ… Map name to agent
25
  agent_map = {agent.name: agent for agent in all_agents}
26
 
27
-
28
- # βœ… Core chat function for API call
29
  def chat(prompt, selected_agents):
30
  responses = {}
31
  for name in selected_agents:
@@ -35,8 +33,7 @@ def chat(prompt, selected_agents):
35
  except Exception as e:
36
  output = f"[ERROR: {e}]"
37
  responses[name] = output
38
- return [responses] # βœ… Must be inside a list for Gradio JSON API
39
-
40
 
41
  # βœ… Gradio Interface
42
  iface = gr.Interface(
@@ -50,19 +47,18 @@ iface = gr.Interface(
50
  gr.CheckboxGroup(
51
  choices=list(agent_map.keys()),
52
  label="Choose Which Personalities to Ask",
53
- value=list(agent_map.keys()) # βœ… All selected by default
54
  )
55
  ],
56
  outputs=gr.JSON(label="Responses"),
57
  title="PerspectiveAI",
58
- description="Ask a question, get responses from 8 unique AI personas.",
59
  theme=gr.themes.Soft()
60
  )
61
 
62
- # βœ… Launch with API mode enabled (important!)
63
  iface.launch(
64
  server_name="0.0.0.0",
65
  server_port=7860,
66
- show_api=True,
67
- ssr=False # 🚨 This disables SvelteKit SSR and enables API mode
68
  )
 
9
  from agents.trader import TraderAgent
10
  from agents.base_agent import ACPMessage
11
 
12
+ # βœ… Initialize agents
13
  all_agents = [
14
  PhilosopherAgent(),
15
  HistorianAgent(),
 
21
  TraderAgent()
22
  ]
23
 
 
24
  agent_map = {agent.name: agent for agent in all_agents}
25
 
26
+ # βœ… Main chat function
 
27
  def chat(prompt, selected_agents):
28
  responses = {}
29
  for name in selected_agents:
 
33
  except Exception as e:
34
  output = f"[ERROR: {e}]"
35
  responses[name] = output
36
+ return [responses] # βœ… Gradio API requires list
 
37
 
38
  # βœ… Gradio Interface
39
  iface = gr.Interface(
 
47
  gr.CheckboxGroup(
48
  choices=list(agent_map.keys()),
49
  label="Choose Which Personalities to Ask",
50
+ value=list(agent_map.keys())
51
  )
52
  ],
53
  outputs=gr.JSON(label="Responses"),
54
  title="PerspectiveAI",
55
+ description="Ask a question, get 8 expert AI perspectives.",
56
  theme=gr.themes.Soft()
57
  )
58
 
59
+ # βœ… Launch (no ssr anymore!)
60
  iface.launch(
61
  server_name="0.0.0.0",
62
  server_port=7860,
63
+ show_api=True
 
64
  )