Newcode / app.py
Ankush05's picture
this
f2b4ffb
raw
history blame
1.32 kB
import streamlit as st
import os
from bardapi import Bard
from getvalues import getValues
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"]
bardkey = os.environ.get("BARD_API_KEY")
bard = Bard(token=bardkey)
def Chatbot():
st.title("Chatbot")
if query :=st.chat_input("Enter your message"):
ans = classifyr(query,candidate_labels=["reminders", "general conversation"])
if ans["labels"][0] == "reminders":
values = getValues(ans.lower())
with st.chat_message("assistant"):
st.write(values)
col.insert_one(values)
elif ans["labels"][0] == "general conversation":
umsg = bard.get_answer(message)["content"]
with st.chat_message("assistant"):
st.write(umsg)
Chatbot()
def Create_Reminder():
st.title("Create Reminder")
message = st.text_input("Share your plan of today")
time = str(st.time_input("Time"))
date = str(st.date_input("Date"))