Spaces:
Build error
Build error
Update PanelInterface.py
Browse files- PanelInterface.py +16 -59
PanelInterface.py
CHANGED
|
@@ -14,6 +14,11 @@ def load_panelists_from_excel(file_path="config/genzheroes/panelist_details.xlsx
|
|
| 14 |
return df.to_dict(orient="records")
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def build_interface(respondent_agents_dict, processor_llm):
|
| 18 |
def chatbot_interface(message, history=None):
|
| 19 |
if history is None or not isinstance(history, dict):
|
|
@@ -62,40 +67,23 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 62 |
for p in panelists
|
| 63 |
)
|
| 64 |
|
|
|
|
|
|
|
|
|
|
| 65 |
with gr.Blocks(css="assets/custom.css") as demo:
|
| 66 |
with gr.Row(elem_classes="logo-row"):
|
| 67 |
gr.Image("static/predata-logo.png", height=300, width=600, show_label=False, elem_id="logo")
|
| 68 |
|
| 69 |
with gr.Row(elem_classes="welcome-section"):
|
| 70 |
with gr.Column():
|
| 71 |
-
gr.Markdown(""
|
| 72 |
-
# Welcome to PreData.AI's Market Research Panel [Demo]
|
| 73 |
-
## Introducing our AI-powered panel:
|
| 74 |
-
- This panel consists of some **AI-powered agents** who will answer your questions.
|
| 75 |
-
- Ask them a question by **typing into the input box below**.
|
| 76 |
-
- Feel free to address a question to a **specific panellist**.
|
| 77 |
-
- If no panellist is specified, all of the panellists will respond.
|
| 78 |
-
""")
|
| 79 |
|
| 80 |
with gr.Row():
|
| 81 |
with gr.Column(scale=1, elem_classes="bio-section"):
|
| 82 |
-
gr.HTML(""
|
| 83 |
-
|
| 84 |
-
<h2>Recommended Topics for Discussion</h2>
|
| 85 |
-
<ul>
|
| 86 |
-
<li>Our agents have been trained exclusively on topics relevant to youth attitudes, behaviours, and lifestyle preferences.</li>
|
| 87 |
-
<li>To ensure meaningful and respectful conversations, please do not ask inappropriate, offensive, or out-of-scope questions.</li>
|
| 88 |
-
<li><a href='javascript:void(0);' onclick='showTopicsModal(event)' style='cursor: pointer; color: #007bff; text-decoration: underline;'><b>Click here for a list of permitted and prohibited topics.</b></a></li>
|
| 89 |
-
</ul>
|
| 90 |
-
</div>
|
| 91 |
-
""")
|
| 92 |
|
| 93 |
gr.HTML(f"""
|
| 94 |
-
<div style='text-align: left;'>
|
| 95 |
-
<h2>Our Panellists</h2>
|
| 96 |
-
<i>Click on our panellist's name so they can introduce themselves</i><br>
|
| 97 |
-
{panel_html}
|
| 98 |
-
</div>
|
| 99 |
<div id='bioModal' style='
|
| 100 |
display: none;
|
| 101 |
position: fixed;
|
|
@@ -135,7 +123,7 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 135 |
overflow-y: visible;
|
| 136 |
border-radius: 10px;
|
| 137 |
'>
|
| 138 |
-
<p id='topicsContent'>
|
| 139 |
<button onclick='closeTopicsModal()' id='closeTopicsButton'>Close</button>
|
| 140 |
</div>
|
| 141 |
<div id='topicsBackdrop' style='
|
|
@@ -192,32 +180,7 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 192 |
const backdrop = document.getElementById('topicsBackdrop');
|
| 193 |
const closeButton = document.getElementById('closeTopicsButton');
|
| 194 |
const topicsContent = document.getElementById('topicsContent');
|
| 195 |
-
topicsContent.innerHTML = `
|
| 196 |
-
<b>Permitted Topics:</b><br>
|
| 197 |
-
<ul>
|
| 198 |
-
<li>Demographics (age, location, family, education)</li>
|
| 199 |
-
<li>Values & beliefs (responsibility, independence, equality, spirituality, mental health)</li>
|
| 200 |
-
<li>Career goals & aspirations</li>
|
| 201 |
-
<li>Influences & role models</li>
|
| 202 |
-
<li>Interests & hobbies (sports, music, cooking, gaming, travel)</li>
|
| 203 |
-
<li>Health & lifestyle (fitness, diet, skincare, self-care)</li>
|
| 204 |
-
<li>Social media & technology habits</li>
|
| 205 |
-
<li>Personal relationships (family, friends, romantic)</li>
|
| 206 |
-
<li>Future plans & personal growth</li>
|
| 207 |
-
<li>Social issues (gender equality, tradition vs modernity)</li>
|
| 208 |
-
<li>Lifestyle preferences (food, fashion, spending, culture)</li>
|
| 209 |
-
</ul>
|
| 210 |
-
<b>Prohibited Topics:</b><br>
|
| 211 |
-
<ul>
|
| 212 |
-
<li>Hate speech, discrimination, harassment</li>
|
| 213 |
-
<li>Sexually explicit or violent content</li>
|
| 214 |
-
<li>Religious extremism or proselytising</li>
|
| 215 |
-
<li>Politically sensitive content (politicians, elections, policies)</li>
|
| 216 |
-
<li>Extremist ideologies or hate groups</li>
|
| 217 |
-
<li>Technical or academic topics outside personal lifestyle</li>
|
| 218 |
-
<li>News or controversial current events</li>
|
| 219 |
-
</ul>
|
| 220 |
-
`;
|
| 221 |
modal.style.display = 'block';
|
| 222 |
backdrop.style.display = 'block';
|
| 223 |
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
@@ -244,7 +207,6 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 244 |
closeButton.style.borderRadius = '5px';
|
| 245 |
closeButton.style.cursor = 'pointer';
|
| 246 |
}}
|
| 247 |
-
|
| 248 |
function closeTopicsModal() {{
|
| 249 |
document.getElementById('topicsModal').style.display = 'none';
|
| 250 |
document.getElementById('topicsBackdrop').style.display = 'none';
|
|
@@ -260,13 +222,8 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 260 |
|
| 261 |
with gr.Row(elem_classes="footer-row"):
|
| 262 |
with gr.Column():
|
| 263 |
-
gr.Markdown(""
|
| 264 |
-
<div style="text-align: center; margin-top: 20px; font-size: 14px;">
|
| 265 |
-
© 2025 PreData.AI - All rights reserved. | Contact us at
|
| 266 |
-
<a href="mailto:hello@predata.ai" onclick="event.stopPropagation();"
|
| 267 |
-
style="text-decoration: none; color: #007bff;">hello@predata.ai</a>
|
| 268 |
-
</div>
|
| 269 |
-
""")
|
| 270 |
|
| 271 |
logging.info("Interface build complete.")
|
| 272 |
-
|
|
|
|
|
|
| 14 |
return df.to_dict(orient="records")
|
| 15 |
|
| 16 |
|
| 17 |
+
def load_ui_texts_from_excel(file_path="config/ui_texts.xlsx"):
|
| 18 |
+
df = pd.read_excel(file_path)
|
| 19 |
+
return dict(zip(df['key'], df['value']))
|
| 20 |
+
|
| 21 |
+
|
| 22 |
def build_interface(respondent_agents_dict, processor_llm):
|
| 23 |
def chatbot_interface(message, history=None):
|
| 24 |
if history is None or not isinstance(history, dict):
|
|
|
|
| 67 |
for p in panelists
|
| 68 |
)
|
| 69 |
|
| 70 |
+
# Load UI texts from Excel
|
| 71 |
+
ui_texts = load_ui_texts_from_excel("config/ui_texts.xlsx")
|
| 72 |
+
|
| 73 |
with gr.Blocks(css="assets/custom.css") as demo:
|
| 74 |
with gr.Row(elem_classes="logo-row"):
|
| 75 |
gr.Image("static/predata-logo.png", height=300, width=600, show_label=False, elem_id="logo")
|
| 76 |
|
| 77 |
with gr.Row(elem_classes="welcome-section"):
|
| 78 |
with gr.Column():
|
| 79 |
+
gr.Markdown(ui_texts["welcome_markdown"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
with gr.Row():
|
| 82 |
with gr.Column(scale=1, elem_classes="bio-section"):
|
| 83 |
+
gr.HTML(ui_texts["recommended_topics_html"])
|
| 84 |
+
gr.HTML(ui_texts["panelist_intro_html"].replace("{panel_html}", panel_html))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
gr.HTML(f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 87 |
<div id='bioModal' style='
|
| 88 |
display: none;
|
| 89 |
position: fixed;
|
|
|
|
| 123 |
overflow-y: visible;
|
| 124 |
border-radius: 10px;
|
| 125 |
'>
|
| 126 |
+
<p id='topicsContent'></p>
|
| 127 |
<button onclick='closeTopicsModal()' id='closeTopicsButton'>Close</button>
|
| 128 |
</div>
|
| 129 |
<div id='topicsBackdrop' style='
|
|
|
|
| 180 |
const backdrop = document.getElementById('topicsBackdrop');
|
| 181 |
const closeButton = document.getElementById('closeTopicsButton');
|
| 182 |
const topicsContent = document.getElementById('topicsContent');
|
| 183 |
+
topicsContent.innerHTML = `${ui_texts["permitted_topics_html"]}${ui_texts["prohibited_topics_html"]}`;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 184 |
modal.style.display = 'block';
|
| 185 |
backdrop.style.display = 'block';
|
| 186 |
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
|
|
| 207 |
closeButton.style.borderRadius = '5px';
|
| 208 |
closeButton.style.cursor = 'pointer';
|
| 209 |
}}
|
|
|
|
| 210 |
function closeTopicsModal() {{
|
| 211 |
document.getElementById('topicsModal').style.display = 'none';
|
| 212 |
document.getElementById('topicsBackdrop').style.display = 'none';
|
|
|
|
| 222 |
|
| 223 |
with gr.Row(elem_classes="footer-row"):
|
| 224 |
with gr.Column():
|
| 225 |
+
gr.Markdown(ui_texts["footer_html"])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
logging.info("Interface build complete.")
|
| 228 |
+
modal.style.border = '1px solid #444';
|
| 229 |
+
|