Spaces:
Sleeping
Sleeping
import streamlit as st | |
from pymongo import MongoClient | |
from transformers import pipeline, Conversation | |
classifyr = pipeline("zero-shot-classification") | |
convo = pipeline("conversational") | |
uri = os.environ["MONGO_CONNECTION_STRING"] | |
client = MongoClient(uri, tlsCertificateKeyFile="database/cert.pem") | |
db == client["myapp"] | |
col = db["reminders"] | |
def Chatbot(): | |
st.title("Chatbot") | |
if message :=st.chat_input("Enter your message"): | |
x = classifyr(message,candidate_labels=["reminders", "general conversation"]) | |
if x["labels"][0] == "reminders": | |
with st.chat_message("Assistant"): | |
st.write(x) | |
elif x["labels"][0] == "general conversation": | |
umsg = Conversation(message) | |
ans =convo(umsg) | |
with st.chat_message("assistant"): | |
st.write(ans) | |