Update app.py
Browse files
app.py
CHANGED
|
@@ -30,7 +30,8 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
| 30 |
with st.chat_message("assistant"):
|
| 31 |
message_placeholder = st.empty()
|
| 32 |
full_response = ""
|
| 33 |
-
|
|
|
|
| 34 |
model=st.session_state["openai_model"],
|
| 35 |
instructions = grounding,
|
| 36 |
input=[
|
|
@@ -38,11 +39,14 @@ if prompt := st.chat_input("How can I help you today?"):
|
|
| 38 |
for m in st.session_state.messages
|
| 39 |
],
|
| 40 |
stream=True,
|
| 41 |
-
)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
message_placeholder.markdown(full_response)
|
| 47 |
print(full_response)
|
|
|
|
| 48 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|
|
|
|
| 30 |
with st.chat_message("assistant"):
|
| 31 |
message_placeholder = st.empty()
|
| 32 |
full_response = ""
|
| 33 |
+
|
| 34 |
+
response = openai.responses.create(
|
| 35 |
model=st.session_state["openai_model"],
|
| 36 |
instructions = grounding,
|
| 37 |
input=[
|
|
|
|
| 39 |
for m in st.session_state.messages
|
| 40 |
],
|
| 41 |
stream=True,
|
| 42 |
+
)
|
| 43 |
+
|
| 44 |
+
for chunk in response:
|
| 45 |
+
if chunk.choices[0].delta.content is not None:
|
| 46 |
+
full_response += chunk.choices[0].delta.content.replace('\\$','$').replace('$','\\$')
|
| 47 |
+
message_placeholder.markdown(full_response + "▌")
|
| 48 |
+
|
| 49 |
message_placeholder.markdown(full_response)
|
| 50 |
print(full_response)
|
| 51 |
+
|
| 52 |
st.session_state.messages.append({"role": "assistant", "content": full_response})
|