Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,3 @@
|
|
1 |
-
# app.py
|
2 |
-
|
3 |
import gradio as gr
|
4 |
from agents.philosopher import PhilosopherAgent
|
5 |
from agents.historian import HistorianAgent
|
@@ -25,17 +23,16 @@ all_agents = [
|
|
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
|
33 |
try:
|
34 |
output = agent.generate([ACPMessage(role="user", content=prompt)])
|
35 |
except Exception as e:
|
36 |
-
output = f"[ERROR
|
37 |
responses[name] = output
|
38 |
-
return responses
|
39 |
|
40 |
iface = gr.Interface(
|
41 |
fn=chat,
|
@@ -49,16 +46,15 @@ iface = gr.Interface(
|
|
49 |
gr.CheckboxGroup(
|
50 |
choices=list(agent_map.keys()),
|
51 |
label="Choose Which Personalities to Ask",
|
52 |
-
value=list(agent_map.keys())
|
53 |
)
|
54 |
],
|
55 |
outputs=gr.JSON(label="Responses"),
|
56 |
title="PerspectiveAI",
|
57 |
description=(
|
58 |
-
""
|
59 |
-
""
|
60 |
-
"
|
61 |
-
"Created by Aymn: [LinkedIn](https://www.linkedin.com/in/aymnsk) · "
|
62 |
"[GitHub](https://github.com/aymnsk) · "
|
63 |
"[Instagram](https://www.instagram.com/damnn_aymn/) · "
|
64 |
"[X](https://x.com/Aymn51414199) · "
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from agents.philosopher import PhilosopherAgent
|
3 |
from agents.historian import HistorianAgent
|
|
|
23 |
|
24 |
agent_map = {agent.name: agent for agent in all_agents}
|
25 |
|
|
|
26 |
def chat(prompt, selected_agents):
|
27 |
responses = {}
|
28 |
for name in selected_agents:
|
29 |
+
agent = agent_map.get(name)
|
30 |
try:
|
31 |
output = agent.generate([ACPMessage(role="user", content=prompt)])
|
32 |
except Exception as e:
|
33 |
+
output = f"[ERROR: {e}]"
|
34 |
responses[name] = output
|
35 |
+
return [responses] # ✅ Wrap in list for Gradio API
|
36 |
|
37 |
iface = gr.Interface(
|
38 |
fn=chat,
|
|
|
46 |
gr.CheckboxGroup(
|
47 |
choices=list(agent_map.keys()),
|
48 |
label="Choose Which Personalities to Ask",
|
49 |
+
value=list(agent_map.keys()) # Default: all agents selected
|
50 |
)
|
51 |
],
|
52 |
outputs=gr.JSON(label="Responses"),
|
53 |
title="PerspectiveAI",
|
54 |
description=(
|
55 |
+
"Ask a question and get responses from different expert minds.\n\n"
|
56 |
+
"Created by Aymn: "
|
57 |
+
"[LinkedIn](https://www.linkedin.com/in/aymnsk) · "
|
|
|
58 |
"[GitHub](https://github.com/aymnsk) · "
|
59 |
"[Instagram](https://www.instagram.com/damnn_aymn/) · "
|
60 |
"[X](https://x.com/Aymn51414199) · "
|