Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,8 @@ import gradio as gr
|
|
3 |
from huggingface_hub import get_token
|
4 |
|
5 |
from chatbot import get_retrieval_qa
|
6 |
-
from flagging import myHuggingFaceDatasetSaver
|
|
|
7 |
|
8 |
|
9 |
# get the html data and save it to a file
|
@@ -22,20 +23,18 @@ qa = get_retrieval_qa(filename)
|
|
22 |
|
23 |
# dataset callback
|
24 |
dataset_name = "SEA-AI/seadog-chat-history"
|
25 |
-
hf_writer =
|
26 |
|
27 |
|
28 |
def answer_question(message, history, system):
|
29 |
# concatenate the history, message and system
|
30 |
query = " ".join([message, system])
|
31 |
retrieval_qa = qa.invoke(query)
|
32 |
-
result = retrieval_qa["result"]
|
33 |
result = result.replace('"', "").strip() # clean up the result
|
34 |
-
# query = retrieval_qa["query"]
|
35 |
-
# source_documents = retrieval_qa["source_documents"]
|
36 |
|
37 |
# save the query and result to the dataset
|
38 |
-
hf_writer.flag([query, result])
|
39 |
return result
|
40 |
|
41 |
|
|
|
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
|
|
|
23 |
|
24 |
# dataset callback
|
25 |
dataset_name = "SEA-AI/seadog-chat-history"
|
26 |
+
hf_writer = HuggingFaceDatasetSaver(get_token(), dataset_name)
|
27 |
|
28 |
|
29 |
def answer_question(message, history, system):
|
30 |
# concatenate the history, message and system
|
31 |
query = " ".join([message, system])
|
32 |
retrieval_qa = qa.invoke(query)
|
33 |
+
result = retrieval_qa["result"] # "query" and "source_documents" are also available
|
34 |
result = result.replace('"', "").strip() # clean up the result
|
|
|
|
|
35 |
|
36 |
# save the query and result to the dataset
|
37 |
+
hf_writer.flag(flag_data=[(query, result)])
|
38 |
return result
|
39 |
|
40 |
|