Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -37,13 +37,13 @@ def text2story(text):
|
|
37 |
str: Generated story suitable for kids aged 3-10, within 100 words.
|
38 |
"""
|
39 |
# Add a prompt to ensure the story is happy, fun, and appropriate for kids
|
40 |
-
prompt = f"Base on the following scenario: {text}, write a happy
|
41 |
|
42 |
# Load the text generation model
|
43 |
story_generator = pipeline("text-generation", model="aspis/gpt2-genre-story-generation")
|
44 |
|
45 |
# Generate the story
|
46 |
-
story = story_generator(prompt, max_length=150, num_return_sequences=1
|
47 |
|
48 |
# Remove the prompt from the generated story
|
49 |
story = story.replace(prompt, "").strip()
|
|
|
37 |
str: Generated story suitable for kids aged 3-10, within 100 words.
|
38 |
"""
|
39 |
# Add a prompt to ensure the story is happy, fun, and appropriate for kids
|
40 |
+
prompt = f"Base on the following scenario: {text}, write a happy and fun story for kids."
|
41 |
|
42 |
# Load the text generation model
|
43 |
story_generator = pipeline("text-generation", model="aspis/gpt2-genre-story-generation")
|
44 |
|
45 |
# Generate the story
|
46 |
+
story = story_generator(prompt, max_length=150, num_return_sequences=1)[0]["generated_text"]
|
47 |
|
48 |
# Remove the prompt from the generated story
|
49 |
story = story.replace(prompt, "").strip()
|