File size: 1,239 Bytes
bdb2da1
 
 
 
 
 
 
 
 
25b33a6
bdb2da1
25b33a6
 
bdb2da1
 
 
 
 
 
 
25b33a6
 
 
 
 
 
 
 
 
 
 
 
bdb2da1
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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()