Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 23, 2024
1 parent b52a3db commit e1e42fe
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/jupyter-ai/jupyter_ai/completions/handlers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,25 +134,25 @@ def _post_process_suggestion(
While most models (especially instruct and infill models do not require
any pre-processing), some models such as gpt-4 which only have chat APIs
may require removing spurious fragments (such as backticks).
This function uses heuristics and request data to remove such fragments.
It comments out all lines that are not code, irrespective of programming language.
may require removing spurious fragments (such as backticks).
This function uses heuristics and request data to remove such fragments.
It comments out all lines that are not code, irrespective of programming language.
"""
suggestion = "\n\n" + suggestion.strip()
segments = suggestion.split('\n')
segments = suggestion.split("\n")
is_code = False
suggestion = []
for s in segments:
if is_code==False:
if s.startswith('```'):
if is_code == False:
if s.startswith("```"):
is_code = True
else:
if len(s)>0:
if len(s) > 0:
suggestion.append("# " + s)
else:
suggestion.append(s)
else:
if s.startswith('```'):
if s.startswith("```"):
is_code = False
else:
suggestion.append(s)
Expand Down

0 comments on commit e1e42fe

Please sign in to comment.