Skip to content

Commit d54538b

Browse files
stefanotorneoMatteo-it
authored andcommitted
fix prompt msg
1 parent e166a62 commit d54538b

File tree

22 files changed

+45
-39
lines changed

22 files changed

+45
-39
lines changed

examples/bedtime-story-teller/assets/app.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,9 @@ function resetStoryView() {
317317
arrow.classList.add('rotated');
318318
container.classList.remove('disabled');
319319
} else {
320-
container.classList.add('disabled');
320+
if (container.id !== 'prompt-container') {
321+
container.classList.add('disabled');
322+
}
321323
content.style.display = 'none';
322324
arrow.classList.remove('rotated');
323325
}
@@ -444,19 +446,26 @@ document.addEventListener('DOMContentLoaded', () => {
444446
});
445447

446448
document.getElementById('copy-story-button').addEventListener('click', () => {
447-
const storyText = document.getElementById('story-response').textContent;
448-
navigator.clipboard.writeText(storyText).then(() => {
449-
const copyButton = document.getElementById('copy-story-button');
450-
const originalHTML = copyButton.innerHTML;
449+
const storyText = document.getElementById('story-response').innerText;
450+
const copyButton = document.getElementById('copy-story-button');
451+
const originalHTML = copyButton.innerHTML;
452+
const textarea = document.createElement('textarea');
453+
textarea.value = storyText;
454+
document.body.appendChild(textarea);
455+
textarea.select();
456+
try {
457+
document.execCommand('copy');
451458
copyButton.textContent = 'Copied!';
452459
copyButton.disabled = true;
453-
setTimeout(() => {
454-
copyButton.innerHTML = originalHTML;
455-
copyButton.disabled = false;
456-
}, 2000);
457-
}, (err) => {
460+
} catch (err) {
458461
console.error('Could not copy text: ', err);
459-
});
462+
}
463+
document.body.removeChild(textarea);
464+
465+
setTimeout(() => {
466+
copyButton.innerHTML = originalHTML;
467+
copyButton.disabled = false;
468+
}, 2000);
460469
});
461470

462471
document.getElementById('generate-randomly-button').addEventListener('click', () => {

examples/bedtime-story-teller/assets/style.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ body {
639639
line-height: 1.6;
640640
white-space: pre-wrap;
641641
overflow-y: auto;
642+
max-height: 60vh; /* Added for fixed height and scrollbar */
642643
}
643644

644645
#prompt-display strong {

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

examples/mascot-jump-game/assets/fonts/fonts.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
2+
* SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
33
*
44
* SPDX-License-Identifier: MPL-2.0
55
*/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
1+
SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
22

33
SPDX-License-Identifier: MPL-2.0

examples/mascot-jump-game/assets/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
2+
SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
33
44
SPDX-License-Identifier: MPL-2.0
55
-->

examples/mascot-jump-game/assets/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
2+
SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
33
44
SPDX-License-Identifier: MPL-2.0
55
*/

examples/object-hunting/assets/app.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
1+
// SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
22
//
33
// SPDX-License-Identifier: MPL-2.0
44

examples/object-hunting/assets/fonts/fonts.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
2+
* SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
33
*
44
* SPDX-License-Identifier: MPL-2.0
55
*/
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
SPDX-FileCopyrightText: Copyright (C) 2025 ARDUINO SA <http://www.arduino.cc>
1+
SPDX-FileCopyrightText: Copyright (C) ARDUINO SRL (http://www.arduino.cc)
22

33
SPDX-License-Identifier: MPL-2.0

0 commit comments

Comments
 (0)