From 51a6701794e59c3e5bca1b71a964f687f1abf5c2 Mon Sep 17 00:00:00 2001 From: Amir Date: Tue, 18 Feb 2025 16:21:00 +0100 Subject: [PATCH] Reducing chance to minimum for AI response to fail --- backend/core/utils.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/backend/core/utils.py b/backend/core/utils.py index 8f4bf2b..f93f136 100644 --- a/backend/core/utils.py +++ b/backend/core/utils.py @@ -131,13 +131,11 @@ def get_controls_for_risk(risk, organization): if control_id in valid_control_ids and 1 <= weight <= 10: if control_id in control_ids_seen: - valid = False - break + continue selected_controls.append((control_id, weight)) control_ids_seen.add(control_id) else: - valid = False - break + continue if valid and len(selected_controls) == 10: return selected_controls @@ -145,7 +143,6 @@ def get_controls_for_risk(risk, organization): print(f"Recived {len(selected_controls)} controls. Retrying for missing ones...\n") remaining_controls = valid_control_ids - control_ids_seen missing_count = 10 - len(selected_controls) - if missing_count > 0: remaining_controls_list = [f"Control ID:{cid}, Control Name: {control_map[cid]}" for cid in remaining_controls] prompt = f"""