Spaces:
Runtime error
Runtime error
File size: 1,543 Bytes
c5db237 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import gradio as gr
import pandas as pd
from google.colab import auth
import gspread
from google.auth import default
def feedback_response(feedback, comments):
response = ''
if feedback == 'Good Response':
response = 'Good Response!'
elif feedback == 'Bad Response':
response = 'Bad Response'
else:
response = 'Inappropriate response!'
if comments:
comments = comments
# Create a DataFrame from the response
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
sheet_id = "18hnoTsEaGMWMael42MXubb-FzAe5jJB5RpaSolIXyb0"
worksheet_name = "Sheet1"
auth.authenticate_user()
creds, _ = default()
gc = gspread.authorize(creds)
sh = gc.open_by_key(sheet_id)
sh.worksheets()
worksheet = sh.worksheet(worksheet_name)
df = pd.DataFrame({'Response': [response],'Additional Comments': [comments]})
#worksheet.append_rows([df.columns.values.tolist()] + df.values.tolist())
worksheet.append_rows(df.values.tolist())
return "Your feedback has been recorded. Thank you!"
# Set up the Gradio Interface
feedback_interface = gr.Interface(
fn=feedback_response,
inputs=[
gr.Radio(
choices=[
"Good Response",
"Bad Response",
"Inappropriate Response"
],
label="Feedback"
),
gr.Textbox(label="Additional Comments")
],
outputs= "text"
)
# Launch the interface
feedback_interface.launch(share=True)
|