From fd4e614e7e9822f5bba7a949c6d5d77055c1ac3e Mon Sep 17 00:00:00 2001 From: Bovard Doerschuk-Tiberi Date: Thu, 14 Dec 2023 23:57:15 +0000 Subject: [PATCH 1/4] add error handling for when agents don't submit a guess --- .../envs/llm_20_questions/llm_20_questions.py | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py index 18323933..085f52a7 100644 --- a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py +++ b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py @@ -99,13 +99,15 @@ def interpreter(state, env): if active1 is not None: guessed = False if active1.observation.role == "guesser": - if active1.observation.turnType == "ask": + if not active1.action: + active1.status = "ERROR" + elif active1.observation.turnType == "ask": active1.observation.questions.append(active1.action) inactive1.observation.questions.append(active1.action) elif active1.observation.turnType == "guess": active1.observation.guesses.append(active1.action) inactive1.observation.guesses.append(active1.action) - if keyword_guessed(active1.action): + if active1.action and keyword_guessed(active1.action): guessed = True score = 20 - int(step / 3) active1.reward = score @@ -120,12 +122,14 @@ def interpreter(state, env): active1.observation.keyword = keyword active1.observation.category = category response = active1.action - if response.lower().__contains__("yes"): + if not response: + active1.status = "ERROR" + elif response and response.lower().__contains__("yes"): response = "yes" - elif response.lower().__contains__("no"): + elif response and response.lower().__contains__("no"): response = "no" else: - response = "maybe" + active1.status = "ERROR" active1.observation.answers.append(response) inactive1.observation.answers.append(response) @@ -151,13 +155,15 @@ def interpreter(state, env): if active2 is not None: guessed = False if active2.observation.role == "guesser": - if active2.observation.turnType == "ask": + if not active2.action: + active2.status = "ERROR" + elif active2.observation.turnType == "ask": active2.observation.questions.append(active2.action) inactive2.observation.questions.append(active2.action) elif active2.observation.turnType == "guess": active2.observation.guesses.append(active2.action) inactive2.observation.guesses.append(active2.action) - if keyword_guessed(active2.action): + if active2.action and keyword_guessed(active2.action): guessed = True score = 20 - int(step / 3) active2.reward = score @@ -172,12 +178,14 @@ def interpreter(state, env): active2.observation.keyword = keyword active2.observation.category = category response = active2.action - if response.lower().__contains__("yes"): + if not response: + active2.status = "ERROR" + elif response.lower().__contains__("yes"): response = "yes" elif response.lower().__contains__("no"): response = "no" else: - response = "maybe" + active2.status = "ERROR" active2.observation.answers.append(response) inactive2.observation.answers.append(response) From 40f337b001ea8ece2494dcb48726c823c14cd4c1 Mon Sep 17 00:00:00 2001 From: Bovard Doerschuk-Tiberi Date: Tue, 19 Dec 2023 23:07:15 +0000 Subject: [PATCH 2/4] CR --- kaggle_environments/envs/llm_20_questions/llm_20_questions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py index 085f52a7..cfbf1f4f 100644 --- a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py +++ b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py @@ -124,9 +124,9 @@ def interpreter(state, env): response = active1.action if not response: active1.status = "ERROR" - elif response and response.lower().__contains__("yes"): + elif response.lower().__contains__("yes"): response = "yes" - elif response and response.lower().__contains__("no"): + elif response.lower().__contains__("no"): response = "no" else: active1.status = "ERROR" From f30e5302313a9e1895b49f52dfea2a9a45a8750b Mon Sep 17 00:00:00 2001 From: Bovard Doerschuk-Tiberi Date: Tue, 9 Jan 2024 17:51:18 +0000 Subject: [PATCH 3/4] added more error handling --- kaggle_environments/envs/llm_20_questions/llm_20_questions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py index cfbf1f4f..1b46c73e 100644 --- a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py +++ b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py @@ -123,12 +123,14 @@ def interpreter(state, env): active1.observation.category = category response = active1.action if not response: + response = "error" active1.status = "ERROR" elif response.lower().__contains__("yes"): response = "yes" elif response.lower().__contains__("no"): response = "no" else: + response = "maybe" active1.status = "ERROR" active1.observation.answers.append(response) inactive1.observation.answers.append(response) @@ -179,12 +181,14 @@ def interpreter(state, env): active2.observation.category = category response = active2.action if not response: + response = "error" active2.status = "ERROR" elif response.lower().__contains__("yes"): response = "yes" elif response.lower().__contains__("no"): response = "no" else: + response = "error" active2.status = "ERROR" active2.observation.answers.append(response) inactive2.observation.answers.append(response) From 9eaffcc850f9a0b152a43a02b075e526a7c037d0 Mon Sep 17 00:00:00 2001 From: Bovard Doerschuk-Tiberi Date: Tue, 9 Jan 2024 17:54:00 +0000 Subject: [PATCH 4/4] update --- kaggle_environments/envs/llm_20_questions/llm_20_questions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py index cfbf1f4f..4ac17bd7 100644 --- a/kaggle_environments/envs/llm_20_questions/llm_20_questions.py +++ b/kaggle_environments/envs/llm_20_questions/llm_20_questions.py @@ -123,12 +123,14 @@ def interpreter(state, env): active1.observation.category = category response = active1.action if not response: + response = "none" active1.status = "ERROR" elif response.lower().__contains__("yes"): response = "yes" elif response.lower().__contains__("no"): response = "no" else: + response = "maybe" active1.status = "ERROR" active1.observation.answers.append(response) inactive1.observation.answers.append(response) @@ -179,12 +181,14 @@ def interpreter(state, env): active2.observation.category = category response = active2.action if not response: + reponse = "none" active2.status = "ERROR" elif response.lower().__contains__("yes"): response = "yes" elif response.lower().__contains__("no"): response = "no" else: + reponse = "maybe" active2.status = "ERROR" active2.observation.answers.append(response) inactive2.observation.answers.append(response)