Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,7 +36,6 @@ MODEL_DICT = {
|
|
36 |
DATA_PATH = 'models/dataset.xlsx'
|
37 |
EMBEDDINGS_PATH = 'models/embeddings.pkl'
|
38 |
|
39 |
-
|
40 |
class ChatbotModel:
|
41 |
def __init__(self, model=DEFAULT_MODEL):
|
42 |
self._chatbot = Chatbot()
|
@@ -49,10 +48,6 @@ class ChatbotModel:
|
|
49 |
def chat(self, question):
|
50 |
return self._chatbot.answer_question(question)
|
51 |
|
52 |
-
def eval(self, model, predict_method):
|
53 |
-
return self._chatbot.eval(model_name=model, predict_method=predict_method)
|
54 |
-
|
55 |
-
|
56 |
class Chatbot:
|
57 |
def __init__(self):
|
58 |
# Initialize variables
|
@@ -138,16 +133,6 @@ class Chatbot:
|
|
138 |
similar_questions, similar_contexts, distances, indices = self.faiss_search(question_vector)
|
139 |
context = similar_contexts[0]
|
140 |
Answer = self.model_pipeline(similar_questions[0], context)
|
141 |
-
# start_index = context.find(Answer)
|
142 |
-
# end_index = start_index + len(Answer)
|
143 |
-
# output = {
|
144 |
-
# "user_question": message,
|
145 |
-
# "answer": self.df['Answer'][indices[0][0]],
|
146 |
-
# "distance": round(distances[0][0], 4),
|
147 |
-
# "highlight_start": start_index,
|
148 |
-
# "highlight_end": end_index
|
149 |
-
# }
|
150 |
-
# return output
|
151 |
return Answer
|
152 |
|
153 |
if __name__ == "__main__":
|
@@ -155,8 +140,6 @@ if __name__ == "__main__":
|
|
155 |
|
156 |
def chat_interface(question, history):
|
157 |
response = bot._chatbot.predict(question)
|
158 |
-
# highlighted_answer = highlight_text(response["answer"], response["highlight_start"], response["highlight_end"])
|
159 |
-
# return highlighted_answer
|
160 |
return response
|
161 |
|
162 |
EXAMPLE = ["หลิน ไห่เฟิง มีชื่อเรียกอีกชื่อว่าอะไร" , "ใครเป็นผู้ตั้งสภาเศรษฐกิจโลกขึ้นในปี พ.ศ. 2514 โดยทุกปีจะมีการประชุมที่ประเทศสวิตเซอร์แลนด์", "โปรดิวเซอร์ของอัลบั้มตลอดกาล ของวงคีรีบูนคือใคร", "สกุลเดิมของหม่อมครูนุ่ม นวรัตน ณ อยุธยา คืออะไร"]
|
|
|
36 |
DATA_PATH = 'models/dataset.xlsx'
|
37 |
EMBEDDINGS_PATH = 'models/embeddings.pkl'
|
38 |
|
|
|
39 |
class ChatbotModel:
|
40 |
def __init__(self, model=DEFAULT_MODEL):
|
41 |
self._chatbot = Chatbot()
|
|
|
48 |
def chat(self, question):
|
49 |
return self._chatbot.answer_question(question)
|
50 |
|
|
|
|
|
|
|
|
|
51 |
class Chatbot:
|
52 |
def __init__(self):
|
53 |
# Initialize variables
|
|
|
133 |
similar_questions, similar_contexts, distances, indices = self.faiss_search(question_vector)
|
134 |
context = similar_contexts[0]
|
135 |
Answer = self.model_pipeline(similar_questions[0], context)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
return Answer
|
137 |
|
138 |
if __name__ == "__main__":
|
|
|
140 |
|
141 |
def chat_interface(question, history):
|
142 |
response = bot._chatbot.predict(question)
|
|
|
|
|
143 |
return response
|
144 |
|
145 |
EXAMPLE = ["หลิน ไห่เฟิง มีชื่อเรียกอีกชื่อว่าอะไร" , "ใครเป็นผู้ตั้งสภาเศรษฐกิจโลกขึ้นในปี พ.ศ. 2514 โดยทุกปีจะมีการประชุมที่ประเทศสวิตเซอร์แลนด์", "โปรดิวเซอร์ของอัลบั้มตลอดกาล ของวงคีรีบูนคือใคร", "สกุลเดิมของหม่อมครูนุ่ม นวรัตน ณ อยุธยา คืออะไร"]
|