Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AnjiBot 🤖
|
2 |
+
### Computer Science Course Representative (Chatbot)
|
3 |
+
|
4 |
+
from transformers import pipeline
|
5 |
+
import pandas as pd
|
6 |
+
import gradio as gr
|
7 |
+
|
8 |
+
# Load TAPAS model and table
|
9 |
+
tqa = pipeline(task="table-question-answering", model="google/tapas-base-finetuned-sqa")
|
10 |
+
table = pd.read_csv('CSLECTURERS.csv', delimiter="::")
|
11 |
+
table = table.astype('str')
|
12 |
+
|
13 |
+
messages = []
|
14 |
+
responses = []
|
15 |
+
|
16 |
+
def anjibot(message, history):
|
17 |
+
messages.append(message)
|
18 |
+
conversation = {"text": message, "past_user_input": messages, "generated_responses": responses}
|
19 |
+
answer = tqa(table=table, query=message)["answer"]
|
20 |
+
responses.append(answer)
|
21 |
+
return "AnjiBot: " + answer
|
22 |
+
|
23 |
+
demo_chatbot = gr.ChatInterface(anjibot, title='AnjiBot', description="Anji is unavailable? That girl! Ask me, I may know!")
|
24 |
+
demo_chatbot.launch()
|