How to add a text box

I would like to know how to add a text box in the web app in which a user can enter the sentence and it will revert back to the function created in the code.

Well, I want to know this because I’ll like to do this fir sentiment analysis where a user will enter a sentence and the model then predict the outcome.

Hi @Pradeep_Rajpurohit,

You can achieve this with st.text_input like this:

sentence = st.text_input('Input your sentence here:') 

if sentence:
    st.write(my_model.predict(sentence))

I hope this helps!

2 Likes