ccclllwww commited on
Commit
38c8a94
Β·
verified Β·
1 Parent(s): 4204a24

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -22,7 +22,7 @@ _image_caption_pipeline = pipeline(
22
  )
23
 
24
  # Global model configuration constants
25
- _text_generation_pipeline = pipeline("text-generation", model="Qwen/Qwen1.5-0.5B",max_new_tokens=100)
26
 
27
  # Initialize TTS components once to avoid reloading
28
  _SPEECH_PIPELINE = pipeline("text-to-speech", model="microsoft/speecht5_tts")
@@ -82,15 +82,14 @@ def generate_story_content(system_prompt: str, user_prompt: str) -> str:
82
  try:
83
  # Prepare chat message structure
84
  conversation_history = [
85
- {"role": "system", "content": system_prompt},
86
- {"role": "user", "content": user_prompt},
87
  ]
88
 
89
  # Generate the story
90
  story=_text_generation_pipeline(conversation_history)
91
 
92
  # Extract the stroy result
93
- stroy_result=story[0]["generated_text"][2]["content"]
94
 
95
  # Process and clean output
96
  return stroy_result
@@ -259,15 +258,15 @@ if uploaded_image is not None:
259
  # Define prompt templates
260
  PROMPT_TEMPLATES = {
261
  "educational": {
262
- "system": "You are a children's educator. Create a simple 100-word story that teaches basic life skills or moral lessons.",
263
  "icon": "πŸ“š"
264
  },
265
  "adventure": {
266
- "system": "You are a fantasy writer. Create a 100-word magical adventure story suitable for children.",
267
  "icon": "🌠"
268
  },
269
  "animal": {
270
- "system": "You are an animal expert. Create a 100-word story about friendly animals learning together.",
271
  "icon": "🐻"
272
  }
273
  }
 
22
  )
23
 
24
  # Global model configuration constants
25
+ _text_generation_pipeline = pipeline("text-generation", model="Qwen/Qwen3-1.7B")
26
 
27
  # Initialize TTS components once to avoid reloading
28
  _SPEECH_PIPELINE = pipeline("text-to-speech", model="microsoft/speecht5_tts")
 
82
  try:
83
  # Prepare chat message structure
84
  conversation_history = [
85
+ {"role": "user", "content": system_prompt+user_prompt+"/no_think"},
 
86
  ]
87
 
88
  # Generate the story
89
  story=_text_generation_pipeline(conversation_history)
90
 
91
  # Extract the stroy result
92
+ stroy_result=story[0]["generated_text"][1]["content"][19:]
93
 
94
  # Process and clean output
95
  return stroy_result
 
258
  # Define prompt templates
259
  PROMPT_TEMPLATES = {
260
  "educational": {
261
+ "system": "You are a children's educator writer. Create an educational story about ",
262
  "icon": "πŸ“š"
263
  },
264
  "adventure": {
265
+ "system": "You are a fantasy writer. Create a adventure story about ",
266
  "icon": "🌠"
267
  },
268
  "animal": {
269
+ "system": "You are an animal themes writer. Create a animal fairy tales about ",
270
  "icon": "🐻"
271
  }
272
  }