From a166a71818571ea49a9762bbc42401fee579013e Mon Sep 17 00:00:00 2001 From: Mircea Lungu Date: Fri, 3 Apr 2026 14:53:04 +0200 Subject: [PATCH 1/2] Fix outdated comment about lesson regeneration Co-Authored-By: Claude Opus 4.6 (1M context) --- zeeguu/core/audio_lessons/daily_lesson_generator.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/zeeguu/core/audio_lessons/daily_lesson_generator.py b/zeeguu/core/audio_lessons/daily_lesson_generator.py index eb42d172..d3b75d68 100644 --- a/zeeguu/core/audio_lessons/daily_lesson_generator.py +++ b/zeeguu/core/audio_lessons/daily_lesson_generator.py @@ -64,8 +64,7 @@ def prepare_lesson_generation(self, user, timezone_offset=0, suggestion=None, su # Check if a lesson already exists for today existing_lesson = self.get_todays_lesson_for_user(user, timezone_offset) if existing_lesson.get("lesson_id"): - # If the user provided a topic that differs from the existing lesson's, - # delete the old lesson so a new one can be generated with the topic. + # If the suggestion changed, delete today's lesson and regenerate. existing_topic = existing_lesson.get("suggestion") existing_type = existing_lesson.get("suggestion_type") topic_changed = suggestion and suggestion != existing_topic From 84a6da01277c407218135299377a84a8e30073d7 Mon Sep 17 00:00:00 2001 From: Mircea Lungu Date: Fri, 3 Apr 2026 15:59:32 +0200 Subject: [PATCH 2/2] Use dedicated prompt templates for topic and situation lessons Instead of appending to the default template, select a template that integrates the suggestion into the intro and dialogue instructions. Situations get scene-setting with appropriate character roles; topics get themed dialogue. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../prompts/meaning_lesson--situation-v1.txt | 58 +++++++++++++++++++ .../prompts/meaning_lesson--topic-v1.txt | 58 +++++++++++++++++++ zeeguu/core/audio_lessons/script_generator.py | 18 +++--- 3 files changed, 126 insertions(+), 8 deletions(-) create mode 100644 zeeguu/core/audio_lessons/prompts/meaning_lesson--situation-v1.txt create mode 100644 zeeguu/core/audio_lessons/prompts/meaning_lesson--topic-v1.txt diff --git a/zeeguu/core/audio_lessons/prompts/meaning_lesson--situation-v1.txt b/zeeguu/core/audio_lessons/prompts/meaning_lesson--situation-v1.txt new file mode 100644 index 00000000..93d3bf41 --- /dev/null +++ b/zeeguu/core/audio_lessons/prompts/meaning_lesson--situation-v1.txt @@ -0,0 +1,58 @@ +Create a language learning audio script for the {target_language} word "{origin_word}" meaning "{translation_word}". +Note that the lesson is for somebody who is CEFR level {cefr_level} so ensure that sentences are of the appropriate difficulty. + +The dialogue must be set in this real-world situation: "{suggestion}" +The characters should be in roles appropriate to the situation (e.g. a customer and waiter at a restaurant, a patient and doctor at a clinic, neighbors meeting on the stairway, etc). Choose realistic roles that fit the scenario naturally. + +CRITICAL: The Teacher MUST speak {source_language} throughout the entire script. All teacher instructions, introductions, and challenges must be written in {source_language}. The Man and Woman speak {target_language}. + +IMPORTANT: Output ONLY the script lines below. Do not include any explanations, preambles, or additional text. + +Use this exact format: + + + Teacher: [Introduction in {source_language} setting the scene for the situation. + Explain who the characters are and what is happening. Mention they will hear the word:] + [0.2 seconds] + Man: {origin_word} [0.5 seconds] + Teacher: [Say "with the meaning" in {source_language}] [0.2 seconds] + Teacher: {translation_word}. [1 seconds] + + Create a dialogue of at least 8 lines between Man and Woman using the target word naturally. + The dialogue must feel like a real conversation that would happen in the given situation. + In between lines add one second break annotations with: [1 seconds] + + + + Next, add the teacher's voice with an introduction IN {source_language} inviting the listener + to practice speaking (similar to "Let's practice some key phrases" but in {source_language}). + + Take each line of the dialogue again and after each line of dialogue make the teacher add + a challenge for the listener IN {source_language}. The challenge asks the listener to say + a phrase (diversify how the teacher formulates this): + + Teacher: [Challenge in {source_language} asking "Could you say...?" or similar] [5 seconds] + Man: [3 seconds] + Man: [3 seconds] + + Use as many challenges as possible from the dialogue. + + + + Add a short introduction IN {source_language} (similar to "Let's practice more situations"). + + Do not use the origin word within this introduction. + + Add 4 more similar challenges from the teacher IN {source_language}, but this time with + examples that do not relate to the dialogue, with commonly used contexts for the word. + + +RULES: +- Use only "Teacher:", "Man:", "Woman:" labels +- Include [X seconds] timing for pauses +- CRITICAL: Teacher MUST speak {source_language} for ALL lines. Man/Woman speak {target_language} +- For student response pauses, use [5 seconds] after teacher questions +- For repetitions, use [3 seconds] between repeats +- No explanatory text or translations in the script + + diff --git a/zeeguu/core/audio_lessons/prompts/meaning_lesson--topic-v1.txt b/zeeguu/core/audio_lessons/prompts/meaning_lesson--topic-v1.txt new file mode 100644 index 00000000..114dce3d --- /dev/null +++ b/zeeguu/core/audio_lessons/prompts/meaning_lesson--topic-v1.txt @@ -0,0 +1,58 @@ +Create a language learning audio script for the {target_language} word "{origin_word}" meaning "{translation_word}". +Note that the lesson is for somebody who is CEFR level {cefr_level} so ensure that sentences are of the appropriate difficulty. + +The dialogue should revolve around the topic: "{suggestion}" +The examples and challenges should use vocabulary relevant to this topic. + +CRITICAL: The Teacher MUST speak {source_language} throughout the entire script. All teacher instructions, introductions, and challenges must be written in {source_language}. The Man and Woman speak {target_language}. + +IMPORTANT: Output ONLY the script lines below. Do not include any explanations, preambles, or additional text. + +Use this exact format: + + + Teacher: [Introduction in {source_language} explaining that in the following conversation + they will hear a man and woman talking about {suggestion}. Mention they will hear the word:] + [0.2 seconds] + Man: {origin_word} [0.5 seconds] + Teacher: [Say "with the meaning" in {source_language}] [0.2 seconds] + Teacher: {translation_word}. [1 seconds] + + Create a dialogue of at least 8 lines between Man and Woman using the target word naturally. + The dialogue should be themed around {suggestion}. + In between lines add one second break annotations with: [1 seconds] + + + + Next, add the teacher's voice with an introduction IN {source_language} inviting the listener + to practice speaking (similar to "Let's practice some key phrases" but in {source_language}). + + Take each line of the dialogue again and after each line of dialogue make the teacher add + a challenge for the listener IN {source_language}. The challenge asks the listener to say + a phrase (diversify how the teacher formulates this): + + Teacher: [Challenge in {source_language} asking "Could you say...?" or similar] [5 seconds] + Man: [3 seconds] + Man: [3 seconds] + + Use as many challenges as possible from the dialogue. + + + + Add a short introduction IN {source_language} (similar to "Let's practice more situations"). + + Do not use the origin word within this introduction. + + Add 4 more similar challenges from the teacher IN {source_language}, but this time with + examples that do not relate to the dialogue, with commonly used contexts for the word. + + +RULES: +- Use only "Teacher:", "Man:", "Woman:" labels +- Include [X seconds] timing for pauses +- CRITICAL: Teacher MUST speak {source_language} for ALL lines. Man/Woman speak {target_language} +- For student response pauses, use [5 seconds] after teacher questions +- For repetitions, use [3 seconds] between repeats +- No explanatory text or translations in the script + + diff --git a/zeeguu/core/audio_lessons/script_generator.py b/zeeguu/core/audio_lessons/script_generator.py index 9bb60b70..92fc1cc7 100644 --- a/zeeguu/core/audio_lessons/script_generator.py +++ b/zeeguu/core/audio_lessons/script_generator.py @@ -71,22 +71,24 @@ def generate_lesson_script( translation_language, translation_language ) - # Load and format the prompt - prompt_template = get_prompt_template(generator_prompt_file) + # Select template based on suggestion type + if suggestion and suggestion_type == "situation": + prompt_file = "meaning_lesson--situation-v1.txt" + elif suggestion and suggestion_type == "topic": + prompt_file = "meaning_lesson--topic-v1.txt" + else: + prompt_file = generator_prompt_file + + prompt_template = get_prompt_template(prompt_file) prompt = prompt_template.format( origin_word=origin_word, translation_word=translation_word, target_language=origin_lang_name, source_language=translation_lang_name, cefr_level=cefr_level, + suggestion=suggestion or "", ) - if suggestion: - if suggestion_type == "situation": - prompt += f'\nSITUATION: Structure the lesson as a roleplay scenario: "{suggestion}". The dialogue should simulate a real conversation the learner might have in this situation.\n' - else: - prompt += f'\nTOPIC: Set the dialogue scenario in a context related to "{suggestion}". The examples and challenges should use vocabulary relevant to this topic.\n' - log(f"Generating script for {origin_word} -> {translation_word} (topic: {suggestion}, type: {suggestion_type})") try: