diff --git a/packages/jupyter-ai/jupyter_ai/completions/handlers/default.py b/packages/jupyter-ai/jupyter_ai/completions/handlers/default.py index 8d20df1e1..de16a41af 100644 --- a/packages/jupyter-ai/jupyter_ai/completions/handlers/default.py +++ b/packages/jupyter-ai/jupyter_ai/completions/handlers/default.py @@ -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)