Skip to content

Commit

Permalink
fix get_file_modifications detection issue
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed Nov 7, 2024
1 parent 39f9519 commit 619dc43
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/codeinterpreterapi/chains/modifications_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def get_file_modifications(
result = llm.invoke(prompt)

try:
if isinstance(result.content, str):
if result.content.endswith("```"):
result.content = result.content[:-3]
if result.content.startswith("```"):
result.content = result.content[3:]
result = json.loads(result.content)
except json.JSONDecodeError:
result = ""
Expand All @@ -40,6 +45,11 @@ async def aget_file_modifications(
result = await llm.ainvoke(prompt)

try:
if isinstance(result.content, str):
if result.content.endswith("```"):
result.content = result.content[:-3]
if result.content.startswith("```"):
result.content = result.content[3:]
result = json.loads(result.content)
except json.JSONDecodeError:
result = ""
Expand Down

0 comments on commit 619dc43

Please sign in to comment.