mkoot007 commited on
Commit
be452dc
·
1 Parent(s): a7ef976

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
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
- ending = st.selectbox("Ending:", ["Happy", "Sad"])
 
 
14
 
15
- if st.button("Generate Story"):
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. In the end, the story has a {ending} ending."
19
-
20
  # Generate the story
21
  set_seed(42) # Set a seed for reproducibility
22
- full_story = text_generator(prompt, max_length=1000, do_sample=True)[0]["generated_text"]
23
-
24
  st.markdown(full_story)
25
  else:
26
- st.warning("Please provide a title and character name.")
 
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.")