Spaces:
Build error
Build error
Update PanelInterface.py
Browse files- PanelInterface.py +9 -20
PanelInterface.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
import logging
|
| 3 |
import json
|
| 4 |
|
|
@@ -7,8 +8,13 @@ from InteractiveInterviewChatbot import *
|
|
| 7 |
# Configure logging
|
| 8 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 9 |
|
| 10 |
-
def build_interface(respondent_agents_dict, processor_llm):
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
def chatbot_interface(message, history=None):
|
| 13 |
if history is None or not isinstance(history, dict):
|
| 14 |
history = {"chat": [], "last_respondent_agent": None}
|
|
@@ -48,13 +54,8 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 48 |
|
| 49 |
logging.info("Building Gradio interface...")
|
| 50 |
|
| 51 |
-
panelists
|
| 52 |
-
|
| 53 |
-
{"ID": "Panellist2", "Name": "Divya", "Description": "17 year old female from Chennai", "Bio": "Divya is a humble, easy-going, and funny individual who enjoys connecting with people and unwinding with reality shows and TV series. She finds joy in cooking new recipes and keeping her room organized, valuing personal time while prioritizing her studies. Inspired by her independent aunt, she aspires to become financially independent through a career in software. Divya practices self-care and values her close relationships with family and friends."},
|
| 54 |
-
{"ID": "Panellist3", "Name": "Rahul", "Description": "17 year old male from Hyderabad", "Bio": "Rahul is a consistent, joyful, and responsible student pursuing a career in Cost and Management Accounting, inspired by his father. He balances his studies with playing indoor cricket and cycling, which he finds peaceful. Rahul dreams of owning a modern home and a luxury car, believing in hard work, planning, and multiple income sources. He prioritizes mental and physical health and values his close-knit family and friends."},
|
| 55 |
-
{"ID": "Panellist4", "Name": "Meena", "Description": "21 year old female from Trichy", "Bio": "Meena is a fearless, kind, friendly, and fun engineering student who has become more reserved over the years. She balances her studies with household responsibilities, finding relaxation and motivation in creating rangoli designs and valuing cleanliness. Meena aspires to secure a good, permanent non-coding job and champions financial independence for women. She maintains a positive outlook, prioritizes her family, and is deeply spiritual."}
|
| 56 |
-
]
|
| 57 |
-
|
| 58 |
bios_js_object = {p["ID"]: p["Bio"] for p in panelists}
|
| 59 |
panel_html = "".join(
|
| 60 |
f"<p><a href='javascript:void(0);' onclick='showModal(event, \"{p['ID']}\")'><b>{p['Name']}</b></a> – {p['Description']}</p>"
|
|
@@ -62,7 +63,6 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 62 |
)
|
| 63 |
|
| 64 |
with gr.Blocks(css="assets/custom.css") as demo:
|
| 65 |
-
logging.info("Adding logo and welcome message...")
|
| 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 |
|
|
@@ -122,7 +122,6 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 122 |
height: 100%;
|
| 123 |
z-index: 999;
|
| 124 |
' onclick='closeModal()'></div>
|
| 125 |
-
|
| 126 |
<div id='topicsModal' style='
|
| 127 |
display: none;
|
| 128 |
position: fixed;
|
|
@@ -148,24 +147,18 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 148 |
height: 100%;
|
| 149 |
z-index: 999;
|
| 150 |
' onclick='closeTopicsModal()'></div>
|
| 151 |
-
|
| 152 |
<script>
|
| 153 |
const bios = {json.dumps(bios_js_object)};
|
| 154 |
-
|
| 155 |
function showModal(event, name) {{
|
| 156 |
event.preventDefault();
|
| 157 |
-
|
| 158 |
const modal = document.getElementById('bioModal');
|
| 159 |
const backdrop = document.getElementById('modalBackdrop');
|
| 160 |
const closeButton = document.getElementById('closeButton');
|
| 161 |
const bioContent = document.getElementById('bioContent');
|
| 162 |
-
|
| 163 |
bioContent.innerText = bios[name] || 'Bio not found.';
|
| 164 |
modal.style.display = 'block';
|
| 165 |
backdrop.style.display = 'block';
|
| 166 |
-
|
| 167 |
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 168 |
-
|
| 169 |
if (prefersDark) {{
|
| 170 |
modal.style.backgroundColor = '#1e1e1e';
|
| 171 |
modal.style.color = '#ffffff';
|
|
@@ -183,19 +176,16 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 183 |
closeButton.style.color = 'white';
|
| 184 |
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
| 185 |
}}
|
| 186 |
-
|
| 187 |
closeButton.style.marginTop = '10px';
|
| 188 |
closeButton.style.padding = '5px 10px';
|
| 189 |
closeButton.style.border = 'none';
|
| 190 |
closeButton.style.borderRadius = '5px';
|
| 191 |
closeButton.style.cursor = 'pointer';
|
| 192 |
}}
|
| 193 |
-
|
| 194 |
function closeModal() {{
|
| 195 |
document.getElementById('bioModal').style.display = 'none';
|
| 196 |
document.getElementById('modalBackdrop').style.display = 'none';
|
| 197 |
}}
|
| 198 |
-
|
| 199 |
function showTopicsModal(event) {{
|
| 200 |
event.preventDefault();
|
| 201 |
const modal = document.getElementById('topicsModal');
|
|
@@ -267,7 +257,6 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 267 |
msg = gr.Textbox(placeholder="Ask your question to the panel here...")
|
| 268 |
history = gr.State([])
|
| 269 |
msg.submit(chatbot_interface, [msg, history], [chatbot, msg, history])
|
| 270 |
-
logging.info("Connected message box to chatbot_interface.")
|
| 271 |
|
| 272 |
with gr.Row(elem_classes="footer-row"):
|
| 273 |
with gr.Column():
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
import logging
|
| 4 |
import json
|
| 5 |
|
|
|
|
| 8 |
# Configure logging
|
| 9 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
| 10 |
|
|
|
|
| 11 |
|
| 12 |
+
def load_panelists_from_excel(file_path="panelist_details.xlsx"):
|
| 13 |
+
df = pd.read_excel(file_path)
|
| 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):
|
| 20 |
history = {"chat": [], "last_respondent_agent": None}
|
|
|
|
| 54 |
|
| 55 |
logging.info("Building Gradio interface...")
|
| 56 |
|
| 57 |
+
# Load panelists from Excel
|
| 58 |
+
panelists = load_panelists_from_excel("panelist_details.xlsx")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
bios_js_object = {p["ID"]: p["Bio"] for p in panelists}
|
| 60 |
panel_html = "".join(
|
| 61 |
f"<p><a href='javascript:void(0);' onclick='showModal(event, \"{p['ID']}\")'><b>{p['Name']}</b></a> – {p['Description']}</p>"
|
|
|
|
| 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 |
|
|
|
|
| 122 |
height: 100%;
|
| 123 |
z-index: 999;
|
| 124 |
' onclick='closeModal()'></div>
|
|
|
|
| 125 |
<div id='topicsModal' style='
|
| 126 |
display: none;
|
| 127 |
position: fixed;
|
|
|
|
| 147 |
height: 100%;
|
| 148 |
z-index: 999;
|
| 149 |
' onclick='closeTopicsModal()'></div>
|
|
|
|
| 150 |
<script>
|
| 151 |
const bios = {json.dumps(bios_js_object)};
|
|
|
|
| 152 |
function showModal(event, name) {{
|
| 153 |
event.preventDefault();
|
|
|
|
| 154 |
const modal = document.getElementById('bioModal');
|
| 155 |
const backdrop = document.getElementById('modalBackdrop');
|
| 156 |
const closeButton = document.getElementById('closeButton');
|
| 157 |
const bioContent = document.getElementById('bioContent');
|
|
|
|
| 158 |
bioContent.innerText = bios[name] || 'Bio not found.';
|
| 159 |
modal.style.display = 'block';
|
| 160 |
backdrop.style.display = 'block';
|
|
|
|
| 161 |
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
|
|
| 162 |
if (prefersDark) {{
|
| 163 |
modal.style.backgroundColor = '#1e1e1e';
|
| 164 |
modal.style.color = '#ffffff';
|
|
|
|
| 176 |
closeButton.style.color = 'white';
|
| 177 |
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
| 178 |
}}
|
|
|
|
| 179 |
closeButton.style.marginTop = '10px';
|
| 180 |
closeButton.style.padding = '5px 10px';
|
| 181 |
closeButton.style.border = 'none';
|
| 182 |
closeButton.style.borderRadius = '5px';
|
| 183 |
closeButton.style.cursor = 'pointer';
|
| 184 |
}}
|
|
|
|
| 185 |
function closeModal() {{
|
| 186 |
document.getElementById('bioModal').style.display = 'none';
|
| 187 |
document.getElementById('modalBackdrop').style.display = 'none';
|
| 188 |
}}
|
|
|
|
| 189 |
function showTopicsModal(event) {{
|
| 190 |
event.preventDefault();
|
| 191 |
const modal = document.getElementById('topicsModal');
|
|
|
|
| 257 |
msg = gr.Textbox(placeholder="Ask your question to the panel here...")
|
| 258 |
history = gr.State([])
|
| 259 |
msg.submit(chatbot_interface, [msg, history], [chatbot, msg, history])
|
|
|
|
| 260 |
|
| 261 |
with gr.Row(elem_classes="footer-row"):
|
| 262 |
with gr.Column():
|