From dc4a1c1b548adb1d71dcae32cad6a83a688d65cb Mon Sep 17 00:00:00 2001 From: Leon Derczynski Date: Tue, 14 May 2024 07:55:04 +0200 Subject: [PATCH] handle target model returning None in atkgen (#678) * handle target model returning None in atkgen * validate response structure without try/except --- garak/probes/atkgen.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/garak/probes/atkgen.py b/garak/probes/atkgen.py index 67d657078..612986c23 100644 --- a/garak/probes/atkgen.py +++ b/garak/probes/atkgen.py @@ -135,13 +135,12 @@ def probe(self, generator) -> List[garak.attempt.Attempt]: f" turn {t.n:02}: waiting for [{generator.name[:10]:<10}]" ) # send the challenge and get the response - try: - response = generator.generate(challenge)[0].strip() - except AttributeError as ae: - if generator.generate(challenge)[0] is None: - response = "" - else: - raise AttributeError from ae + response = generator.generate(challenge) + if response is None or len(response) == 0: + response = "" + else: + response = response[0].strip() if response[0] is not None else "" + # log the response turn = ("model", response) turns.append(turn)