parser fix for deepseek

This commit is contained in:
Xingyao Wang
2024-09-27 21:10:14 +00:00
parent 4ae0a3c887
commit 78cbd90df0

View File

@@ -40,6 +40,10 @@ class CodeActResponseParser(ResponseParser):
if action is None:
return ''
for lang in ['bash', 'ipython', 'browse']:
# special handling for DeepSeek: it has stop-word bug and returns </execute_ipython instead of </execute_ipython>
if f'</execute_{lang}' in action and f'</execute_{lang}>' not in action:
action = action.replace(f'</execute_{lang}', f'</execute_{lang}>')
if f'<execute_{lang}>' in action and f'</execute_{lang}>' not in action:
action += f'</execute_{lang}>'
return action