Skip to content

Commit eeef679

Browse files
committed
fix prompt msg
1 parent e166a62 commit eeef679

File tree

1 file changed

+5
-9
lines changed
  • examples/bedtime-story-teller/python

1 file changed

+5
-9
lines changed

examples/bedtime-story-teller/python/main.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# SPDX-License-Identifier: MPL-2.0
44

5-
import os
65
import re
76
from arduino.app_bricks.cloud_llm import CloudLLM, CloudModel
87
from arduino.app_bricks.web_ui import WebUI
@@ -35,16 +34,13 @@ def generate_story(_, data):
3534
prompt_for_display += " Characters of the story: "
3635
char_prompts = []
3736
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)
4340
prompt_for_display += ", ".join(char_prompts)
41+
prompt_for_display += "."
4442

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."
4844
if other:
4945
prompt_for_display += f"\n\nOther on optional stuff for the story: <strong>{other}</strong>"
5046

0 commit comments

Comments
 (0)