CosmoAI commited on
Commit
58c6cb9
·
1 Parent(s): d4b5485

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +74 -0
app.py ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import os
3
+ import pandas as pd
4
+
5
+ from streamlit_option_menu import option_menu
6
+ from bardapi import Bard
7
+ from getvalues import getValues
8
+ from pymongo import MongoClient
9
+ from transformers import pipeline, Conversation
10
+
11
+
12
+
13
+ classifyr = pipeline("zero-shot-classification")
14
+
15
+ convo = pipeline("conversational")
16
+
17
+ # classifi = pipeline(model="facebook/bart-large-mnli")
18
+
19
+ uri = os.environ["MONGO_CONNECTION_STRING"]
20
+ client = MongoClient(uri, tlsCertificateKeyFile="database/cert.pem")
21
+
22
+ db = client["myapp"]
23
+
24
+ col = db["reminders"]
25
+
26
+ bardkey = os.environ.get("BARD_API_KEY")
27
+
28
+ bard = Bard(token=bardkey)
29
+
30
+ def view_rem():
31
+ allrem = list(col.find())
32
+ remdata = pd.DataFrame(allrem)
33
+ st.dataframe(remdata)
34
+
35
+
36
+ def Chatbot():
37
+ st.title("Chatbot")
38
+ if user_input := st.chat_input("Describe your goal. e.g: I want to achieve this goal in this time. Be as specific and explanatory as you can."):
39
+ bardans = bard.get_answer(user_input)['content']
40
+ anslist = bard.get_answer(f"Make a list of this answer: \n{bardans} \nfor this goal: \n{user_input}\n\nThe list should be in two section, section 1 for all the reminders to track called Daily Routine and section 2 for all information that should be consumed to achieve the goal and stay very focused and motivated with excitement and this section is called Notes")['content']
41
+ # result = classifyr(user_input,candidate_labels=["reminders", "notes"])
42
+ with st.chat_message("assistant"):
43
+ st.write(anslist)
44
+
45
+ # with st.chat_message("user"):
46
+ # st.write(result["labels"][0])
47
+
48
+ # if ans["labels"][0] == "reminders":
49
+ # values = getValues(query.lower())
50
+ # with st.chat_message("assistant"):
51
+ # st.write(values)
52
+ # col.insert_one(values)
53
+
54
+
55
+ # elif ans["labels"][0] == "general conversation":
56
+ # umsg = bard.get_answer(query)["content"]
57
+ # with st.chat_message("assistant"):
58
+ # st.write(umsg)
59
+
60
+ # elif ans["labels"][0] == "notes":
61
+
62
+ # Notes = query.lower().replace( " create a new note", "",).replace(" no new note", "")
63
+
64
+
65
+
66
+ Chatbot()
67
+
68
+
69
+ def Create_Reminder():
70
+ st.title("Create Reminder")
71
+ message = st.text_input("Share your plan of today")
72
+ time = str(st.time_input("Time"))
73
+ date = str(st.date_input("Date"))
74
+