Upload app.py
Browse files
app.py
CHANGED
|
@@ -20,7 +20,7 @@ def chatbot_response(message):
|
|
| 20 |
response = query_engine.query(message)
|
| 21 |
return str(response)
|
| 22 |
|
| 23 |
-
# Custom CSS for purple button styling
|
| 24 |
custom_css = """
|
| 25 |
/* Target all possible Gradio button selectors */
|
| 26 |
button,
|
|
@@ -94,36 +94,6 @@ button.primary {
|
|
| 94 |
color: white !important;
|
| 95 |
}
|
| 96 |
|
| 97 |
-
/* NUCLEAR OPTION: Override ALL buttons in the examples section */
|
| 98 |
-
div:has(> *:contains("Examples")) ~ * button,
|
| 99 |
-
div:has(> *:contains("Examples")) button,
|
| 100 |
-
*[class*="example"] button,
|
| 101 |
-
*[class*="Example"] button {
|
| 102 |
-
background: #374151 !important;
|
| 103 |
-
color: white !important;
|
| 104 |
-
border: 1px solid #4B5563 !important;
|
| 105 |
-
border-radius: 8px !important;
|
| 106 |
-
}
|
| 107 |
-
|
| 108 |
-
div:has(> *:contains("Examples")) ~ * button:hover,
|
| 109 |
-
div:has(> *:contains("Examples")) button:hover,
|
| 110 |
-
*[class*="example"] button:hover,
|
| 111 |
-
*[class*="Example"] button:hover {
|
| 112 |
-
background: #4B5563 !important;
|
| 113 |
-
color: white !important;
|
| 114 |
-
}
|
| 115 |
-
|
| 116 |
-
/* Universal override for anything that might be an example */
|
| 117 |
-
button:nth-of-type(n+3) {
|
| 118 |
-
background: #374151 !important;
|
| 119 |
-
color: white !important;
|
| 120 |
-
border: 1px solid #4B5563 !important;
|
| 121 |
-
}
|
| 122 |
-
|
| 123 |
-
button:nth-of-type(n+3):hover {
|
| 124 |
-
background: #4B5563 !important;
|
| 125 |
-
}
|
| 126 |
-
|
| 127 |
/* Clear/secondary buttons */
|
| 128 |
.secondary,
|
| 129 |
.btn-secondary,
|
|
@@ -138,6 +108,68 @@ button:nth-of-type(n+3):hover {
|
|
| 138 |
.gr-button-secondary:hover {
|
| 139 |
background: #F3F4F6 !important;
|
| 140 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 141 |
"""
|
| 142 |
|
| 143 |
iface = gr.Interface(
|
|
|
|
| 20 |
response = query_engine.query(message)
|
| 21 |
return str(response)
|
| 22 |
|
| 23 |
+
# Custom CSS for purple button styling with JavaScript
|
| 24 |
custom_css = """
|
| 25 |
/* Target all possible Gradio button selectors */
|
| 26 |
button,
|
|
|
|
| 94 |
color: white !important;
|
| 95 |
}
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
/* Clear/secondary buttons */
|
| 98 |
.secondary,
|
| 99 |
.btn-secondary,
|
|
|
|
| 108 |
.gr-button-secondary:hover {
|
| 109 |
background: #F3F4F6 !important;
|
| 110 |
}
|
| 111 |
+
|
| 112 |
+
/* JavaScript to style example buttons */
|
| 113 |
+
<script>
|
| 114 |
+
function styleExampleButtons() {
|
| 115 |
+
// Wait for the page to fully load
|
| 116 |
+
setTimeout(function() {
|
| 117 |
+
console.log('Attempting to style example buttons...');
|
| 118 |
+
|
| 119 |
+
// Find all buttons on the page
|
| 120 |
+
const allButtons = document.querySelectorAll('button');
|
| 121 |
+
console.log('Found', allButtons.length, 'buttons');
|
| 122 |
+
|
| 123 |
+
// Skip the first two buttons (Clear and Submit) and style the rest
|
| 124 |
+
allButtons.forEach((btn, index) => {
|
| 125 |
+
if (index >= 2) {
|
| 126 |
+
console.log('Styling button', index, ':', btn.textContent);
|
| 127 |
+
btn.style.setProperty('background', '#374151', 'important');
|
| 128 |
+
btn.style.setProperty('color', 'white', 'important');
|
| 129 |
+
btn.style.setProperty('border', '1px solid #4B5563', 'important');
|
| 130 |
+
btn.style.setProperty('border-radius', '8px', 'important');
|
| 131 |
+
|
| 132 |
+
// Add hover effect
|
| 133 |
+
btn.addEventListener('mouseenter', function() {
|
| 134 |
+
this.style.setProperty('background', '#4B5563', 'important');
|
| 135 |
+
});
|
| 136 |
+
btn.addEventListener('mouseleave', function() {
|
| 137 |
+
this.style.setProperty('background', '#374151', 'important');
|
| 138 |
+
});
|
| 139 |
+
}
|
| 140 |
+
});
|
| 141 |
+
|
| 142 |
+
// Alternative approach: look for buttons containing example text
|
| 143 |
+
const exampleTexts = [
|
| 144 |
+
'Provide a summary of Donald',
|
| 145 |
+
'Has Donald worked with Python',
|
| 146 |
+
'Tell me something interesting',
|
| 147 |
+
'What technical skills',
|
| 148 |
+
'How did Donald build'
|
| 149 |
+
];
|
| 150 |
+
|
| 151 |
+
exampleTexts.forEach(text => {
|
| 152 |
+
const buttons = Array.from(allButtons).filter(btn =>
|
| 153 |
+
btn.textContent.includes(text) ||
|
| 154 |
+
btn.innerText.includes(text)
|
| 155 |
+
);
|
| 156 |
+
buttons.forEach(btn => {
|
| 157 |
+
console.log('Found example button:', btn.textContent);
|
| 158 |
+
btn.style.setProperty('background', '#374151', 'important');
|
| 159 |
+
btn.style.setProperty('color', 'white', 'important');
|
| 160 |
+
btn.style.setProperty('border', '1px solid #4B5563', 'important');
|
| 161 |
+
});
|
| 162 |
+
});
|
| 163 |
+
}, 2000); // Wait 2 seconds for Gradio to fully render
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
// Run immediately and also when DOM content loads
|
| 167 |
+
styleExampleButtons();
|
| 168 |
+
document.addEventListener('DOMContentLoaded', styleExampleButtons);
|
| 169 |
+
|
| 170 |
+
// Also run when the window loads (backup)
|
| 171 |
+
window.addEventListener('load', styleExampleButtons);
|
| 172 |
+
</script>
|
| 173 |
"""
|
| 174 |
|
| 175 |
iface = gr.Interface(
|