Spaces:
Build error
Build error
Update PanelInterface.py
Browse files- PanelInterface.py +80 -25
PanelInterface.py
CHANGED
|
@@ -93,34 +93,89 @@ def build_interface(respondent_agents_dict, processor_llm):
|
|
| 93 |
with gr.Column():
|
| 94 |
gr.Markdown(ui_texts["footer_html"])
|
| 95 |
|
| 96 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
<script>
|
| 98 |
-
|
|
|
|
| 99 |
event.preventDefault();
|
| 100 |
-
const
|
| 101 |
-
const
|
| 102 |
-
|
| 103 |
-
const
|
| 104 |
-
|
| 105 |
-
modal.style.
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
</script>
|
| 122 |
-
"""
|
| 123 |
-
|
| 124 |
gr.HTML(modal_script)
|
| 125 |
|
| 126 |
logging.info("Interface build complete.")
|
|
|
|
| 93 |
with gr.Column():
|
| 94 |
gr.Markdown(ui_texts["footer_html"])
|
| 95 |
|
| 96 |
+
# Inject the bios object for the modal JS
|
| 97 |
+
bios_json = json.dumps(bios_js_object)
|
| 98 |
+
permitted_topics = ui_texts.get("permitted_topics_html", "")
|
| 99 |
+
prohibited_topics = ui_texts.get("prohibited_topics_html", "")
|
| 100 |
+
modal_script = f"""
|
| 101 |
<script>
|
| 102 |
+
const bios = {bios_json};
|
| 103 |
+
function showModal(event, name) {{
|
| 104 |
event.preventDefault();
|
| 105 |
+
const modal = document.getElementById('bioModal');
|
| 106 |
+
const backdrop = document.getElementById('modalBackdrop');
|
| 107 |
+
const closeButton = document.getElementById('closeButton');
|
| 108 |
+
const bioContent = document.getElementById('bioContent');
|
| 109 |
+
bioContent.innerHTML = bios[name] || 'Bio not found.';
|
| 110 |
+
modal.style.display = 'block';
|
| 111 |
+
backdrop.style.display = 'block';
|
| 112 |
+
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 113 |
+
if (prefersDark) {{
|
| 114 |
+
modal.style.backgroundColor = '#1e1e1e';
|
| 115 |
+
modal.style.color = '#ffffff';
|
| 116 |
+
modal.style.border = '1px solid #444';
|
| 117 |
+
modal.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.8)';
|
| 118 |
+
closeButton.style.backgroundColor = '#007bff';
|
| 119 |
+
closeButton.style.color = 'white';
|
| 120 |
+
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
|
| 121 |
+
}} else {{
|
| 122 |
+
modal.style.backgroundColor = '#ffffff';
|
| 123 |
+
modal.style.color = '#000000';
|
| 124 |
+
modal.style.border = '1px solid #ccc';
|
| 125 |
+
modal.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.2)';
|
| 126 |
+
closeButton.style.backgroundColor = '#007bff';
|
| 127 |
+
closeButton.style.color = 'white';
|
| 128 |
+
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
| 129 |
+
}}
|
| 130 |
+
closeButton.style.marginTop = '10px';
|
| 131 |
+
closeButton.style.padding = '5px 10px';
|
| 132 |
+
closeButton.style.border = 'none';
|
| 133 |
+
closeButton.style.borderRadius = '5px';
|
| 134 |
+
closeButton.style.cursor = 'pointer';
|
| 135 |
+
}}
|
| 136 |
+
function closeModal() {{
|
| 137 |
+
document.getElementById('bioModal').style.display = 'none';
|
| 138 |
+
document.getElementById('modalBackdrop').style.display = 'none';
|
| 139 |
+
}}
|
| 140 |
+
function showTopicsModal(event) {{
|
| 141 |
+
event.preventDefault();
|
| 142 |
+
const modal = document.getElementById('topicsModal');
|
| 143 |
+
const backdrop = document.getElementById('topicsBackdrop');
|
| 144 |
+
const closeButton = document.getElementById('closeTopicsButton');
|
| 145 |
+
const topicsContent = document.getElementById('topicsContent');
|
| 146 |
+
topicsContent.innerHTML = `{permitted_topics}{prohibited_topics}`;
|
| 147 |
+
modal.style.display = 'block';
|
| 148 |
+
backdrop.style.display = 'block';
|
| 149 |
+
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
| 150 |
+
if (prefersDark) {{
|
| 151 |
+
modal.style.backgroundColor = '#1e1e1e';
|
| 152 |
+
modal.style.color = '#ffffff';
|
| 153 |
+
modal.style.border = '1px solid #444';
|
| 154 |
+
modal.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.8)';
|
| 155 |
+
closeButton.style.backgroundColor = '#007bff';
|
| 156 |
+
closeButton.style.color = 'white';
|
| 157 |
+
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.7)';
|
| 158 |
+
}} else {{
|
| 159 |
+
modal.style.backgroundColor = '#ffffff';
|
| 160 |
+
modal.style.color = '#000000';
|
| 161 |
+
modal.style.border = '1px solid #ccc';
|
| 162 |
+
modal.style.boxShadow = '0px 4px 6px rgba(0, 0, 0, 0.2)';
|
| 163 |
+
closeButton.style.backgroundColor = '#007bff';
|
| 164 |
+
closeButton.style.color = 'white';
|
| 165 |
+
backdrop.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
|
| 166 |
+
}}
|
| 167 |
+
closeButton.style.marginTop = '10px';
|
| 168 |
+
closeButton.style.padding = '5px 10px';
|
| 169 |
+
closeButton.style.border = 'none';
|
| 170 |
+
closeButton.style.borderRadius = '5px';
|
| 171 |
+
closeButton.style.cursor = 'pointer';
|
| 172 |
+
}}
|
| 173 |
+
function closeTopicsModal() {{
|
| 174 |
+
document.getElementById('topicsModal').style.display = 'none';
|
| 175 |
+
document.getElementById('topicsBackdrop').style.display = 'none';
|
| 176 |
+
}}
|
| 177 |
</script>
|
| 178 |
+
"""
|
|
|
|
| 179 |
gr.HTML(modal_script)
|
| 180 |
|
| 181 |
logging.info("Interface build complete.")
|