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

Trim leading whitespace when processing #900

Merged
merged 1 commit into from
Jul 17, 2024
Merged
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 @@ -38,8 +38,9 @@ def post_process_suggestion(suggestion: str, request: InlineCompletionRequest) -
for identifier in markdown_identifiers.get(language, [language])
] + ["```"]
for opening in bad_openings:
if suggestion.startswith(opening):
suggestion = suggestion[len(opening) :].lstrip()
# ollama models tend to add spurious whitespace
if suggestion.lstrip().startswith(opening):
suggestion = suggestion.lstrip()[len(opening) :].lstrip()
# check for the prefix inclusion (only if there was a bad opening)
if suggestion.startswith(request.prefix):
suggestion = suggestion[len(request.prefix) :]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ async def test_handle_request(inline_handler):
("```python\nTest python code\n```", "Test python code"),
("```\ntest\n```\n \n", "test"),
("```hello```world```", "hello```world"),
(" ```\nprint(test)\n```", "print(test)"),
("``` \nprint(test)\n```", "print(test)"),
]


Expand Down
Loading