Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -50,4 +50,14 @@ if st.session_state.messages[-1]["role"] != "assistant":
|
|
50 |
response = chat_engine.chat(prompt)
|
51 |
st.write(response.response)
|
52 |
message = {"role": "assistant", "content": response.response}
|
53 |
-
st.session_state.messages.append(message) # Add response to message history
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
response = chat_engine.chat(prompt)
|
51 |
st.write(response.response)
|
52 |
message = {"role": "assistant", "content": response.response}
|
53 |
+
st.session_state.messages.append(message) # Add response to message history
|
54 |
+
|
55 |
+
try:
|
56 |
+
if prompt := st.chat_input("Your question"): # Prompt for user input and save to chat history
|
57 |
+
if not openai_api_key.startswith('sk-'):
|
58 |
+
st.warning('Please enter your OpenAI API key!', icon='⚠')
|
59 |
+
else: # Only allow the user to proceed if it appears they've entered a valid OpenAI API key
|
60 |
+
st.session_state.messages.append({"role": "user", "content": prompt})
|
61 |
+
# ... (rest of the code)
|
62 |
+
except Exception as e:
|
63 |
+
st.error(f"An error occurred: {e}")
|