Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 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] # β
|
| 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())
|
| 54 |
)
|
| 55 |
],
|
| 56 |
outputs=gr.JSON(label="Responses"),
|
| 57 |
title="PerspectiveAI",
|
| 58 |
-
description="Ask a question, get
|
| 59 |
theme=gr.themes.Soft()
|
| 60 |
)
|
| 61 |
|
| 62 |
-
# β
Launch
|
| 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 |
)
|