-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathA.I.D.A-Chatbot.py
99 lines (66 loc) · 2.25 KB
/
A.I.D.A-Chatbot.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import bardapi.core
def main():
if __name__ == '__main__':
main()
from bardapi import Bard
import streamlit as st
from streamlit_chat import message
import os
Token=st.secrets.BARD_API_KEY.Token
st.title("A.I.D.A")
st.markdown("---")
st.subheader("Hey Buddy! :wave: I am A.I.D.A your anytime companion.Please feel free to share anything0. :smile:")
st.markdown("""
<style>
.main.css-uf99v8.e1g8pov65
{
background: url(https://unsplash.com/photos/a-sunset-over-a-body-of-water-with-clouds-in-the-sky-SM8zJo-mbqQ) no-repeat center fixed ;
}
.css-erpbzb.e1ewe7hr3
{
visibility:hidden;
}
.css-cio0dv.e1g8pov61
{
visibility:hidden;
}
</style>
""",unsafe_allow_html=True) #removing hamburger on streamlit page
# .css-erpbzb.e1ewe7hr3
# {
# visibility:hidden;
# }
def generated_response (prompt):
response = Bard(token=Token).get_answer(prompt)['content']
return response
def input ():
input_text=st.text_input("","Hey A.I.D.A I want to talk to you.",key='Input')
return input_text
if 'generated' not in st.session_state:
st.session_state['generated'] = []
if 'past' not in st.session_state:
st.session_state['past'] = []
user_input = input()
if user_input:
print(user_input)
output = generated_response(user_input)
print(output)
st.session_state['past'].append(user_input)
st.session_state['generated'].append(output)
if st.session_state['generated']:
for i in range(len(st.session_state['generated'])-1,-1,-1):
message(st.session_state['generated'][i], key= str(i))
message(st.session_state['past'][i], key="user"+str(i),is_user=True)
st.markdown("---")
def change_in_state():
state=False
state=st.checkbox(label="Need professional help?",value=False,on_change=change_in_state)
if state:
st.write("[Click here to get a Professonial Counsellor](https://pib.gov.in/PressReleasePage.aspx?PRID=1652240)")
else:
pass
# st.markdown("[Click here to get a professional Counsellor](https://pib.gov.in/PressReleasePage.aspx?PRID=1652240)")
# def on_click():
# st.write(" Rounak with Love :heart:")
# st.button(label="Made By",on_click=on_click)
st.caption("Made By Rounak with Love :heart:")