Spaces:
Runtime error
Runtime error
adding feedback
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
from mvp import tbl
|
|
|
|
| 4 |
|
| 5 |
# # Function to call your system API and get the response
|
| 6 |
# def search_question(question):
|
|
@@ -16,7 +17,16 @@ from mvp import tbl
|
|
| 16 |
|
| 17 |
# Function to handle feedback submission
|
| 18 |
def handle_feedback(feedback, additional_feedback):
|
| 19 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
return "Thank you for your feedback!"
|
| 21 |
|
| 22 |
from mvp import search_question
|
|
@@ -67,11 +77,7 @@ def gradio_app():
|
|
| 67 |
# Function to show the additional feedback textbox
|
| 68 |
def show_additional_feedback_box():
|
| 69 |
return gr.update(visible=True)
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
def format_results(docs):
|
| 73 |
-
return [[doc.text, doc.filename, doc.username] for doc in docs]
|
| 74 |
-
|
| 75 |
|
| 76 |
search_button.click(
|
| 77 |
fn=search_question,
|
|
@@ -86,7 +92,7 @@ def gradio_app():
|
|
| 86 |
thumbs_down.click(fn=show_additional_feedback_box, outputs=additional_feedback)
|
| 87 |
|
| 88 |
# Connect the feedback button to the handle_feedback function
|
| 89 |
-
feedback_button.click(fn=handle_feedback, inputs=[thumbs_down, additional_feedback], outputs=None)
|
| 90 |
|
| 91 |
return demo
|
| 92 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
from mvp import tbl
|
| 4 |
+
import sqlite3
|
| 5 |
|
| 6 |
# # Function to call your system API and get the response
|
| 7 |
# def search_question(question):
|
|
|
|
| 17 |
|
| 18 |
# Function to handle feedback submission
|
| 19 |
def handle_feedback(feedback, additional_feedback):
|
| 20 |
+
# Update the last logged interaction with feedback
|
| 21 |
+
conn = sqlite3.connect('rag.db')
|
| 22 |
+
cursor = conn.cursor()
|
| 23 |
+
cursor.execute('''
|
| 24 |
+
UPDATE interactions
|
| 25 |
+
SET feedback = ?, additional_feedback = ?
|
| 26 |
+
WHERE id = (SELECT MAX(id) FROM interactions)
|
| 27 |
+
''', (feedback, additional_feedback))
|
| 28 |
+
conn.commit()
|
| 29 |
+
conn.close()
|
| 30 |
return "Thank you for your feedback!"
|
| 31 |
|
| 32 |
from mvp import search_question
|
|
|
|
| 77 |
# Function to show the additional feedback textbox
|
| 78 |
def show_additional_feedback_box():
|
| 79 |
return gr.update(visible=True)
|
| 80 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
|
| 82 |
search_button.click(
|
| 83 |
fn=search_question,
|
|
|
|
| 92 |
thumbs_down.click(fn=show_additional_feedback_box, outputs=additional_feedback)
|
| 93 |
|
| 94 |
# Connect the feedback button to the handle_feedback function
|
| 95 |
+
feedback_button.click(fn=lambda x, y: handle_feedback(x, y), inputs=[thumbs_down, additional_feedback], outputs=None)
|
| 96 |
|
| 97 |
return demo
|
| 98 |
|