Upload folder using huggingface_hub
Browse files- hate_speech_demo.py +27 -37
hate_speech_demo.py
CHANGED
|
@@ -829,64 +829,54 @@ def create_gradio_app():
|
|
| 829 |
</div>
|
| 830 |
""")
|
| 831 |
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
| 839 |
-
|
| 840 |
-
|
| 841 |
-
|
| 842 |
-
|
| 843 |
-
|
| 844 |
# π Contextual Safety Oracle
|
| 845 |
gr.HTML("""
|
| 846 |
-
<div>
|
| 847 |
-
<
|
| 848 |
-
<
|
| 849 |
-
<a href="#" class="knowledge-button" onclick="openPolicyPopup(); return false;">View policy</a>
|
| 850 |
-
</div>
|
| 851 |
</div>
|
| 852 |
""")
|
| 853 |
contextual_results = gr.HTML('<div class="rating-box contextual-box empty-rating">Rating will appear here</div>')
|
| 854 |
-
|
| 855 |
-
# Hidden placeholder for retrieval
|
| 856 |
retrieved_knowledge = gr.HTML('', visible=False)
|
| 857 |
|
| 858 |
# π¦ LlamaGuard
|
| 859 |
gr.HTML("""
|
| 860 |
-
<div>
|
| 861 |
-
<
|
| 862 |
-
<
|
| 863 |
-
|
| 864 |
-
target="_blank" class="knowledge-button">View model card</a>
|
| 865 |
-
</div>
|
| 866 |
</div>
|
| 867 |
""")
|
| 868 |
llama_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
| 869 |
|
| 870 |
# π§· OpenAI Moderation
|
| 871 |
gr.HTML("""
|
| 872 |
-
<div>
|
| 873 |
-
<
|
| 874 |
-
<
|
| 875 |
-
|
| 876 |
-
target="_blank" class="knowledge-button">View model card</a>
|
| 877 |
-
</div>
|
| 878 |
</div>
|
| 879 |
""")
|
| 880 |
openai_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
| 881 |
|
| 882 |
# π§© Perspective API
|
| 883 |
gr.HTML("""
|
| 884 |
-
<div>
|
| 885 |
-
<
|
| 886 |
-
<
|
| 887 |
-
|
| 888 |
-
target="_blank" class="knowledge-button">View docs</a>
|
| 889 |
-
</div>
|
| 890 |
</div>
|
| 891 |
""")
|
| 892 |
perspective_results = gr.HTML('<div class="rating-box secondary-box empty-rating">Rating will appear here</div>')
|
|
|
|
| 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>')
|