Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse files
app.py
CHANGED
@@ -302,13 +302,7 @@ def main():
|
|
302 |
|
303 |
teapot_ai = TeapotAI(documents=[], settings=TeapotAISettings(rag_num_results=3, log_level="debug"))
|
304 |
|
305 |
-
|
306 |
-
if "messages" not in st.session_state:
|
307 |
-
st.session_state.messages = [{"role": "assistant", "content": "Hi, I am Teapot AI, how can I help you?"}]
|
308 |
-
|
309 |
-
for message in st.session_state.messages:
|
310 |
-
with st.chat_message(message["role"]):
|
311 |
-
st.markdown(message["content"])
|
312 |
|
313 |
list1 = ["Tell me about teapotllm", "What is Teapot AI?","What devices can Teapot run on?","Who are you?"]
|
314 |
list2 = ["Who invented quantum mechanics?", "Who are the authors of attention is all you need", "Tell me about popular places to travel in France","Summarize the book irobot", "Explain artificial intelligence","what are the key ingredients of bouillabaisse"]
|
@@ -321,40 +315,35 @@ def main():
|
|
321 |
choice2 = random.choice(list2)
|
322 |
choice3 = random.choice(list3)
|
323 |
|
324 |
-
|
325 |
-
# Initialize user_suggested_input in session_state if it doesn't exist
|
326 |
-
if 'user_suggested_input' not in st.session_state:
|
327 |
-
st.session_state.user_suggested_input = None
|
328 |
-
|
329 |
-
# Define columns
|
330 |
s1, s2, s3 = st.columns([1, 1, 1])
|
331 |
|
332 |
-
|
|
|
333 |
with s1:
|
334 |
if st.button(choice1, use_container_width=True):
|
335 |
-
|
336 |
|
337 |
with s2:
|
338 |
if st.button(choice2, use_container_width=True):
|
339 |
-
|
340 |
|
341 |
with s3:
|
342 |
if st.button(choice3, use_container_width=True):
|
343 |
-
|
|
|
|
|
|
|
344 |
|
345 |
-
|
346 |
-
|
|
|
347 |
|
348 |
-
|
349 |
-
|
|
|
350 |
with st.spinner('Generating Response...'):
|
351 |
-
response = handle_chat(user_prompt,
|
352 |
-
|
353 |
-
|
354 |
-
# Reset the input field after generating the response if needed
|
355 |
-
if user_input or st.session_state.user_suggested_input:
|
356 |
-
st.session_state.user_suggested_input = None # Reset suggested input after processing
|
357 |
-
|
358 |
|
359 |
if __name__ == "__main__":
|
360 |
main()
|
|
|
302 |
|
303 |
teapot_ai = TeapotAI(documents=[], settings=TeapotAISettings(rag_num_results=3, log_level="debug"))
|
304 |
|
305 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
306 |
|
307 |
list1 = ["Tell me about teapotllm", "What is Teapot AI?","What devices can Teapot run on?","Who are you?"]
|
308 |
list2 = ["Who invented quantum mechanics?", "Who are the authors of attention is all you need", "Tell me about popular places to travel in France","Summarize the book irobot", "Explain artificial intelligence","what are the key ingredients of bouillabaisse"]
|
|
|
315 |
choice2 = random.choice(list2)
|
316 |
choice3 = random.choice(list3)
|
317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
s1, s2, s3 = st.columns([1, 1, 1])
|
319 |
|
320 |
+
user_suggested_input = None
|
321 |
+
|
322 |
with s1:
|
323 |
if st.button(choice1, use_container_width=True):
|
324 |
+
user_suggested_input = choice1
|
325 |
|
326 |
with s2:
|
327 |
if st.button(choice2, use_container_width=True):
|
328 |
+
user_suggested_input = choice2
|
329 |
|
330 |
with s3:
|
331 |
if st.button(choice3, use_container_width=True):
|
332 |
+
user_suggested_input = choice3
|
333 |
+
|
334 |
+
if "messages" not in st.session_state:
|
335 |
+
st.session_state.messages = [{"role": "assistant", "content": "Hi, I am Teapot AI, how can I help you?"}]
|
336 |
|
337 |
+
for message in st.session_state.messages:
|
338 |
+
with st.chat_message(message["role"]):
|
339 |
+
st.markdown(message["content"])
|
340 |
|
341 |
+
user_input = st.chat_input("Ask me anything")
|
342 |
+
|
343 |
+
if user_input:
|
344 |
with st.spinner('Generating Response...'):
|
345 |
+
response = handle_chat(user_prompt, user_suggested_input or user_input, teapot_ai)
|
346 |
+
|
|
|
|
|
|
|
|
|
|
|
347 |
|
348 |
if __name__ == "__main__":
|
349 |
main()
|