Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,12 @@ if 'API_Key' not in st.session_state:
|
|
18 |
# Setting page title and header
|
19 |
st.set_page_config(page_title="ChatMate: Your Professional AI Conversation Partner Solution", page_icon=":robot_face:")
|
20 |
st.markdown("<h1 style='text-align: center; color: navy;'>ChatMate</h1>", unsafe_allow_html=True)
|
21 |
-
st.markdown("<h4 style='text-align: center;'>
|
22 |
st.markdown("<p style='text-align: right'>By <a href='https://entzyeung.github.io/portfolio/index.html'>Lorentz Yeung</a></p>", unsafe_allow_html=True)
|
23 |
|
24 |
st.markdown("<p style='text-align: left;'>I am capable of recalling previous parts of our conversation, such as remembering your name if you share it with me.</p>", unsafe_allow_html=True)
|
25 |
st.session_state['API_Key']= st.text_input("First, to get it work, put your OpenAI API Key here please, the system will enter for you automatically.",type="password")
|
26 |
-
st.markdown("<p style='text-align: left;'>
|
27 |
|
28 |
|
29 |
|
@@ -34,22 +34,14 @@ st.sidebar.markdown("""
|
|
34 |
ChatMate is an advanced conversational AI interface, expertly crafted to demonstrate the fusion of Streamlit's user-friendly design and OpenAI's powerful GPT-3.5 model. Here are its highlights:
|
35 |
|
36 |
<ul style='text-align: left;'>
|
37 |
-
<li><strong>Intuitive Interface</strong>: Built with Streamlit, ChatMate offers a clean, responsive user experience, allowing for natural dialogue with the AI.</li>
|
38 |
-
<li><strong>Advanced NLP</strong>: Incorporating OpenAI's most advanced GPT model, the app provides nuanced understanding and generation of human-like text
|
39 |
<li><strong>State Management</strong>: Utilizes <code>ConversationChain</code> and <code>ConversationMemory</code> from <code>langchain</code> to preserve the context and flow, ensuring coherent and engaging interactions.</li>
|
40 |
<li><strong>Python Proficiency</strong>: The app's robust backend, written in Python, reflects the data scientist’s adeptness in programming and system design.</li>
|
41 |
<li><strong>Secure Interaction</strong>: Streamlit's session state management is used for secure API key handling and user input retention across sessions.</li>
|
42 |
</ul>
|
43 |
-
|
44 |
-
ChatMate is developed by Lorentz Yeung
|
45 |
""", unsafe_allow_html=True)
|
46 |
-
|
47 |
-
#st.session_state['API_Key']= st.sidebar.text_input("Put your OpenAI API Key here please, the system will enter for you automatically.",type="password")
|
48 |
-
|
49 |
-
# summarise_button = st.sidebar.button("Summarise the conversation", key="summarise")
|
50 |
-
#if summarise_button:
|
51 |
-
# summarise_placeholder = st.sidebar.write("Nice chatting with you my friend ❤️")
|
52 |
-
|
53 |
|
54 |
|
55 |
# Function to get response from the model
|
@@ -78,7 +70,7 @@ def getresponse(userInput, api_key):
|
|
78 |
|
79 |
|
80 |
response_container = st.container()
|
81 |
-
#
|
82 |
container = st.container()
|
83 |
|
84 |
# User input and response display
|
@@ -96,8 +88,8 @@ with container:
|
|
96 |
with response_container:
|
97 |
for i in range(len(st.session_state['messages'])):
|
98 |
if (i % 2) == 0:
|
99 |
-
message(st.session_state['messages'][i], is_user=True, key=str(i) + '_user', avatar_style="
|
100 |
else:
|
101 |
-
message(st.session_state['messages'][i], key=str(i) + '_AI', avatar_style="
|
102 |
|
103 |
|
|
|
18 |
# Setting page title and header
|
19 |
st.set_page_config(page_title="ChatMate: Your Professional AI Conversation Partner Solution", page_icon=":robot_face:")
|
20 |
st.markdown("<h1 style='text-align: center; color: navy;'>ChatMate</h1>", unsafe_allow_html=True)
|
21 |
+
st.markdown("<h4 style='text-align: center;'>OpenAI-like Chat Experience</h4>", unsafe_allow_html=True)
|
22 |
st.markdown("<p style='text-align: right'>By <a href='https://entzyeung.github.io/portfolio/index.html'>Lorentz Yeung</a></p>", unsafe_allow_html=True)
|
23 |
|
24 |
st.markdown("<p style='text-align: left;'>I am capable of recalling previous parts of our conversation, such as remembering your name if you share it with me.</p>", unsafe_allow_html=True)
|
25 |
st.session_state['API_Key']= st.text_input("First, to get it work, put your OpenAI API Key here please, the system will enter for you automatically.",type="password")
|
26 |
+
st.markdown("<p style='text-align: left;'>How can I help you today?</p>", unsafe_allow_html=True)
|
27 |
|
28 |
|
29 |
|
|
|
34 |
ChatMate is an advanced conversational AI interface, expertly crafted to demonstrate the fusion of Streamlit's user-friendly design and OpenAI's powerful GPT-3.5 model. Here are its highlights:
|
35 |
|
36 |
<ul style='text-align: left;'>
|
37 |
+
<li><strong>Intuitive Interface</strong>: Built with Streamlit, ChatMate offers a clean, responsive OpenAI-ChatGPT-like user experience, allowing for natural dialogue with the AI.</li>
|
38 |
+
<li><strong>Advanced NLP</strong>: Incorporating OpenAI's most advanced GPT model, the app provides nuanced understanding and generation of human-like text.</li>
|
39 |
<li><strong>State Management</strong>: Utilizes <code>ConversationChain</code> and <code>ConversationMemory</code> from <code>langchain</code> to preserve the context and flow, ensuring coherent and engaging interactions.</li>
|
40 |
<li><strong>Python Proficiency</strong>: The app's robust backend, written in Python, reflects the data scientist’s adeptness in programming and system design.</li>
|
41 |
<li><strong>Secure Interaction</strong>: Streamlit's session state management is used for secure API key handling and user input retention across sessions.</li>
|
42 |
</ul>
|
|
|
|
|
43 |
""", unsafe_allow_html=True)
|
44 |
+
st.markdown("<p style='text-align: right'>By <a href='https://entzyeung.github.io/portfolio/index.html'>Lorentz Yeung</a></p>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
|
47 |
# Function to get response from the model
|
|
|
70 |
|
71 |
|
72 |
response_container = st.container()
|
73 |
+
# container for user input text box
|
74 |
container = st.container()
|
75 |
|
76 |
# User input and response display
|
|
|
88 |
with response_container:
|
89 |
for i in range(len(st.session_state['messages'])):
|
90 |
if (i % 2) == 0:
|
91 |
+
message(st.session_state['messages'][i], is_user=True, key=str(i) + '_user', avatar_style="")
|
92 |
else:
|
93 |
+
message(st.session_state['messages'][i], key=str(i) + '_AI', avatar_style="")
|
94 |
|
95 |
|