prompt engineering

modified:   app.py
	modified:   research/activity19-rock-paper-scissors.yaml
This commit is contained in:
Russell Ballestrini 2024-08-10 19:15:19 -04:00
parent 2609ff993d
commit f923570f5a
2 changed files with 35 additions and 21 deletions

2
app.py
View file

@ -2604,7 +2604,7 @@ def provide_feedback(
def translate_text(text, target_language):
# Guard clause for default language
if target_language.lower() == "english":
if " english" in target_language.lower():
return text
openai_client, model_name = get_openai_client_and_model()

View file

@ -3,35 +3,43 @@ sections:
- section_id: "section_1"
title: "Rock-Paper-Scissors with History"
steps:
- step_id: "step_1"
- step_id: "step_0"
title: "Challenge a Historical Figure"
content_blocks:
- "Welcome to the Rock-Paper-Scissors challenge! 🎮"
- "You will be playing against a random historical figure. Make your choice: rock, paper, or scissors."
- "You will be playing against a random historical figure."
- step_id: "step_1"
title: "Shoot against a Historical Figure"
tokens_for_ai: |
Determine who wins the game, use 'user_choice2' against the given value.
Careful to check if user is trying to 'set_language' and do that first. otherwise figure out if they are picking the bucket rock, paper, or scissors.
feedback_tokens_for_ai: |
Speaking in first person as a historical firgure, firstly announce your move based on the metadata and then on a new line,
Determine who wins the game, use 'user_choice' against the given `ai_` value.
The rules are simple:
* rock beats scissors
* paper beats rock
* rock beats scissors
* rock always beats scissors
* paper always beats rock
* scissors always beats paper
Finally continue to provide a witty fact as the figure. Don't ever mention AI.
The figure should also comment on the 'attempts' number and how many times played!
if you feel like it, jeer at the player about an early 'exit' & suggest they quit.
and provide a witty fact from the historical figure's perspective."
question: "What's your choice? Rock, paper, or scissors? 🤔"
buckets:
- rock
- paper
- scissors
- set_language
- exit
transitions:
rock:
content_blocks:
- "You chose rock! Let's see what the historical figure picked... 🪨"
ai_feedback:
tokens_for_ai: "Declare you move and then determine who wins the game and provide a witty fact from the historical figure's perspective."
tokens_for_ai: "Declare your move and then determine who wins the game and provide a witty fact from the historical figure's perspective."
metadata_add:
attempts: "n+1"
metadata_tmp_add:
#user_choice: "the-users-response"
user_choice: "rock"
metadata_tmp_random:
ai_rock: true
@ -39,12 +47,11 @@ sections:
ai_scissors: true
next_section_and_step: "section_1:step_1"
paper:
content_blocks:
- "You chose paper! Let's see what the historical figure picked... 📄"
ai_feedback:
tokens_for_ai: "Declare you move and then determine who wins the game and provide a witty fact from the historical figure's perspective."
tokens_for_ai: "Declare your move and then determine who wins the game and provide a witty fact from the historical figure's perspective."
metadata_add:
attempts: "n+1"
metadata_tmp_add:
#user_choice: "the-users-response"
user_choice: "paper"
metadata_tmp_random:
ai_rock: true
@ -52,20 +59,27 @@ sections:
ai_scissors: true
next_section_and_step: "section_1:step_1"
scissors:
content_blocks:
- "You chose scissors! Let's see what the historical figure picked... ✂️"
ai_feedback:
tokens_for_ai: "Declare you move and Determine who wins the game and provide a witty fact from the historical figure's perspective."
tokens_for_ai: "Declare your move and determine who wins the game and provide a witty fact from the historical figure's perspective."
metadata_add:
attempts: "n+1"
metadata_tmp_add:
#user_choice: "the-users-response"
user_choice: "scissors"
metadata_tmp_random:
ai_rock: true
ai_paper: true
ai_scissors: true
next_section_and_step: "section_1:step_1"
set_language:
content_blocks:
- "Language preference updated. Please continue in your preferred language."
ai_feedback:
tokens_for_ai: "Acknowledge the language change and confirm the update."
metadata_add:
language: "the-users-response"
counts_as_attempt: false
exit:
next_section_and_step: "section_1:step_1"
next_section_and_step: "section_2:step_1"
- section_id: "section_2"
title: "Goodbye"