wh1223 commited on
Commit
b1d00fe
·
verified ·
1 Parent(s): 9bfb002

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -13
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
- #messages = [
22
- # {"role": "system", "content": "You are a helpful AI assistant and will write stories based user input.The story must contain:Beginning, middle, end,Character development and around 100 words"},
23
- # {"role": "user", "content": text},
24
- #]
25
- text_to_story_model= pipeline("text-generation", model="microsoft/Phi-4-mini-instruct", trust_remote_code=True)
26
  story_text = text_to_story_model(
27
  messages,
28
- max_length=150,
29
- min_length=50,
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']