Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
06a3065
1
Parent(s):
3cf2975
Replace HTML onclick with native Gradio buttons
Browse files- Removed problematic JavaScript onclick handlers
- Used native Gradio Button components instead of HTML buttons
- Added proper click handlers for question buttons
- Fixed JavaScript syntax errors
- Questions now populate input field using Gradio's event system
app.py
CHANGED
@@ -770,30 +770,25 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, js=question_js) as demo:
|
|
770 |
|
771 |
# Right side - Question carousel
|
772 |
with gr.Column(scale=1):
|
773 |
-
|
774 |
<div class="question-carousel">
|
775 |
<div class="carousel-title">💡 Quick Questions</div>
|
776 |
-
|
|
|
777 |
|
|
|
|
|
778 |
for category, questions in QUESTION_CATEGORIES.items():
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
{question}
|
790 |
-
</button>
|
791 |
-
"""
|
792 |
-
carousel_html += "</div>"
|
793 |
-
|
794 |
-
carousel_html += "</div>"
|
795 |
-
|
796 |
-
gr.HTML(carousel_html)
|
797 |
|
798 |
# Advanced settings in collapsible section
|
799 |
with gr.Accordion("⚙️ Advanced Settings", open=False, elem_classes="advanced-settings"):
|
@@ -930,6 +925,15 @@ with gr.Blocks(theme=gr.themes.Soft(), css=custom_css, js=question_js) as demo:
|
|
930 |
[chatbot, msg],
|
931 |
queue=False
|
932 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
933 |
|
934 |
# Launch configuration
|
935 |
if __name__ == "__main__":
|
|
|
770 |
|
771 |
# Right side - Question carousel
|
772 |
with gr.Column(scale=1):
|
773 |
+
gr.HTML("""
|
774 |
<div class="question-carousel">
|
775 |
<div class="carousel-title">💡 Quick Questions</div>
|
776 |
+
</div>
|
777 |
+
""")
|
778 |
|
779 |
+
# Create buttons for quick questions
|
780 |
+
question_buttons = []
|
781 |
for category, questions in QUESTION_CATEGORIES.items():
|
782 |
+
with gr.Group():
|
783 |
+
gr.HTML(f'<div class="carousel-card"><div class="carousel-card-title">{category}</div></div>')
|
784 |
+
for question in questions:
|
785 |
+
btn = gr.Button(
|
786 |
+
question,
|
787 |
+
variant="secondary",
|
788 |
+
size="sm",
|
789 |
+
elem_classes="question-button"
|
790 |
+
)
|
791 |
+
question_buttons.append((btn, question))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
792 |
|
793 |
# Advanced settings in collapsible section
|
794 |
with gr.Accordion("⚙️ Advanced Settings", open=False, elem_classes="advanced-settings"):
|
|
|
925 |
[chatbot, msg],
|
926 |
queue=False
|
927 |
)
|
928 |
+
|
929 |
+
# Connect question button click handlers
|
930 |
+
for btn, question_text in question_buttons:
|
931 |
+
btn.click(
|
932 |
+
lambda q=question_text: q,
|
933 |
+
None,
|
934 |
+
msg,
|
935 |
+
queue=False
|
936 |
+
)
|
937 |
|
938 |
# Launch configuration
|
939 |
if __name__ == "__main__":
|