Update app.py
Browse files
app.py
CHANGED
|
@@ -56,58 +56,61 @@ units = st.slider(
|
|
| 56 |
)
|
| 57 |
|
| 58 |
|
| 59 |
-
for message in st.session_state.messages:
|
| 60 |
-
|
| 61 |
-
|
| 62 |
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
# Display assistant response in chat message container
|
| 66 |
-
with st.chat_message("assistant"):
|
| 67 |
message_placeholder = st.empty()
|
| 68 |
full_response = ""
|
| 69 |
-
assistant_response =
|
| 70 |
# Simulate stream of response with milliseconds delay
|
| 71 |
for chunk in assistant_response.split():
|
| 72 |
full_response += chunk + " "
|
| 73 |
time.sleep(0.05)
|
| 74 |
# Add a blinking cursor to simulate typing
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
# Add assistant response to chat history
|
| 78 |
-
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
| 113 |
|
|
|
|
| 56 |
)
|
| 57 |
|
| 58 |
|
| 59 |
+
# for message in st.session_state.messages:
|
| 60 |
+
# with st.chat_message(message["role"]):
|
| 61 |
+
# st.markdown(message["content"])
|
| 62 |
|
| 63 |
+
assistant = st.chat_message("assistant")
|
| 64 |
+
assistant.write("How can I help you today?")
|
| 65 |
|
| 66 |
+
def assistant_response(response):
|
|
|
|
|
|
|
| 67 |
message_placeholder = st.empty()
|
| 68 |
full_response = ""
|
| 69 |
+
assistant_response = response
|
| 70 |
# Simulate stream of response with milliseconds delay
|
| 71 |
for chunk in assistant_response.split():
|
| 72 |
full_response += chunk + " "
|
| 73 |
time.sleep(0.05)
|
| 74 |
# Add a blinking cursor to simulate typing
|
| 75 |
+
assistant.markdown(full_response + "β")
|
| 76 |
+
assistant.markdown(full_response)
|
| 77 |
+
# Add assistant response to chat history
|
| 78 |
+
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
| 79 |
+
|
| 80 |
+
assistant_response("Yah I'm tired af right now boi")
|
| 81 |
+
|
| 82 |
+
|
| 83 |
+
# if prompt := st.chat_input("What kind of class are you looking for?"):
|
| 84 |
+
# # Display user message in chat message container
|
| 85 |
+
# with st.chat_message("user"):
|
| 86 |
+
# st.markdown(prompt)
|
| 87 |
+
# # Add user message to chat history
|
| 88 |
+
# st.session_state.messages.append({"role": "user", "content": prompt})
|
| 89 |
+
|
| 90 |
+
# response = filter_agent(prompt, OPENAI_API)
|
| 91 |
+
# query = response
|
| 92 |
+
|
| 93 |
+
# response = index.query(
|
| 94 |
+
# vector= embeddings.embed_query(query),
|
| 95 |
+
# # filter= build_filter(json),
|
| 96 |
+
# top_k=5,
|
| 97 |
+
# include_metadata=True
|
| 98 |
+
# )
|
| 99 |
+
# response = reranker(query, response)
|
| 100 |
+
# result_query = 'Original Query:' + query + 'Query Results:' + str(response)
|
| 101 |
+
# assistant_response = results_agent(result_query, OPENAI_API)
|
| 102 |
+
|
| 103 |
+
# if assistant_response:
|
| 104 |
+
# with st.chat_message("assistant"):
|
| 105 |
+
# message_placeholder = st.empty()
|
| 106 |
+
# full_response = ""
|
| 107 |
+
# # Simulate stream of response with milliseconds delay
|
| 108 |
+
# for chunk in assistant_response.split():
|
| 109 |
+
# full_response += chunk + " "
|
| 110 |
+
# time.sleep(0.05)
|
| 111 |
+
# # Add a blinking cursor to simulate typing
|
| 112 |
+
# message_placeholder.markdown(full_response + "β")
|
| 113 |
+
# message_placeholder.markdown(full_response)
|
| 114 |
+
# # Add assistant response to chat history
|
| 115 |
+
# st.session_state.messages.append({"role": "assistant", "content": full_response})
|
| 116 |
|