faisalsns commited on
Commit
9009308
·
1 Parent(s): d5977dd

Initial commit for the feedback control

Browse files
UploadsToHuggingFace/README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Feedback Control
3
+ emoji: 😻
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: gradio
7
+ sdk_version: 5.38.2
8
+ app_file: app.py
9
+ pinned: false
10
+ license: apache-2.0
11
+ short_description: Feedback Control for HuggingFace Apps
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
UploadsToHuggingFace/app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import requests
3
+ from datetime import datetime
4
+ import os
5
+ from dotenv import load_dotenv
6
+
7
+ load_dotenv()
8
+
9
+ def submit_feedback(app_id, rating, comment):
10
+ SUPABASE_URL = "https://aumllmcpfqpfeunedemp.supabase.co"
11
+ TABLE_NAME = "feedback"
12
+ API_KEY = os.getenv("SUPERBASE_KEY",)
13
+ SUPABASE_KEY = API_KEY
14
+ payload = {
15
+ "app_id": app_id,
16
+ "rating": rating,
17
+ "comment": comment,
18
+ "created_at": datetime.utcnow().isoformat()
19
+ }
20
+ headers = {
21
+ "apikey": SUPABASE_KEY,
22
+ "Authorization": f"Bearer {SUPABASE_KEY}",
23
+ "Content-Type": "application/json"
24
+ }
25
+ r = requests.post(f"{SUPABASE_URL}/rest/v1/{TABLE_NAME}", json=payload, headers=headers)
26
+ if r.status_code == 201:
27
+ return "Thank you for your feedback!"
28
+ else:
29
+ return f"Error: {r.status_code} - {r.text}"
30
+
31
+ with gr.Blocks() as demo:
32
+ gr.Markdown("### Rate this app")
33
+ app_id = gr.Textbox(label="App ID", placeholder="e.g., app123")
34
+ rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating")
35
+ comment = gr.Textbox(lines=4, label="Comment")
36
+ output = gr.Textbox(label="Status", interactive=False)
37
+ submit_btn = gr.Button("Submit")
38
+
39
+ submit_btn.click(fn=submit_feedback, inputs=[app_id, rating, comment], outputs=[output])
40
+
41
+ demo.launch()
UploadsToHuggingFace/requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ gradio
2
+ requests