Spaces:
Sleeping
Sleeping
JohnAlexander23
commited on
Commit
•
743cb15
1
Parent(s):
eae3f9f
Update app.py
Browse files
app.py
CHANGED
@@ -139,60 +139,15 @@ for chat in st.session_state.chat_history:
|
|
139 |
st.markdown("</div>", unsafe_allow_html=True)
|
140 |
|
141 |
# Custom input field
|
142 |
-
st.
|
143 |
-
"""
|
144 |
-
<div class="chat-input">
|
145 |
-
<input type="text" id="chat-input-field" placeholder="Type your message here..." onkeydown="if(event.key === 'Enter'){sendChat();}">
|
146 |
-
<button id="chat-submit-button" onclick="sendChat()">Send</button>
|
147 |
-
</div>
|
148 |
-
<script>
|
149 |
-
function sendChat() {
|
150 |
-
const inputField = document.getElementById('chat-input-field');
|
151 |
-
const message = inputField.value;
|
152 |
-
if (message) {
|
153 |
-
inputField.value = '';
|
154 |
-
fetch('/', {
|
155 |
-
method: 'POST',
|
156 |
-
headers: {
|
157 |
-
'Content-Type': 'application/json'
|
158 |
-
},
|
159 |
-
body: JSON.stringify({ 'user_input': message })
|
160 |
-
}).then(response => {
|
161 |
-
if (response.ok) {
|
162 |
-
location.reload();
|
163 |
-
}
|
164 |
-
});
|
165 |
-
}
|
166 |
-
}
|
167 |
-
</script>
|
168 |
-
""",
|
169 |
-
unsafe_allow_html=True
|
170 |
-
)
|
171 |
|
172 |
-
#
|
173 |
-
st.
|
174 |
-
|
175 |
-
|
176 |
-
<script>
|
177 |
-
function saveSession() {
|
178 |
-
fetch('/save-session', {
|
179 |
-
method: 'POST',
|
180 |
-
headers: {
|
181 |
-
'Content-Type': 'application/json'
|
182 |
-
},
|
183 |
-
}).then(response => {
|
184 |
-
if (response.ok) {
|
185 |
-
location.reload();
|
186 |
-
}
|
187 |
-
});
|
188 |
-
}
|
189 |
-
</script>
|
190 |
-
""",
|
191 |
-
unsafe_allow_html=True
|
192 |
-
)
|
193 |
|
194 |
-
#
|
195 |
-
if st.button("
|
196 |
st.session_state.previous_sessions.append(st.session_state.chat_history)
|
197 |
st.session_state.chat_history = [
|
198 |
{"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper examples to help the user. Try to mention references or provide citations to make it more detail-oriented."}
|
@@ -213,3 +168,4 @@ st.markdown(
|
|
213 |
|
214 |
|
215 |
|
|
|
|
139 |
st.markdown("</div>", unsafe_allow_html=True)
|
140 |
|
141 |
# Custom input field
|
142 |
+
user_input = st.text_input("Enter your question here:")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
143 |
|
144 |
+
# Button to trigger response
|
145 |
+
if st.button("Get Response"):
|
146 |
+
response = fetch_response(user_input)
|
147 |
+
st.write("Response:", response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
148 |
|
149 |
+
# Save session button
|
150 |
+
if st.button("Save Session", key="save_session", help="Save the current chat session", class_="save-session"):
|
151 |
st.session_state.previous_sessions.append(st.session_state.chat_history)
|
152 |
st.session_state.chat_history = [
|
153 |
{"role": "system", "content": "you are a helpful assistant. Take the input from the users and try to provide as detailed response as possible. Provide proper examples to help the user. Try to mention references or provide citations to make it more detail-oriented."}
|
|
|
168 |
|
169 |
|
170 |
|
171 |
+
|