acecalisto3 commited on
Commit
2bfabfb
·
verified ·
1 Parent(s): 61749a1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -60,10 +60,7 @@ for message in chat_history:
60
  st.write(message[1])
61
 
62
  # User input area
63
- user_input = st.text_input("Enter your message or code:", key="input")
64
-
65
- # Process user input when Enter is pressed
66
- if user_input:
67
  chat_history = chat_with_code(user_input)
68
 
69
  # Display updated chat history
@@ -72,5 +69,6 @@ if user_input:
72
  if message[1]:
73
  st.write(message[1])
74
 
75
- # Clear the input field
76
- st.session_state.input = ""
 
 
60
  st.write(message[1])
61
 
62
  # User input area
63
+ def handle_input(user_input):
 
 
 
64
  chat_history = chat_with_code(user_input)
65
 
66
  # Display updated chat history
 
69
  if message[1]:
70
  st.write(message[1])
71
 
72
+ st.session_state.input = "" # Clear the input field
73
+
74
+ user_input = st.text_input("Enter your message or code:", key="input", on_change=handle_input)