Skip to content

Commit

Permalink
fix: handle the case in which closing code tag starts with </
Browse files Browse the repository at this point in the history
  • Loading branch information
gventuri committed May 7, 2023
1 parent f2348d0 commit dba400f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pandasai/llm/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ def _extract_code(self, response: str, separator: str = "```") -> str:
str: Extracted code from the response
"""
code = response
match = re.search(rf"{START_CODE_TAG}(.*){END_CODE_TAG}", code, re.DOTALL)
match = re.search(
rf"{START_CODE_TAG}(.*)({END_CODE_TAG}|{END_CODE_TAG.replace('<', '</')})",
code,
re.DOTALL,
)
if match:
code = match.group(1).strip()
if len(code.split(separator)) > 1:
Expand Down

0 comments on commit dba400f

Please sign in to comment.