Update app.py
Browse files
app.py
CHANGED
|
@@ -3,8 +3,8 @@ import gradio as gr
|
|
| 3 |
from huggingface_hub import get_token
|
| 4 |
|
| 5 |
from chatbot import get_retrieval_qa
|
| 6 |
-
|
| 7 |
-
from gradio.flagging import HuggingFaceDatasetSaver
|
| 8 |
|
| 9 |
|
| 10 |
# get the html data and save it to a file
|
|
@@ -34,7 +34,8 @@ def answer_question(message, history, system):
|
|
| 34 |
result = result.replace('"', "").strip() # clean up the result
|
| 35 |
|
| 36 |
# save the query and result to the dataset
|
| 37 |
-
|
|
|
|
| 38 |
return result
|
| 39 |
|
| 40 |
|
|
@@ -98,6 +99,7 @@ with gr.ChatInterface(
|
|
| 98 |
demo.load(lambda: download_html(url, filename))
|
| 99 |
# This needs to be called prior to the first call to callback.flag()
|
| 100 |
hf_writer.setup([demo.textbox, demo.chatbot], "flagged")
|
|
|
|
| 101 |
# like callback
|
| 102 |
chatbot.like(on_like, None, None)
|
| 103 |
|
|
|
|
| 3 |
from huggingface_hub import get_token
|
| 4 |
|
| 5 |
from chatbot import get_retrieval_qa
|
| 6 |
+
from flagging import myHuggingFaceDatasetSaver as HuggingFaceDatasetSaver
|
| 7 |
+
#from gradio.flagging import HuggingFaceDatasetSaver
|
| 8 |
|
| 9 |
|
| 10 |
# get the html data and save it to a file
|
|
|
|
| 34 |
result = result.replace('"', "").strip() # clean up the result
|
| 35 |
|
| 36 |
# save the query and result to the dataset
|
| 37 |
+
print("flagging...")
|
| 38 |
+
hf_writer.flag(flag_data=[query, result])
|
| 39 |
return result
|
| 40 |
|
| 41 |
|
|
|
|
| 99 |
demo.load(lambda: download_html(url, filename))
|
| 100 |
# This needs to be called prior to the first call to callback.flag()
|
| 101 |
hf_writer.setup([demo.textbox, demo.chatbot], "flagged")
|
| 102 |
+
print("flagging setup done!")
|
| 103 |
# like callback
|
| 104 |
chatbot.like(on_like, None, None)
|
| 105 |
|