Spaces:
Sleeping
Sleeping
Annaamalai
commited on
Commit
•
d4964da
1
Parent(s):
4c3d3a6
Update app.py
Browse files
app.py
CHANGED
@@ -1,37 +1,32 @@
|
|
1 |
import streamlit as st
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Load the
|
5 |
-
|
6 |
-
model = BigBirdForQuestionAnswering.from_pretrained(model_name)
|
7 |
-
tokenizer = BigBirdTokenizer.from_pretrained(model_name)
|
8 |
|
9 |
# Streamlit app
|
10 |
def main():
|
11 |
-
st.title("
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
st.write("Answer:")
|
34 |
-
st.write(answer)
|
35 |
|
36 |
if __name__ == "__main__":
|
37 |
main()
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load the Hugging Face model for text generation
|
5 |
+
model = pipeline("text-generation")
|
|
|
|
|
6 |
|
7 |
# Streamlit app
|
8 |
def main():
|
9 |
+
st.title("Cherry Bot")
|
10 |
+
st.markdown("*Your Companion for Suicide Prevention*")
|
11 |
+
|
12 |
+
# Add a sidebar to the app
|
13 |
+
with st.sidebar:
|
14 |
+
st.markdown("# Text Generation Settings")
|
15 |
+
# Slider for adjusting the maximum length of generated text
|
16 |
+
max_length = st.slider("Max Length of Generated Text:", min_value=10, max_value=200, value=50, step=10)
|
17 |
+
|
18 |
+
# Text input for user to input starting text for generation
|
19 |
+
starting_text = st.text_area("Enter starting text for generation:", height=100)
|
20 |
+
|
21 |
+
# Perform text generation when the user clicks the button
|
22 |
+
if st.button("Generate Text"):
|
23 |
+
if starting_text:
|
24 |
+
# Generate text using the loaded model
|
25 |
+
generated_text = model(starting_text, max_length=max_length)[0]['generated_text']
|
26 |
+
|
27 |
+
# Display the generated text
|
28 |
+
st.write("Generated Text:")
|
29 |
+
st.write(generated_text)
|
|
|
|
|
|
|
30 |
|
31 |
if __name__ == "__main__":
|
32 |
main()
|