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)
|
||||
|
||||
# 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"]
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue