Spaces:
Sleeping
Sleeping
import streamlit as st | |
from transformers import pipeline | |
# Load the Hugging Face model for text generation | |
model = pipeline("text-generation") | |
# Streamlit app | |
def main(): | |
st.title("Cherry Bot") | |
st.markdown("*Your Companion for Suicide Prevention*") | |
# Add tabs for each chat in the sidebar | |
chat_tabs = st.sidebar.radio("Chats", ["Chat 1", "Chat 2", "Chat 3"]) | |
# Add a sidebar to the app | |
with st.sidebar: | |
st.markdown("# Text Generation Settings") | |
# Slider for adjusting the maximum length of generated text | |
max_length = st.slider("Max Length of Generated Text:", min_value=10, max_value=200, value=50, step=10) | |
# Text input for user to input starting text for generation | |
starting_text = st.text_area(f"Enter starting text for {chat_tabs}:", height=100) | |
# Perform text generation when the user clicks the button | |
if st.button("Generate Text"): | |
if starting_text: | |
# Generate text using the loaded model | |
generated_text = model(starting_text, max_length=max_length)[0]['generated_text'] | |
# Display the generated text | |
st.write("Generated Text:") | |
st.write(generated_text) | |
if __name__ == "__main__": | |
main() | |