# Define action limits based on student responses
action_limits = {"agree": 1, "disagree": 2, "completely disagree": 3}
# Process each student's response
for idx, row in student_data.iterrows():
statement = row["Statement"]
response = row["Response"].strip().lower()
# Define max actions based on response type
max_actions = action_limits.get(response, 2) # Default to 2 if unknown
full_response = generate_text(prompt)
# Extract only the required number of actions using regex
actions = re.findall(r"\d+.\s(.*?)(?=\d+.|$)", full_response, re.DOTALL)
ai_action = "\n".join(actions[:max_actions]) # Keep only the required actions
# Store the AI-generated action in the dataset
student_data.at[idx, "Action"] = ai_action