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

This commit is contained in:
Raj Maheshwari 2024-07-13 20:06:27 +05:30 committed by GitHub
parent b2b6d2ac1e
commit 64be2cb466
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -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)

View File

@ -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}>'

View File

@ -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}>'