diff --git a/app.py b/app.py index 9a2db5c..06ea335 100644 --- a/app.py +++ b/app.py @@ -2326,7 +2326,7 @@ def handle_activity_response(room_name, user_response, username): activity_state.add_metadata(random_key, random_value) # 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( activity_state.dict_metadata, step["processing_script"] ) diff --git a/research/activity22-odds-or-evens.yaml b/research/activity22-odds-or-evens.yaml index d3fa106..50767a3 100644 --- a/research/activity22-odds-or-evens.yaml +++ b/research/activity22-odds-or-evens.yaml @@ -70,6 +70,7 @@ sections: - exit transitions: throw_fingers: + run_processing_script: True 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." metadata_add: diff --git a/research/activity24-math-plot.yaml b/research/activity24-math-plot.yaml index 52c5630..286747c 100644 --- a/research/activity24-math-plot.yaml +++ b/research/activity24-math-plot.yaml @@ -90,6 +90,7 @@ sections: - exit transitions: correct: + run_processing_script: True ai_feedback: tokens_for_ai: "Great job! You correctly described the plot of your function." metadata_add: diff --git a/research/activity27-tic-tac-toe.yaml b/research/activity27-tic-tac-toe.yaml index f0a3889..748e0dd 100644 --- a/research/activity27-tic-tac-toe.yaml +++ b/research/activity27-tic-tac-toe.yaml @@ -55,7 +55,7 @@ sections: ai_moves = metadata.get("ai_moves", []) ai_move = None board = [" "] * 9 - for move in user_moves[:-1]: + for move in user_moves: board[int(move)] = "X" for move in ai_moves: board[int(move)] = "O" @@ -70,6 +70,7 @@ sections: # Check if the move is valid if 0 <= user_move < 9 and board[user_move] == " ": board[user_move] = "X" + user_moves.append(user_move) user_wins = check_win(board, "X") @@ -108,7 +109,7 @@ sections: } # Debugging: Print the current board state - #print("Current board state:", board) + print("Current board state:", board) buckets: - valid_move @@ -116,6 +117,7 @@ sections: - exit transitions: valid_move: + run_processing_script: True ai_feedback: tokens_for_ai: | Use the processing_script metadata to update the board! @@ -135,22 +137,14 @@ sections: metadata_tmp_add: user_move: "the-users-response" - metadata_append: - user_moves: "the-users-response" next_section_and_step: "section_1:step_1" invalid_move: ai_feedback: tokens_for_ai: "That move is invalid. Please choose an empty position between 0 and 8." metadata_tmp_add: user_move: "the-users-response" - metadata_append: - user_moves: "the-users-response" next_section_and_step: "section_1:step_1" exit: - metadata_tmp_add: - user_move: "the-users-response" - metadata_append: - user_moves: "the-users-response" next_section_and_step: "section_1:step_2" - step_id: "step_2" diff --git a/research/guarded_ai.py b/research/guarded_ai.py index 0bfd4d6..85ed817 100644 --- a/research/guarded_ai.py +++ b/research/guarded_ai.py @@ -290,11 +290,15 @@ def simulate_activity(yaml_file_path): metadata_tmp_keys.append(random_key) # Track temporary keys # 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"]) metadata["processing_script_result"] = 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)}") # Provide feedback based on the category