mirror of
https://github.com/xtekky/gpt4free.git
synced 2024-11-03 03:40:12 +00:00
Update streamlit_chat_app.py
This commit is contained in:
parent
8b0cb0cbc1
commit
08f53b3361
@ -74,7 +74,6 @@ user_input = input_placeholder.text_input(
|
|||||||
)
|
)
|
||||||
submit_button = st.button("Submit")
|
submit_button = st.button("Submit")
|
||||||
|
|
||||||
|
|
||||||
if (user_input and user_input != st.session_state['input_text']) or submit_button:
|
if (user_input and user_input != st.session_state['input_text']) or submit_button:
|
||||||
output = query(user_input, st.session_state['query_method'])
|
output = query(user_input, st.session_state['query_method'])
|
||||||
|
|
||||||
@ -84,6 +83,7 @@ if (user_input and user_input != st.session_state['input_text']) or submit_butto
|
|||||||
st.session_state.current_conversation['generated_responses'].append(escaped_output)
|
st.session_state.current_conversation['generated_responses'].append(escaped_output)
|
||||||
save_conversations(st.session_state.conversations, st.session_state.current_conversation)
|
save_conversations(st.session_state.conversations, st.session_state.current_conversation)
|
||||||
st.session_state['input_text'] = ''
|
st.session_state['input_text'] = ''
|
||||||
|
st.session_state['input_field_key'] += 1 # Increment key value for new widget
|
||||||
user_input = input_placeholder.text_input(
|
user_input = input_placeholder.text_input(
|
||||||
'You:', value=st.session_state['input_text'], key=f'input_text_{st.session_state["input_field_key"]}'
|
'You:', value=st.session_state['input_text'], key=f'input_text_{st.session_state["input_field_key"]}'
|
||||||
) # Clear the input field
|
) # Clear the input field
|
||||||
@ -92,9 +92,8 @@ if (user_input and user_input != st.session_state['input_text']) or submit_butto
|
|||||||
if st.sidebar.button("New Conversation"):
|
if st.sidebar.button("New Conversation"):
|
||||||
st.session_state['selected_conversation'] = None
|
st.session_state['selected_conversation'] = None
|
||||||
st.session_state['current_conversation'] = {'user_inputs': [], 'generated_responses': []}
|
st.session_state['current_conversation'] = {'user_inputs': [], 'generated_responses': []}
|
||||||
st.session_state['input_field_key'] += 1
|
st.session_state['input_field_key'] += 1 # Increment key value for new widget
|
||||||
|
st.session_state['query_method'] = st.sidebar.selectbox("Select API:", options=avail_query_methods, index=0)
|
||||||
st.session_state['query_method'] = st.sidebar.selectbox("Select API:", options=avail_query_methods, index=0)
|
|
||||||
|
|
||||||
# Proxy
|
# Proxy
|
||||||
st.session_state['proxy'] = st.sidebar.text_input("Proxy: ")
|
st.session_state['proxy'] = st.sidebar.text_input("Proxy: ")
|
||||||
|
Loading…
Reference in New Issue
Block a user