Update app.py
Browse files
app.py
CHANGED
|
@@ -10,23 +10,23 @@ def img2text(url):
|
|
| 10 |
|
| 11 |
# text2story
|
| 12 |
def text2story(text):
|
| 13 |
-
messages = f"""Generate a vivid story in 100-120 words using the following sentences: "{text}".
|
| 14 |
-
Structure requirements:
|
| 15 |
-
1. Only 1 paragraphs and the story mest have beginning, middle, end
|
| 16 |
-
2. Include at least two named characters
|
| 17 |
-
3. Use descriptive language
|
| 18 |
|
| 19 |
-
Story:"""
|
| 20 |
#messages = f"""Generate a story of about 100 words using the following sentences: {text}."""
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
text_to_story_model= pipeline("text-generation", model="
|
| 26 |
story_text = text_to_story_model(
|
| 27 |
messages,
|
| 28 |
-
max_length=
|
| 29 |
-
min_length=
|
| 30 |
do_sample=True,
|
| 31 |
temperature=0.65
|
| 32 |
)[0]['generated_text']
|
|
|
|
| 10 |
|
| 11 |
# text2story
|
| 12 |
def text2story(text):
|
| 13 |
+
#messages = f"""Generate a vivid story in 100-120 words using the following sentences: "{text}".
|
| 14 |
+
#Structure requirements:
|
| 15 |
+
#1. Only 1 paragraphs and the story mest have beginning, middle, end
|
| 16 |
+
#2. Include at least two named characters
|
| 17 |
+
#3. Use descriptive language
|
| 18 |
|
| 19 |
+
#Story:"""
|
| 20 |
#messages = f"""Generate a story of about 100 words using the following sentences: {text}."""
|
| 21 |
+
messages = [
|
| 22 |
+
{"role": "system", "content": "You are Qwen, created by Alibaba Cloud. You are a helpful assistant."},
|
| 23 |
+
{"role": "user", "content": f"""Please help generate a vivid story in 100-300 words using the following sentences: "{text}".The story must contain:Beginning, middle, end and use descriptive language"""},
|
| 24 |
+
]
|
| 25 |
+
text_to_story_model= pipeline("text-generation", model="Qwen/Qwen2.5-0.5B-Instruct")
|
| 26 |
story_text = text_to_story_model(
|
| 27 |
messages,
|
| 28 |
+
max_length=400,
|
| 29 |
+
min_length=100,
|
| 30 |
do_sample=True,
|
| 31 |
temperature=0.65
|
| 32 |
)[0]['generated_text']
|