CenterFor commited on
Commit
eb906dc
·
1 Parent(s): fa6c323

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -30,10 +30,13 @@ chat_prompt = ChatPromptTemplate.from_messages(
30
  HF_TOKEN = os.getenv('HF_TOKEN') # replace 'HF_TOKEN' with the name of your environment variable
31
  hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "CenterFor/HeyJesus_Feedback")
32
 
 
 
 
33
  with gr.Blocks() as demo:
34
  chatbot = gr.Chatbot()
35
  msg = gr.Textbox()
36
- clear = gr.ClearButton([msg, chatbot])
37
 
38
  def user(user_message, history):
39
  return gr.update(value="", interactive=False), history + [[user_message, None]]
@@ -55,8 +58,8 @@ with gr.Blocks() as demo:
55
  )
56
  response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
57
 
58
- demo.allow_flagging = "manual" # allow manual flagging
59
- demo.flagging_callback = hf_writer # set the flagging callback to hf_writer
60
 
61
  demo.queue()
62
  demo.launch()
 
30
  HF_TOKEN = os.getenv('HF_TOKEN') # replace 'HF_TOKEN' with the name of your environment variable
31
  hf_writer = gr.HuggingFaceDatasetSaver(HF_TOKEN, "CenterFor/HeyJesus_Feedback")
32
 
33
+ # This needs to be called at some point prior to the first call to hf_writer.flag()
34
+ hf_writer.setup([chatbot, msg], "flagged_conversations")
35
+
36
  with gr.Blocks() as demo:
37
  chatbot = gr.Chatbot()
38
  msg = gr.Textbox()
39
+ flag = gr.Button("Flag")
40
 
41
  def user(user_message, history):
42
  return gr.update(value="", interactive=False), history + [[user_message, None]]
 
58
  )
59
  response.then(lambda: gr.update(interactive=True), None, [msg], queue=False)
60
 
61
+ # We can choose which components to flag -- in this case, we'll flag all of them
62
+ flag.click(lambda *args: hf_writer.flag(args), [chatbot, msg], None, preprocess=False)
63
 
64
  demo.queue()
65
  demo.launch()