Upload folder using huggingface_hub
Browse files- .gradio/certificate.pem +31 -0
- README.md +3 -9
- app.py +47 -0
- flagged_reports/logs.csv +7 -0
- reports.csv +2 -0
- test.ipynb +98 -0
.gradio/certificate.pem
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
-----BEGIN CERTIFICATE-----
|
2 |
+
MIIFazCCA1OgAwIBAgIRAIIQz7DSQONZRGPgu2OCiwAwDQYJKoZIhvcNAQELBQAw
|
3 |
+
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
|
4 |
+
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwHhcNMTUwNjA0MTEwNDM4
|
5 |
+
WhcNMzUwNjA0MTEwNDM4WjBPMQswCQYDVQQGEwJVUzEpMCcGA1UEChMgSW50ZXJu
|
6 |
+
ZXQgU2VjdXJpdHkgUmVzZWFyY2ggR3JvdXAxFTATBgNVBAMTDElTUkcgUm9vdCBY
|
7 |
+
MTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK3oJHP0FDfzm54rVygc
|
8 |
+
h77ct984kIxuPOZXoHj3dcKi/vVqbvYATyjb3miGbESTtrFj/RQSa78f0uoxmyF+
|
9 |
+
0TM8ukj13Xnfs7j/EvEhmkvBioZxaUpmZmyPfjxwv60pIgbz5MDmgK7iS4+3mX6U
|
10 |
+
A5/TR5d8mUgjU+g4rk8Kb4Mu0UlXjIB0ttov0DiNewNwIRt18jA8+o+u3dpjq+sW
|
11 |
+
T8KOEUt+zwvo/7V3LvSye0rgTBIlDHCNAymg4VMk7BPZ7hm/ELNKjD+Jo2FR3qyH
|
12 |
+
B5T0Y3HsLuJvW5iB4YlcNHl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
|
27 |
+
oyi3B43njTOQ5yOf+1CceWxG1bQVs5ZufpsMljq4Ui0/1lvh+wjChP4kqKOJ2qxq
|
28 |
+
4RgqsahDYVvTH9w7jXbyLeiNdd8XM2w9U/t7y0Ff/9yi0GE44Za4rF2LN9d11TPA
|
29 |
+
mRGunUHBcnWEvgJBQl9nJEiU0Zsnvgc/ubhPgXRR4Xq37Z0j4r7g1SgEEzwxA57d
|
30 |
+
emyPxgcYxn/eR44/KJ4EBs+lVDR3veyJm+kXQ99b21/+jh5Xos1AnX5iItreGCc=
|
31 |
+
-----END CERTIFICATE-----
|
README.md
CHANGED
@@ -1,12 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji: 📚
|
4 |
-
colorFrom: purple
|
5 |
-
colorTo: blue
|
6 |
-
sdk: gradio
|
7 |
-
sdk_version: 5.15.0
|
8 |
app_file: app.py
|
9 |
-
|
|
|
10 |
---
|
11 |
-
|
12 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: loca-misc
|
|
|
|
|
|
|
|
|
|
|
3 |
app_file: app.py
|
4 |
+
sdk: gradio
|
5 |
+
sdk_version: 5.12.0
|
6 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import csv
|
3 |
+
import os
|
4 |
+
from datetime import datetime
|
5 |
+
|
6 |
+
# Setup CSV file
|
7 |
+
if not os.path.exists("reports.csv"):
|
8 |
+
with open("reports.csv", "w", newline="") as f:
|
9 |
+
writer = csv.writer(f)
|
10 |
+
writer.writerow(["Message", "Reason", "Comment", "Date"])
|
11 |
+
|
12 |
+
def submit_report(message: str, reason: str, comment: str = "") -> str:
|
13 |
+
with open("reports.csv", "a", newline="") as f:
|
14 |
+
writer = csv.writer(f)
|
15 |
+
writer.writerow([message, reason, comment, datetime.now()])
|
16 |
+
return "Report submitted successfully!"
|
17 |
+
|
18 |
+
def view_reports() -> str:
|
19 |
+
try:
|
20 |
+
with open("reports.csv", "r") as f:
|
21 |
+
return f.read()
|
22 |
+
except:
|
23 |
+
return "No reports found"
|
24 |
+
|
25 |
+
# Gradio Interface
|
26 |
+
with gr.Blocks() as demo:
|
27 |
+
gr.Markdown("## Message Report System")
|
28 |
+
|
29 |
+
with gr.Tab("Submit Report"):
|
30 |
+
message = gr.Textbox(label="Message to Report")
|
31 |
+
reason = gr.Radio(["Spam", "Offensive", "Other"], label="Reason")
|
32 |
+
comment = gr.Textbox(label="Additional Comments (Optional)")
|
33 |
+
submit = gr.Button("Submit Report")
|
34 |
+
result = gr.Textbox(label="Status")
|
35 |
+
|
36 |
+
submit.click(fn=submit_report,
|
37 |
+
inputs=[message, reason, comment],
|
38 |
+
outputs=result)
|
39 |
+
|
40 |
+
with gr.Tab("View Reports"):
|
41 |
+
view_btn = gr.Button("View All Reports")
|
42 |
+
reports = gr.Textbox(label="Reports")
|
43 |
+
|
44 |
+
view_btn.click(fn=view_reports,
|
45 |
+
outputs=reports)
|
46 |
+
|
47 |
+
demo.launch()
|
flagged_reports/logs.csv
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Input Text,Output Text,Flag Reason,Timestamp,User Comment
|
2 |
+
bad text,BAD TEXT,Other,2025-02-07T08:25:53.501477,"bad text
|
3 |
+
"
|
4 |
+
bad text 1,BAD TEXT,Spam,2025-02-07T08:26:12.222082,"bad text 2
|
5 |
+
"
|
6 |
+
Hello 1!!,Hello 2!!,Other,2025-02-07T08:27:54.154672,Hello!! 3
|
7 |
+
REP_20250207T083256622337,1,1,other,2025-02-07T08:32:56.622337,hello 123,PENDING
|
reports.csv
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
Message,Reason,Comment,Date
|
2 |
+
bad bad 2,Spam,bad message,2025-02-07 08:35:30.375065
|
test.ipynb
ADDED
@@ -0,0 +1,98 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "code",
|
5 |
+
"execution_count": 1,
|
6 |
+
"metadata": {},
|
7 |
+
"outputs": [
|
8 |
+
{
|
9 |
+
"name": "stderr",
|
10 |
+
"output_type": "stream",
|
11 |
+
"text": [
|
12 |
+
"/home/prasant/anaconda3/envs/wllm_env/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
|
13 |
+
" from .autonotebook import tqdm as notebook_tqdm\n"
|
14 |
+
]
|
15 |
+
},
|
16 |
+
{
|
17 |
+
"name": "stdout",
|
18 |
+
"output_type": "stream",
|
19 |
+
"text": [
|
20 |
+
"Loaded as API: http://127.0.0.1:7860/ ✔\n",
|
21 |
+
"Report submitted successfully!\n"
|
22 |
+
]
|
23 |
+
}
|
24 |
+
],
|
25 |
+
"source": [
|
26 |
+
"from gradio_client import Client\n",
|
27 |
+
"\n",
|
28 |
+
"client = Client(\"http://127.0.0.1:7860/\")\n",
|
29 |
+
"result = client.predict(\n",
|
30 |
+
"\t\tinput_text=\"Hello 1!!\",\n",
|
31 |
+
"\t\toutput_text=\"Hello 2!!\",\n",
|
32 |
+
"\t\tflag_reason=\"Other\",\n",
|
33 |
+
"\t\tuser_comment=\"Hello!! 3\",\n",
|
34 |
+
"\t\tapi_name=\"/log_report\"\n",
|
35 |
+
")\n",
|
36 |
+
"print(result)"
|
37 |
+
]
|
38 |
+
},
|
39 |
+
{
|
40 |
+
"cell_type": "code",
|
41 |
+
"execution_count": 2,
|
42 |
+
"metadata": {},
|
43 |
+
"outputs": [
|
44 |
+
{
|
45 |
+
"name": "stdout",
|
46 |
+
"output_type": "stream",
|
47 |
+
"text": [
|
48 |
+
"Loaded as API: http://127.0.0.1:7860/ ✔\n",
|
49 |
+
"Input Text,Output Text,Flag Reason,Timestamp,User Comment\n",
|
50 |
+
"bad text,BAD TEXT,Other,2025-02-07T08:25:53.501477,\"bad text\n",
|
51 |
+
"\"\n",
|
52 |
+
"bad text 1,BAD TEXT,Spam,2025-02-07T08:26:12.222082,\"bad text 2\n",
|
53 |
+
"\"\n",
|
54 |
+
"Hello 1!!,Hello 2!!,Other,2025-02-07T08:27:54.154672,Hello!! 3\n",
|
55 |
+
"\n"
|
56 |
+
]
|
57 |
+
}
|
58 |
+
],
|
59 |
+
"source": [
|
60 |
+
"from gradio_client import Client\n",
|
61 |
+
"\n",
|
62 |
+
"client = Client(\"http://127.0.0.1:7860/\")\n",
|
63 |
+
"result = client.predict(\n",
|
64 |
+
"\t\tapi_name=\"/view_log\"\n",
|
65 |
+
")\n",
|
66 |
+
"print(result)"
|
67 |
+
]
|
68 |
+
},
|
69 |
+
{
|
70 |
+
"cell_type": "code",
|
71 |
+
"execution_count": null,
|
72 |
+
"metadata": {},
|
73 |
+
"outputs": [],
|
74 |
+
"source": []
|
75 |
+
}
|
76 |
+
],
|
77 |
+
"metadata": {
|
78 |
+
"kernelspec": {
|
79 |
+
"display_name": "wllm_env",
|
80 |
+
"language": "python",
|
81 |
+
"name": "python3"
|
82 |
+
},
|
83 |
+
"language_info": {
|
84 |
+
"codemirror_mode": {
|
85 |
+
"name": "ipython",
|
86 |
+
"version": 3
|
87 |
+
},
|
88 |
+
"file_extension": ".py",
|
89 |
+
"mimetype": "text/x-python",
|
90 |
+
"name": "python",
|
91 |
+
"nbconvert_exporter": "python",
|
92 |
+
"pygments_lexer": "ipython3",
|
93 |
+
"version": "3.10.16"
|
94 |
+
}
|
95 |
+
},
|
96 |
+
"nbformat": 4,
|
97 |
+
"nbformat_minor": 2
|
98 |
+
}
|