Преглед изворни кода

[Fix] Minor bug in parse_response of CodeActResponseParser (#2912)

Raj Maheshwari пре 1 година
родитељ
комит
64be2cb466

+ 4 - 1
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)

+ 2 - 0
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'<execute_{lang}>' in action and f'</execute_{lang}>' not in action:
                 action += f'</execute_{lang}>'

+ 2 - 0
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'<execute_{lang}>' in action and f'</execute_{lang}>' not in action:
                 action += f'</execute_{lang}>'