Upload folder using huggingface_hub
Browse files- hate_speech_demo.py +51 -51
hate_speech_demo.py
CHANGED
|
@@ -829,57 +829,57 @@ def create_gradio_app():
|
|
| 829 |
</div>
|
| 830 |
""")
|
| 831 |
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
-
|
| 845 |
-
|
| 846 |
-
|
| 847 |
-
|
| 848 |
-
|
| 849 |
-
|
| 850 |
-
|
| 851 |
-
|
| 852 |
-
|
| 853 |
-
|
| 854 |
-
|
| 855 |
-
|
| 856 |
-
|
| 857 |
-
|
| 858 |
-
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
| 864 |
-
|
| 865 |
-
|
| 866 |
-
|
| 867 |
-
|
| 868 |
-
|
| 869 |
-
|
| 870 |
-
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
|
| 874 |
-
|
| 875 |
-
|
| 876 |
-
|
| 877 |
-
|
| 878 |
-
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
|
| 884 |
# Define show/hide loading indicator functions
|
| 885 |
def show_loading():
|
|
|
|
| 829 |
</div>
|
| 830 |
""")
|
| 831 |
|
| 832 |
+
with gr.Column():
|
| 833 |
+
# Buttons (stacked or spaced however you like)
|
| 834 |
+
random_test_btn = gr.Button("π² Random Test Case", elem_classes=["orange-button"])
|
| 835 |
+
rate_btn = gr.Button("Rate Content", variant="primary", size="lg", elem_classes=["gray-button"])
|
| 836 |
+
|
| 837 |
+
# Input box
|
| 838 |
+
user_input = gr.Textbox(
|
| 839 |
+
label="Input content to rate:",
|
| 840 |
+
placeholder="Type content to evaluate here...",
|
| 841 |
+
lines=6
|
| 842 |
+
)
|
| 843 |
+
|
| 844 |
+
# π Contextual Safety Oracle
|
| 845 |
+
gr.HTML("""
|
| 846 |
+
<div class="result-header" style="display: flex; align-items: center; gap: 10px;">
|
| 847 |
+
<span>π Contextual Safety Oracle</span>
|
| 848 |
+
<a href="#" class="knowledge-button" onclick="openPolicyPopup(); return false;">View policy</a>
|
| 849 |
+
</div>
|
| 850 |
+
""")
|
| 851 |
+
contextual_results = gr.HTML('<div class="rating-box contextual-box empty-rating">Rating will appear here</div>')
|
| 852 |
+
retrieved_knowledge = gr.HTML('', visible=False)
|
| 853 |
+
|
| 854 |
+
# π¦ LlamaGuard
|
| 855 |
+
gr.HTML("""
|
| 856 |
+
<div class="result-header" style="display: flex; align-items: center; gap: 10px;">
|
| 857 |
+
<span>π¦ LlamaGuard 3.0</span>
|
| 858 |
+
<a href="https://github.com/meta-llama/PurpleLlama/blob/main/Llama-Guard3/8B/MODEL_CARD.md"
|
| 859 |
+
target="_blank" class="knowledge-button">View model card</a>
|
| 860 |
+
</div>
|
| 861 |
+
""")
|
| 862 |
+
llama_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
| 863 |
+
|
| 864 |
+
# π§· OpenAI Moderation
|
| 865 |
+
gr.HTML("""
|
| 866 |
+
<div class="result-header" style="display: flex; align-items: center; gap: 10px;">
|
| 867 |
+
<span>π§· OpenAI Moderation</span>
|
| 868 |
+
<a href="https://platform.openai.com/docs/guides/moderation"
|
| 869 |
+
target="_blank" class="knowledge-button">View model card</a>
|
| 870 |
+
</div>
|
| 871 |
+
""")
|
| 872 |
+
openai_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
| 873 |
+
|
| 874 |
+
# π§© Perspective API
|
| 875 |
+
gr.HTML("""
|
| 876 |
+
<div class="result-header" style="display: flex; align-items: center; gap: 10px;">
|
| 877 |
+
<span>π§© Perspective API</span>
|
| 878 |
+
<a href="https://developers.perspectiveapi.com/s/docs"
|
| 879 |
+
target="_blank" class="knowledge-button">View docs</a>
|
| 880 |
+
</div>
|
| 881 |
+
""")
|
| 882 |
+
perspective_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
| 883 |
|
| 884 |
# Define show/hide loading indicator functions
|
| 885 |
def show_loading():
|