Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inline completion bug, add test cases #1002

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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