Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ def post_process_suggestion(suggestion: str, request: InlineCompletionRequest) -
for opening in bad_openings:
# ollama models tend to add spurious whitespace
if suggestion.lstrip().startswith(opening):
suggestion = suggestion.lstrip()[len(opening) :].lstrip()
suggestion = suggestion.lstrip()[len(opening) :]
# check for the prefix inclusion (only if there was a bad opening)
if suggestion.startswith(request.prefix):
suggestion = suggestion[len(request.prefix) :]
if suggestion.lstrip().startswith(request.prefix):
suggestion = suggestion.lstrip()[len(request.prefix) :]
break

# check if the suggestion ends with a closing markdown identifier and remove it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ async def test_handle_request(inline_handler):
("```hello```world```", "hello```world"),
(" ```\nprint(test)\n```", "print(test)"),
("``` \nprint(test)\n```", "print(test)"),
("```\n# load json file\n```", "\n# load json file"),
("```\ndef function():\n pass\n```", "\ndef function():\n pass"),
(
"```\n# load json file\nimport json\nwith open('path-to-file','r') as f:```",
"\nimport json\nwith open('path-to-file','r') as f:",
),
]


Expand Down
Loading