Newcode / app.py
Ankush05's picture
this
2e367ae
raw
history blame
1.76 kB
import streamlit as st
import os
import pandas as pd
from streamlit_option_menu import option_menu
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")
# classifi = pipeline(model="facebook/bart-large-mnli")
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 view_rem():
allrem = list(col.find())
remdata = pd.DataFrame(allrem)
st.dataframe(remdata)
def Chatbot():
st.title("Chatbot")
if query := st.chat_input("Enter your message"):
ans = classifyr(query,candidate_labels=["reminders", "general conversation", "notes"])
if ans["labels"][0] == "reminders":
values = getValues(query.lower())
with st.chat_message("assistant"):
st.write(values)
col.insert_one(values)
elif ans["labels"][0] == "general conversation":
umsg = bard.get_answer(query)["content"]
with st.chat_message("assistant"):
st.write(umsg)
elif ans["labels"][0] == "notes":
Notes = entry.lower().replace( " create a new note", "",).replace(" no new note", "")
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"))