Ezhil
commited on
Commit
Β·
dbbb4e2
1
Parent(s):
0da0ed7
TEST-2
Browse files
main.py
CHANGED
|
@@ -26,12 +26,8 @@ st.title("π³ Finance & Banking Chatbot π€΅")
|
|
| 26 |
|
| 27 |
# Display previous messages in the chat area
|
| 28 |
for msg in st.session_state.messages:
|
| 29 |
-
if msg["role"] == "user":
|
| 30 |
-
|
| 31 |
-
st.markdown(f"<div style='text-align: right;'>{msg['content']}</div>", unsafe_allow_html=True)
|
| 32 |
-
else:
|
| 33 |
-
with st.chat_message("assistant", avatar="π€΅"):
|
| 34 |
-
st.markdown(f"<div style='text-align: left;'>{msg['content']}</div>", unsafe_allow_html=True)
|
| 35 |
|
| 36 |
# User input field
|
| 37 |
user_input = st.chat_input("Ask me about finance, banking, investments, etc. π")
|
|
@@ -40,7 +36,7 @@ if user_input:
|
|
| 40 |
# Add user message to history
|
| 41 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 42 |
with st.chat_message("user", avatar="π¦π»"):
|
| 43 |
-
st.markdown(
|
| 44 |
|
| 45 |
# Get response from Groq API
|
| 46 |
response = client.chat.completions.create(
|
|
@@ -54,4 +50,4 @@ if user_input:
|
|
| 54 |
# Add bot response to history
|
| 55 |
st.session_state.messages.append({"role": "assistant", "content": bot_reply})
|
| 56 |
with st.chat_message("assistant", avatar="π€΅"):
|
| 57 |
-
st.markdown(
|
|
|
|
| 26 |
|
| 27 |
# Display previous messages in the chat area
|
| 28 |
for msg in st.session_state.messages:
|
| 29 |
+
with st.chat_message(msg["role"], avatar=("π¦π»" if msg["role"] == "user" else "π€΅")):
|
| 30 |
+
st.markdown(msg["content"])
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
# User input field
|
| 33 |
user_input = st.chat_input("Ask me about finance, banking, investments, etc. π")
|
|
|
|
| 36 |
# Add user message to history
|
| 37 |
st.session_state.messages.append({"role": "user", "content": user_input})
|
| 38 |
with st.chat_message("user", avatar="π¦π»"):
|
| 39 |
+
st.markdown(user_input)
|
| 40 |
|
| 41 |
# Get response from Groq API
|
| 42 |
response = client.chat.completions.create(
|
|
|
|
| 50 |
# Add bot response to history
|
| 51 |
st.session_state.messages.append({"role": "assistant", "content": bot_reply})
|
| 52 |
with st.chat_message("assistant", avatar="π€΅"):
|
| 53 |
+
st.markdown(bot_reply)
|