From 64be2cb466672445f44c65983495150aec4d8536 Mon Sep 17 00:00:00 2001
From: Raj Maheshwari <56214007+RajWorking@users.noreply.github.com>
Date: Sat, 13 Jul 2024 20:06:27 +0530
Subject: [PATCH] [Fix] Minor bug in parse_response of CodeActResponseParser
(#2912)
---
agenthub/browsing_agent/response_parser.py | 5 ++++-
agenthub/codeact_agent/action_parser.py | 2 ++
agenthub/codeact_swe_agent/response_parser.py | 2 ++
3 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/agenthub/browsing_agent/response_parser.py b/agenthub/browsing_agent/response_parser.py
index a784d6668d..00cc1634da 100644
--- a/agenthub/browsing_agent/response_parser.py
+++ b/agenthub/browsing_agent/response_parser.py
@@ -20,7 +20,10 @@ class BrowsingResponseParser(ResponseParser):
return self.parse_action(action_str)
def parse_response(self, response) -> str:
- action_str = response['choices'][0]['message']['content'].strip()
+ action_str = response['choices'][0]['message']['content']
+ if action_str is None:
+ return ''
+ action_str = action_str.strip()
if not action_str.endswith('```'):
action_str = action_str + ')```'
logger.info(action_str)
diff --git a/agenthub/codeact_agent/action_parser.py b/agenthub/codeact_agent/action_parser.py
index f901b0f8ea..5d709f32a7 100644
--- a/agenthub/codeact_agent/action_parser.py
+++ b/agenthub/codeact_agent/action_parser.py
@@ -38,6 +38,8 @@ class CodeActResponseParser(ResponseParser):
def parse_response(self, response) -> str:
action = response.choices[0].message.content
+ if action is None:
+ return ''
for lang in ['bash', 'ipython', 'browse']:
if f'' in action and f'' not in action:
action += f''
diff --git a/agenthub/codeact_swe_agent/response_parser.py b/agenthub/codeact_swe_agent/response_parser.py
index c9661d1809..a4d8321f05 100644
--- a/agenthub/codeact_swe_agent/response_parser.py
+++ b/agenthub/codeact_swe_agent/response_parser.py
@@ -33,6 +33,8 @@ class CodeActSWEResponseParser(ResponseParser):
def parse_response(self, response) -> str:
action = response.choices[0].message.content
+ if action is None:
+ return ''
for lang in ['bash', 'ipython']:
if f'' in action and f'' not in action:
action += f''