LeoWalker commited on
Commit
d0e0214
·
1 Parent(s): e0669c7

removed req for key

Browse files
Files changed (1) hide show
  1. streamlit-gpt4o/app.py +32 -31
streamlit-gpt4o/app.py CHANGED
@@ -144,37 +144,38 @@ with st.sidebar:
144
  st.rerun()
145
 
146
 
147
- if not with_message_history:
148
- st.error("Please enter an OpenAI API key in the sidebar.")
149
-
150
- else:
151
- with bottom:
152
- chat_input_dict = multimodal_chatinput(text_color="black")
153
- if chat_input_dict:
154
- chat_input_human_message = chat_input_to_human_message(chat_input_dict)
155
-
156
- with top:
157
- for msg in history.messages:
158
- if msg.type.lower() in ("user", "human"):
159
- with st.chat_message("human"):
160
- render_human_contents(msg)
161
- elif msg.type.lower() in ("ai", "assistant", "aimessagechunk"):
162
- with st.chat_message("ai"):
163
- st.write(msg.content)
164
-
165
- if chat_input_human_message:
166
 
167
- with st.chat_message("human"):
168
- render_human_contents(chat_input_human_message)
 
 
 
 
 
 
169
 
 
 
 
 
 
 
170
  with st.chat_message("ai"):
171
- st.write_stream(
172
- with_message_history.stream(
173
- {"input": [chat_input_human_message]},
174
- {
175
- "configurable": {"session_id": st.session_state.session_id},
176
- },
177
- ),
178
- )
179
-
180
- chat_input_human_message = None
 
 
 
 
 
 
 
 
 
144
  st.rerun()
145
 
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
+ # if not True: #with_message_history:
149
+ # st.error("Please enter an OpenAI API key in the sidebar.")
150
+
151
+ # else:
152
+ with bottom:
153
+ chat_input_dict = multimodal_chatinput(text_color="black")
154
+ if chat_input_dict:
155
+ chat_input_human_message = chat_input_to_human_message(chat_input_dict)
156
 
157
+ with top:
158
+ for msg in history.messages:
159
+ if msg.type.lower() in ("user", "human"):
160
+ with st.chat_message("human"):
161
+ render_human_contents(msg)
162
+ elif msg.type.lower() in ("ai", "assistant", "aimessagechunk"):
163
  with st.chat_message("ai"):
164
+ st.write(msg.content)
165
+
166
+ if chat_input_human_message:
167
+
168
+ with st.chat_message("human"):
169
+ render_human_contents(chat_input_human_message)
170
+
171
+ with st.chat_message("ai"):
172
+ st.write_stream(
173
+ with_message_history.stream(
174
+ {"input": [chat_input_human_message]},
175
+ {
176
+ "configurable": {"session_id": st.session_state.session_id},
177
+ },
178
+ ),
179
+ )
180
+
181
+ chat_input_human_message = None