Skip to content

Commit

Permalink
[Fix] Minor bug in parse_response of CodeActResponseParser (#2912)
Browse files Browse the repository at this point in the history
  • Loading branch information
RajWorking committed Jul 13, 2024
1 parent b2b6d2a commit 64be2cb
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion agenthub/browsing_agent/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ def parse(self, response: str) -> Action:
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)
Expand Down
2 changes: 2 additions & 0 deletions agenthub/codeact_agent/action_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ def parse(self, response) -> Action:

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}>'
Expand Down
2 changes: 2 additions & 0 deletions agenthub/codeact_swe_agent/response_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ def parse(self, response: str) -> Action:

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}>'
Expand Down

0 comments on commit 64be2cb

Please sign in to comment.