Spaces:
Sleeping
Sleeping
TomMoule91
commited on
Commit
•
ec3b425
1
Parent(s):
c2c49fc
Update app.py
Browse files
app.py
CHANGED
@@ -4,17 +4,21 @@ from transformers import pipeline
|
|
4 |
# Load the text generation pipeline
|
5 |
generator = pipeline("text-generation")
|
6 |
|
7 |
-
def generate_bedtime_story(name, interests, friends):
|
8 |
-
story_prompt = f"
|
9 |
-
|
|
|
|
|
|
|
10 |
return story
|
11 |
|
12 |
def main():
|
13 |
st.title("Bedtime Story Generator")
|
14 |
|
15 |
name = st.text_input("Enter the name of the person you're reading to:")
|
16 |
-
|
17 |
-
|
|
|
18 |
|
19 |
if st.button("Generate Story"):
|
20 |
if name and interests and friends:
|
|
|
4 |
# Load the text generation pipeline
|
5 |
generator = pipeline("text-generation")
|
6 |
|
7 |
+
def generate_bedtime_story(name, interests, friends, age):
|
8 |
+
story_prompt = f"I want to tell a bed time story to a child named {name}. I want the story to revolve around some of {name}'s main interests, which are {interests}. I also want the story to include some of {name}'s friends, who are called: {friends}. Make sure the story is suitable for a child of the age {age}."
|
9 |
+
|
10 |
+
|
11 |
+
Once upon a time, there was a child named {name}. {name} loved {', '.join(interests)} and had many friends including {', '.join(friends)}."
|
12 |
+
story = generator(story_prompt, max_length=1000)[0]['generated_text']
|
13 |
return story
|
14 |
|
15 |
def main():
|
16 |
st.title("Bedtime Story Generator")
|
17 |
|
18 |
name = st.text_input("Enter the name of the person you're reading to:")
|
19 |
+
age = st.text_input("Enter the age of the person you're reading to:")
|
20 |
+
interests = st.text_input("Enter some of things the person is interested in:")
|
21 |
+
friends = st.text_input("Enter the names of some of their friends:")
|
22 |
|
23 |
if st.button("Generate Story"):
|
24 |
if name and interests and friends:
|