Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ from sklearn.metrics.pairwise import cosine_similarity
|
|
| 5 |
import random
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
import gradio as gr
|
|
|
|
| 8 |
|
| 9 |
# Load datasets
|
| 10 |
lecturer_data = pd.read_csv('lecturers.csv', dtype={"phone_number": str}).astype(str)
|
|
@@ -160,7 +161,7 @@ def answer_doc_link_query(query):
|
|
| 160 |
return f"I'm sorry, I can't find any study smarter study set for that course."
|
| 161 |
|
| 162 |
elif max_score < 1:
|
| 163 |
-
return "Sure! To assist you better, please provide the name or code of the course you are referring to."
|
| 164 |
|
| 165 |
else:
|
| 166 |
answer_general_query(query)
|
|
@@ -207,18 +208,19 @@ def get_response(query):
|
|
| 207 |
|
| 208 |
return response
|
| 209 |
|
| 210 |
-
# Function to handle Gradio interface
|
| 211 |
-
def chatty(query):
|
| 212 |
-
response = get_response(query)
|
| 213 |
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
|
|
|
| 217 |
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
|
|
|
|
|
|
|
|
|
|
| 222 |
|
| 223 |
-
|
| 224 |
-
iface.launch()
|
|
|
|
| 5 |
import random
|
| 6 |
from sentence_transformers import SentenceTransformer
|
| 7 |
import gradio as gr
|
| 8 |
+
import time
|
| 9 |
|
| 10 |
# Load datasets
|
| 11 |
lecturer_data = pd.read_csv('lecturers.csv', dtype={"phone_number": str}).astype(str)
|
|
|
|
| 161 |
return f"I'm sorry, I can't find any study smarter study set for that course."
|
| 162 |
|
| 163 |
elif max_score < 1:
|
| 164 |
+
return "Sure! To assist you better, please provide the name or code of the course you are referring to, along with the entire query."
|
| 165 |
|
| 166 |
else:
|
| 167 |
answer_general_query(query)
|
|
|
|
| 208 |
|
| 209 |
return response
|
| 210 |
|
|
|
|
|
|
|
|
|
|
| 211 |
|
| 212 |
+
with gr.Blocks() as iface:
|
| 213 |
+
chatbot = gr.Chatbot()
|
| 214 |
+
msg = gr.Textbox()
|
| 215 |
+
clear = gr.ClearButton([msg, chatbot])
|
| 216 |
|
| 217 |
+
def respond(message, chat_history):
|
| 218 |
+
bot_message = get_response(message)
|
| 219 |
+
chat_history.append((message, bot_message))
|
| 220 |
+
time.sleep(2)
|
| 221 |
+
return "", chat_history
|
| 222 |
+
|
| 223 |
+
msg.submit(respond, [msg, chatbot], [msg, chatbot])
|
| 224 |
|
| 225 |
+
if __name__ == "__main__":
|
| 226 |
+
iface.launch()
|