Update app.py
Browse files
app.py
CHANGED
@@ -7,6 +7,7 @@ import os
|
|
7 |
import json
|
8 |
import getpass
|
9 |
import openai
|
|
|
10 |
|
11 |
from langchain.vectorstores import Pinecone
|
12 |
from langchain.embeddings import OpenAIEmbeddings
|
@@ -55,7 +56,7 @@ days = st.multiselect("What days are you free?",
|
|
55 |
)
|
56 |
|
57 |
assistant = st.chat_message("assistant")
|
58 |
-
initial_message = "Hello, I am your GPT-powered USC Class Helper! How can I assist you today?"
|
59 |
|
60 |
|
61 |
|
@@ -148,10 +149,9 @@ if prompt := st.chat_input("What kind of class are you looking for?"):
|
|
148 |
# )["choices"][0]["message"]["content"]
|
149 |
|
150 |
## Display response regardless of route
|
151 |
-
for chunk in
|
152 |
full_response += chunk + " "
|
153 |
-
time.sleep(0.
|
154 |
message_placeholder.markdown(full_response + "▌")
|
155 |
-
message_placeholder.markdown(full_response)
|
156 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
157 |
|
|
|
7 |
import json
|
8 |
import getpass
|
9 |
import openai
|
10 |
+
import re
|
11 |
|
12 |
from langchain.vectorstores import Pinecone
|
13 |
from langchain.embeddings import OpenAIEmbeddings
|
|
|
56 |
)
|
57 |
|
58 |
assistant = st.chat_message("assistant")
|
59 |
+
initial_message = "Hello, I am your GPT-powered USC Class Helper! \n How can I assist you today?"
|
60 |
|
61 |
|
62 |
|
|
|
149 |
# )["choices"][0]["message"]["content"]
|
150 |
|
151 |
## Display response regardless of route
|
152 |
+
for chunk in re.split(r'(\s+)', assistant_response:
|
153 |
full_response += chunk + " "
|
154 |
+
time.sleep(0.02)
|
155 |
message_placeholder.markdown(full_response + "▌")
|
|
|
156 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
157 |
|