ChatBot / app.py
Ankush05's picture
Update app.py
cd43b43
raw
history blame
842 Bytes
import streamlit as st
import os
from transformers import pipeline
from bardapi import Bard
import os
from getvalues import getValues
bardkey = os.environ.get("BARD_API_KEY")
bard = Bard(token=bardkey)
classifi = pipeline(model="facebook/bart-large-mnli")
def chatbot():
st.title("ChatBot")
if query := st.chat_input("Enter your message"):
ans = classifi(query, candidate_labels=["Reminder", "General Conversation"])
if ans["labels"][0] == "Reminder":
values = getValues(query)
with st.chat_message("assistant"):
st.write(values)
elif ans["labels"][0] == "General Conversation":
umsg = bard.get_answer(message)["content"]
with st.chat_message("assistant"):
st.write(umsg)
chatbot()