conditionally run processing_script
modified: app.py modified: research/activity22-odds-or-evens.yaml modified: research/activity24-math-plot.yaml modified: research/activity27-tic-tac-toe.yaml modified: research/guarded_ai.py
This commit is contained in:
parent
691e4ab054
commit
df54e6b4aa
5 changed files with 12 additions and 12 deletions
2
app.py
2
app.py
|
|
@ -2326,7 +2326,7 @@ def handle_activity_response(room_name, user_response, username):
|
||||||
activity_state.add_metadata(random_key, random_value)
|
activity_state.add_metadata(random_key, random_value)
|
||||||
|
|
||||||
# Execute the processing script if it exists
|
# Execute the processing script if it exists
|
||||||
if "processing_script" in step:
|
if "processing_script" in step and transition.get("run_processing_script", False):
|
||||||
result = execute_processing_script(
|
result = execute_processing_script(
|
||||||
activity_state.dict_metadata, step["processing_script"]
|
activity_state.dict_metadata, step["processing_script"]
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,7 @@ sections:
|
||||||
- exit
|
- exit
|
||||||
transitions:
|
transitions:
|
||||||
throw_fingers:
|
throw_fingers:
|
||||||
|
run_processing_script: True
|
||||||
ai_feedback:
|
ai_feedback:
|
||||||
tokens_for_ai: "Declare your 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:
|
metadata_add:
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,7 @@ sections:
|
||||||
- exit
|
- exit
|
||||||
transitions:
|
transitions:
|
||||||
correct:
|
correct:
|
||||||
|
run_processing_script: True
|
||||||
ai_feedback:
|
ai_feedback:
|
||||||
tokens_for_ai: "Great job! You correctly described the plot of your function."
|
tokens_for_ai: "Great job! You correctly described the plot of your function."
|
||||||
metadata_add:
|
metadata_add:
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ sections:
|
||||||
ai_moves = metadata.get("ai_moves", [])
|
ai_moves = metadata.get("ai_moves", [])
|
||||||
ai_move = None
|
ai_move = None
|
||||||
board = [" "] * 9
|
board = [" "] * 9
|
||||||
for move in user_moves[:-1]:
|
for move in user_moves:
|
||||||
board[int(move)] = "X"
|
board[int(move)] = "X"
|
||||||
for move in ai_moves:
|
for move in ai_moves:
|
||||||
board[int(move)] = "O"
|
board[int(move)] = "O"
|
||||||
|
|
@ -70,6 +70,7 @@ sections:
|
||||||
# Check if the move is valid
|
# Check if the move is valid
|
||||||
if 0 <= user_move < 9 and board[user_move] == " ":
|
if 0 <= user_move < 9 and board[user_move] == " ":
|
||||||
board[user_move] = "X"
|
board[user_move] = "X"
|
||||||
|
user_moves.append(user_move)
|
||||||
|
|
||||||
user_wins = check_win(board, "X")
|
user_wins = check_win(board, "X")
|
||||||
|
|
||||||
|
|
@ -108,7 +109,7 @@ sections:
|
||||||
}
|
}
|
||||||
|
|
||||||
# Debugging: Print the current board state
|
# Debugging: Print the current board state
|
||||||
#print("Current board state:", board)
|
print("Current board state:", board)
|
||||||
|
|
||||||
buckets:
|
buckets:
|
||||||
- valid_move
|
- valid_move
|
||||||
|
|
@ -116,6 +117,7 @@ sections:
|
||||||
- exit
|
- exit
|
||||||
transitions:
|
transitions:
|
||||||
valid_move:
|
valid_move:
|
||||||
|
run_processing_script: True
|
||||||
ai_feedback:
|
ai_feedback:
|
||||||
tokens_for_ai: |
|
tokens_for_ai: |
|
||||||
Use the processing_script metadata to update the board!
|
Use the processing_script metadata to update the board!
|
||||||
|
|
@ -135,22 +137,14 @@ sections:
|
||||||
|
|
||||||
metadata_tmp_add:
|
metadata_tmp_add:
|
||||||
user_move: "the-users-response"
|
user_move: "the-users-response"
|
||||||
metadata_append:
|
|
||||||
user_moves: "the-users-response"
|
|
||||||
next_section_and_step: "section_1:step_1"
|
next_section_and_step: "section_1:step_1"
|
||||||
invalid_move:
|
invalid_move:
|
||||||
ai_feedback:
|
ai_feedback:
|
||||||
tokens_for_ai: "That move is invalid. Please choose an empty position between 0 and 8."
|
tokens_for_ai: "That move is invalid. Please choose an empty position between 0 and 8."
|
||||||
metadata_tmp_add:
|
metadata_tmp_add:
|
||||||
user_move: "the-users-response"
|
user_move: "the-users-response"
|
||||||
metadata_append:
|
|
||||||
user_moves: "the-users-response"
|
|
||||||
next_section_and_step: "section_1:step_1"
|
next_section_and_step: "section_1:step_1"
|
||||||
exit:
|
exit:
|
||||||
metadata_tmp_add:
|
|
||||||
user_move: "the-users-response"
|
|
||||||
metadata_append:
|
|
||||||
user_moves: "the-users-response"
|
|
||||||
next_section_and_step: "section_1:step_2"
|
next_section_and_step: "section_1:step_2"
|
||||||
|
|
||||||
- step_id: "step_2"
|
- step_id: "step_2"
|
||||||
|
|
|
||||||
|
|
@ -290,11 +290,15 @@ def simulate_activity(yaml_file_path):
|
||||||
metadata_tmp_keys.append(random_key) # Track temporary keys
|
metadata_tmp_keys.append(random_key) # Track temporary keys
|
||||||
|
|
||||||
# Execute the processing script if it exists
|
# Execute the processing script if it exists
|
||||||
if "processing_script" in step:
|
if "processing_script" in step and transition.get("run_processing_script", False):
|
||||||
result = execute_processing_script(metadata, step["processing_script"])
|
result = execute_processing_script(metadata, step["processing_script"])
|
||||||
metadata["processing_script_result"] = result
|
metadata["processing_script_result"] = result
|
||||||
metadata_tmp_keys.append("processing_script_result")
|
metadata_tmp_keys.append("processing_script_result")
|
||||||
|
|
||||||
|
# Update metadata with results from the processing script
|
||||||
|
for key, value in result.get("metadata", {}).items():
|
||||||
|
metadata[key] = value
|
||||||
|
|
||||||
print(f"\nMetadata: {json.dumps(metadata, indent=2)}")
|
print(f"\nMetadata: {json.dumps(metadata, indent=2)}")
|
||||||
|
|
||||||
# Provide feedback based on the category
|
# Provide feedback based on the category
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue