Ankush05 commited on
Commit
2ddafac
1 Parent(s): 930b1a4
Files changed (1) hide show
  1. app.py +31 -0
app.py CHANGED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from pymongo import MongoClient
3
+ from transformers import pipeline, Conversation
4
+
5
+
6
+
7
+ classifyr = pipeline("zero-shot-classification")
8
+ convo = pipeline("conversational")
9
+
10
+ uri = os.environ["MONGO_CONNECTION_STRING"]
11
+ client = MongoClient(uri, tlsCertificateKeyFile="database/cert.pem")
12
+
13
+ db == client["myapp"]
14
+
15
+ col = db["reminders"]
16
+
17
+ def Chatbot():
18
+ st.title("Chatbot")
19
+ if message :=st.chat_input("Enter your message"):
20
+ x = classifyr(message,candidate_labels=["reminders", "general conversation"])
21
+ if x["labels"][0] == "reminders":
22
+ with st.chat_message("Assistant"):
23
+ st.write(x)
24
+ elif x["labels"][0] == "general conversation":
25
+ umsg = Conversation(message)
26
+ ans =convo(umsg)
27
+ with st.chat_message("assistant"):
28
+ st.write(ans)
29
+
30
+
31
+