ogegadavis254 commited on
Commit
ab7b66b
·
verified ·
1 Parent(s): 6a9d8b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -42
app.py CHANGED
@@ -2,7 +2,6 @@ import streamlit as st
2
  import os
3
  import requests
4
  import json
5
- from streamlit_chat import message
6
 
7
  # Initialize a global variable to store the entire assistant response
8
  entire_assistant_response = ""
@@ -80,21 +79,9 @@ if "history" not in st.session_state:
80
  st.session_state.history = []
81
 
82
  # Create a container for the chat history
83
- chat_placeholder = st.container()
84
 
85
  # Accept user input at the bottom
86
- st.markdown("""
87
- <style>
88
- .input-container {
89
- position: fixed;
90
- bottom: 0;
91
- width: 100%;
92
- background-color: #f0f2f6;
93
- padding: 10px;
94
- }
95
- </style>
96
- """, unsafe_allow_html=True)
97
-
98
  user_input = st.text_input("You:", key="user_input")
99
  send_button = st.button("Send")
100
 
@@ -104,33 +91,8 @@ if send_button and user_input:
104
  history.append((user_input, response))
105
  st.session_state.history = history
106
 
107
- # Display chat history with colors
108
  with chat_placeholder:
109
  for human, assistant in st.session_state.history:
110
- message(human, is_user=True, key=f"user_{human}")
111
- message(assistant, is_user=False, key=f"assistant_{assistant}")
112
-
113
- # Add user input container at the bottom
114
- st.markdown("""
115
- <div class="input-container">
116
- <input type="text" id="input_box" placeholder="You:">
117
- <button onclick="send_message()">Send</button>
118
- </div>
119
- """, unsafe_allow_html=True)
120
-
121
- def send_message():
122
- user_input = st.session_state.get("user_input", "")
123
- if user_input:
124
- history = st.session_state.history
125
- response = get_streamed_response(user_input, history)
126
- history.append((user_input, response))
127
- st.session_state.history = history
128
- st.session_state.user_input = ""
129
-
130
- chat_placeholder.empty()
131
- with chat_placeholder:
132
- for human, assistant in st.session_state.history:
133
- message(human, is_user=True, key=f"user_{human}")
134
- message(assistant, is_user=False, key=f"assistant_{assistant}")
135
-
136
- st.button("Send", on_click=send_message)
 
2
  import os
3
  import requests
4
  import json
 
5
 
6
  # Initialize a global variable to store the entire assistant response
7
  entire_assistant_response = ""
 
79
  st.session_state.history = []
80
 
81
  # Create a container for the chat history
82
+ chat_placeholder = st.empty()
83
 
84
  # Accept user input at the bottom
 
 
 
 
 
 
 
 
 
 
 
 
85
  user_input = st.text_input("You:", key="user_input")
86
  send_button = st.button("Send")
87
 
 
91
  history.append((user_input, response))
92
  st.session_state.history = history
93
 
94
+ # Display chat history with colors and custom styling
95
  with chat_placeholder:
96
  for human, assistant in st.session_state.history:
97
+ st.text(f"You: {human}")
98
+ st.text(f"notDave: {assistant}")