Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -10,17 +10,19 @@ title = st.text_input("Title of the Story:")
|
|
10 |
character = st.text_input("Character (Hero) Name:")
|
11 |
era = st.selectbox("Era of the Story:", ["Medieval", "Modern", "Future"])
|
12 |
genre = st.selectbox("Genre:", ["Action", "Novelistic", "Love"])
|
13 |
-
|
|
|
|
|
14 |
|
15 |
-
if
|
16 |
-
if title and character:
|
17 |
# Prepare a structured prompt for the story
|
18 |
-
prompt = f"Write a {genre} story titled '{title}' set in the {era} era. The main character, {character}, faces a {genre} adventure.
|
19 |
-
|
20 |
# Generate the story
|
21 |
set_seed(42) # Set a seed for reproducibility
|
22 |
-
full_story = text_generator(prompt, max_length=
|
23 |
-
|
24 |
st.markdown(full_story)
|
25 |
else:
|
26 |
-
st.warning("Please provide a title
|
|
|
10 |
character = st.text_input("Character (Hero) Name:")
|
11 |
era = st.selectbox("Era of the Story:", ["Medieval", "Modern", "Future"])
|
12 |
genre = st.selectbox("Genre:", ["Action", "Novelistic", "Love"])
|
13 |
+
punchline = st.text_area("Punchline (Describe what the story is about):")
|
14 |
+
story_length = st.slider("Story Length", min_value=100, max_value=2000, step=100)
|
15 |
+
generate_button = st.button("Generate Story")
|
16 |
|
17 |
+
if generate_button:
|
18 |
+
if title and character and punchline:
|
19 |
# Prepare a structured prompt for the story
|
20 |
+
prompt = f"Write a {genre} story titled '{title}' set in the {era} era. The main character, {character}, faces a {genre} adventure. The story is about '{punchline}'."
|
21 |
+
|
22 |
# Generate the story
|
23 |
set_seed(42) # Set a seed for reproducibility
|
24 |
+
full_story = text_generator(prompt, max_length=story_length, do_sample=True)[0]["generated_text"]
|
25 |
+
|
26 |
st.markdown(full_story)
|
27 |
else:
|
28 |
+
st.warning("Please provide a title, character name, and punchline.")
|