Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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/
|
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": "
|
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"][
|
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
|
263 |
"icon": "π"
|
264 |
},
|
265 |
"adventure": {
|
266 |
-
"system": "You are a fantasy writer. Create a
|
267 |
"icon": "π "
|
268 |
},
|
269 |
"animal": {
|
270 |
-
"system": "You are an animal
|
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 |
}
|