|
2 | 2 | # |
3 | 3 | # SPDX-License-Identifier: MPL-2.0 |
4 | 4 |
|
5 | | -import os |
6 | 5 | import re |
7 | 6 | from arduino.app_bricks.cloud_llm import CloudLLM, CloudModel |
8 | 7 | from arduino.app_bricks.web_ui import WebUI |
@@ -35,16 +34,13 @@ def generate_story(_, data): |
35 | 34 | prompt_for_display += " Characters of the story: " |
36 | 35 | char_prompts = [] |
37 | 36 | for i, char in enumerate(characters): |
38 | | - name = char.get('name') |
39 | | - role = char.get('role') |
40 | | - description = char.get('description') or '' # Ensure description is not None |
41 | | - |
42 | | - char_prompts.append(f"Character {i+1} (<strong>{description}</strong>, <strong>{name}</strong>, <strong>{role}</strong>)") |
| 37 | + ch = f"Character {i+1} (<strong>{char.get('name')}</strong>, <strong>{char.get('role')}</strong>" |
| 38 | + ch += f", <strong>{char.get('description')}</strong>)" if char.get('description') else ")" |
| 39 | + char_prompts.append(ch) |
43 | 40 | prompt_for_display += ", ".join(char_prompts) |
| 41 | + prompt_for_display += "." |
44 | 42 |
|
45 | | - prompt_for_display += "." |
46 | | - |
47 | | - prompt_for_display += f". The story type is <strong>{theme}</strong>. The tone should be <strong>{tone}</strong>. The format should be a narrative-style story with a clear beginning, middle, and end, allowing for a smooth and engaging reading experience. The objective is to entertain and soothe the child before bedtime. Provide a brief introduction to set the scene and introduce the main character. The scope should revolve around the topic: managing emotions and conflicts. The length should be approximately <strong>{duration}</strong>. Please ensure the story has a <strong>{narrative_structure}</strong> narrative structure, leaving the child with a sense of <strong>{ending_type}</strong>. The language should be easy to understand and suitable for my child's age comprehension." |
| 43 | + prompt_for_display += f" The story type is <strong>{theme}</strong>. The tone should be <strong>{tone}</strong>. The format should be a narrative-style story with a clear beginning, middle, and end, allowing for a smooth and engaging reading experience. The objective is to entertain and soothe the child before bedtime. Provide a brief introduction to set the scene and introduce the main character. The scope should revolve around the topic: managing emotions and conflicts. The length should be approximately <strong>{duration}</strong>. Please ensure the story has a <strong>{narrative_structure}</strong> narrative structure, leaving the child with a sense of <strong>{ending_type}</strong>. The language should be easy to understand and suitable for my child's age comprehension." |
48 | 44 | if other: |
49 | 45 | prompt_for_display += f"\n\nOther on optional stuff for the story: <strong>{other}</strong>" |
50 | 46 |
|
|
0 commit comments