File size: 1,549 Bytes
2ddafac
6898f19
ef7a692
581b917
ef7a692
 
43b9079
2ddafac
 
 
 
 
f843bad
 
 
2ddafac
 
 
 
7e0db7b
2ddafac
 
f2b4ffb
 
 
 
ef7a692
 
 
 
 
 
2ddafac
 
 
581b917
f843bad
43b9079
ef7a692
2ddafac
43b9079
 
 
 
 
f843bad
43b9079
 
e9cea2c
 
c4b114d
43b9079
 
 
 
 
24a1bb7
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
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 = classifi(query,candidate_labels=["reminders", "general conversation"])
        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)
    
    


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"))


Chatbot()