Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,11 +11,25 @@ st.write("This app generates text based on the input prompt using the Gemma mode
|
|
11 |
# Text input for user prompt
|
12 |
prompt = st.text_input("Enter your prompt:", "Once upon a time,")
|
13 |
|
|
|
|
|
|
|
|
|
14 |
# Generate button to trigger text generation
|
15 |
if st.button("Generate Text"):
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
|
|
|
|
|
|
|
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
# Text input for user prompt
|
12 |
prompt = st.text_input("Enter your prompt:", "Once upon a time,")
|
13 |
|
14 |
+
# User controls for output length and creativity
|
15 |
+
max_length = st.slider("Select the maximum output length:", min_value=50, max_value=500, value=100)
|
16 |
+
temperature = st.slider("Adjust the creativity level (temperature):", min_value=0.1, max_value=1.0, value=0.7)
|
17 |
+
|
18 |
# Generate button to trigger text generation
|
19 |
if st.button("Generate Text"):
|
20 |
+
with st.spinner('Generating text...'):
|
21 |
+
try:
|
22 |
+
generated_text = generator(prompt, max_length=max_length, temperature=temperature)[0]['generated_text']
|
23 |
+
except Exception as e:
|
24 |
+
st.error(f"Error generating text: {str(e)}")
|
25 |
+
else:
|
26 |
+
st.success('Text generation complete!')
|
27 |
+
st.markdown("### Generated Text:")
|
28 |
+
st.markdown(generated_text)
|
29 |
|
30 |
+
# About section
|
31 |
+
with st.expander("About"):
|
32 |
+
st.write("""
|
33 |
+
The Gemma Text Generation app uses the powerful Gemma-7b model from Google to generate text.
|
34 |
+
Adjust the sliders to change the length and creativity of the output.
|
35 |
+
""")
|