Ezhil commited on
Commit
0da0ed7
Β·
1 Parent(s): 2d3d9fc
Files changed (1) hide show
  1. main.py +8 -15
main.py CHANGED
@@ -7,10 +7,6 @@ client = Groq(api_key="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"
7
  # Streamlit app UI
8
  st.set_page_config(page_title="πŸ’° Finance & Banking Chatbot", layout="wide")
9
 
10
- # # Sidebar for chat history
11
- # st.sidebar.title("πŸ—‚ Chat History")
12
- # st.sidebar.write("Review your past finance-related conversations here.")
13
-
14
  # System prompt to enforce finance-related responses
15
  SYSTEM_PROMPT = (
16
  "You are an expert financial assistant. Your role is to answer ONLY finance-related topics, including banking, investments, "
@@ -25,22 +21,17 @@ if "messages" not in st.session_state:
25
  {"role": "assistant", "content": "Hello! I can help you with financial questions. How can I assist? πŸ’³"}
26
  ]
27
 
28
- # # Display chat history in the sidebar
29
- # for msg in st.session_state.messages:
30
- # if msg["role"] == "user":
31
- # st.sidebar.write(f"πŸ‘€ **You**: {msg['content']}")
32
- # else:
33
- # st.sidebar.write(f"πŸ€– **Bot**: {msg['content']}")
34
-
35
  # Main chat interface
36
  st.title("πŸ’³ Finance & Banking Chatbot 🀡")
37
 
38
  # Display previous messages in the chat area
39
  for msg in st.session_state.messages:
40
  if msg["role"] == "user":
41
- st.chat_message("user", avatar="πŸ‘¦πŸ»").write(msg["content"])
 
42
  else:
43
- st.chat_message("assistant", avatar="🀡").write(msg["content"])
 
44
 
45
  # User input field
46
  user_input = st.chat_input("Ask me about finance, banking, investments, etc. πŸ“ˆ")
@@ -48,7 +39,8 @@ user_input = st.chat_input("Ask me about finance, banking, investments, etc.
48
  if user_input:
49
  # Add user message to history
50
  st.session_state.messages.append({"role": "user", "content": user_input})
51
- st.chat_message("user", avatar="πŸ‘¦πŸ»").write(user_input)
 
52
 
53
  # Get response from Groq API
54
  response = client.chat.completions.create(
@@ -61,4 +53,5 @@ if user_input:
61
 
62
  # Add bot response to history
63
  st.session_state.messages.append({"role": "assistant", "content": bot_reply})
64
- st.chat_message("assistant", avatar="🀡").write(bot_reply)
 
 
7
  # Streamlit app UI
8
  st.set_page_config(page_title="πŸ’° Finance & Banking Chatbot", layout="wide")
9
 
 
 
 
 
10
  # System prompt to enforce finance-related responses
11
  SYSTEM_PROMPT = (
12
  "You are an expert financial assistant. Your role is to answer ONLY finance-related topics, including banking, investments, "
 
21
  {"role": "assistant", "content": "Hello! I can help you with financial questions. How can I assist? πŸ’³"}
22
  ]
23
 
 
 
 
 
 
 
 
24
  # Main chat interface
25
  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
+ with st.chat_message("user", avatar="πŸ‘¦πŸ»"):
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. πŸ“ˆ")
 
39
  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(f"<div style='text-align: right;'>{user_input}</div>", unsafe_allow_html=True)
44
 
45
  # Get response from Groq API
46
  response = client.chat.completions.create(
 
53
 
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(f"<div style='text-align: left;'>{bot_reply}</div>", unsafe_allow_html=True)