ziyadsuper2017 commited on
Commit
4a3933f
·
1 Parent(s): e23d62d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -52,7 +52,22 @@ for message in chat_history:
52
  st.markdown(content)
53
 
54
  # Accept user input and attachment using chat input widget
55
- user_input, attachment = st.chat_input("Enter a message or a code snippet")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  if user_input or attachment:
58
  # Add user message to chat history
 
52
  st.markdown(content)
53
 
54
  # Accept user input and attachment using chat input widget
55
+ # Get the value from st.chat_input
56
+ value = st.chat_input("Enter a message or a code snippet")
57
+ # Check if the value is a string or a file
58
+ if isinstance(value, str):
59
+ # Assign the value to user_input
60
+ user_input = value
61
+ # Set attachment to None
62
+ attachment = None
63
+ elif isinstance(value, st.uploaded_file_manager.UploadedFile):
64
+ # Assign the value to attachment
65
+ attachment = value
66
+ # Set user_input to None
67
+ user_input = None
68
+ else:
69
+ # Raise an exception if the value is neither a string nor a file
70
+ raise ValueError("Invalid value from st.chat_input")
71
 
72
  if user_input or attachment:
73
  # Add user message to chat history