create a app that has a text field take a string user in put aligned middle of the page along with a yellow button in the middle called predict and a option to chose 3 models now upon clicking the predict button a text will be shown below
To upload files, please first save the app
import streamlit as st
# Set page config to center align the content
st.set_page_config(layout="wide")
# Create columns for centering
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
# Title
st.title("Text Prediction App")
# Text input field
user_input = st.text_input("Enter your text:", key="user_input")
# Model selection
model_option = st.selectbox(
'Choose a model:',
('Model 1', 'Model 2', 'Model 3')
)
# Predict button with custom styling
predict_clicked = st.button(
"Predict",
type="primary",
key="predict_button",
help="Click to get prediction"
)
# Display prediction when button is clicked
if predict_clicked and user_input:
# This is a mock prediction - in a real app, you would call your model here
st.write("Prediction:")
if model_option == "Model 1":
st.write(f"Model 1 predicts: This is a prediction for '{user_input}'")
elif model_option == "Model 2":
st.write(f"Model 2 predicts: Here's what we think about '{user_input}'")
else:
st.write(f"Model 3 predicts: Analysis complete for '{user_input}'")
elif predict_clicked:
st.warning("Please enter some text first!")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?