Annaamalai commited on
Commit
25b33a6
1 Parent(s): 7118c97

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -7,10 +7,10 @@ model = pipeline("text-generation")
7
  # Streamlit app
8
  def main():
9
  st.title("Cherry Bot")
10
- st.markdown("*Your Sweetest Companion*")
11
 
12
- # Maintain a list to store text inputs for each chat
13
- chat_inputs = []
14
 
15
  # Add a sidebar to the app
16
  with st.sidebar:
@@ -18,21 +18,18 @@ def main():
18
  # Slider for adjusting the maximum length of generated text
19
  max_length = st.slider("Max Length of Generated Text:", min_value=10, max_value=200, value=50, step=10)
20
 
21
- # Add a "New Chat" button
22
- if st.button("New Chat"):
23
- chat_inputs.append(st.text_area(f"Enter starting text for Chat {len(chat_inputs) + 1}:", height=100))
24
-
25
- # Perform text generation for each chat
26
- for idx, starting_text in enumerate(chat_inputs):
27
- st.header(f"Chat {idx + 1}")
28
- if st.button(f"Generate Text for Chat {idx + 1}"):
29
- if starting_text:
30
- # Generate text using the loaded model
31
- generated_text = model(starting_text, max_length=max_length)[0]['generated_text']
32
-
33
- # Display the generated text
34
- st.write("Generated Text:")
35
- st.write(generated_text)
36
 
37
  if __name__ == "__main__":
38
  main()
 
7
  # Streamlit app
8
  def main():
9
  st.title("Cherry Bot")
10
+ st.markdown("*Your Companion for Suicide Prevention*")
11
 
12
+ # Add tabs for each chat in the sidebar
13
+ chat_tabs = st.sidebar.radio("Chats", ["Chat 1", "Chat 2", "Chat 3"])
14
 
15
  # Add a sidebar to the app
16
  with st.sidebar:
 
18
  # Slider for adjusting the maximum length of generated text
19
  max_length = st.slider("Max Length of Generated Text:", min_value=10, max_value=200, value=50, step=10)
20
 
21
+ # Text input for user to input starting text for generation
22
+ starting_text = st.text_area(f"Enter starting text for {chat_tabs}:", height=100)
23
+
24
+ # Perform text generation when the user clicks the button
25
+ if st.button("Generate Text"):
26
+ if starting_text:
27
+ # Generate text using the loaded model
28
+ generated_text = model(starting_text, max_length=max_length)[0]['generated_text']
29
+
30
+ # Display the generated text
31
+ st.write("Generated Text:")
32
+ st.write(generated_text)
 
 
 
33
 
34
  if __name__ == "__main__":
35
  main()