feat(sidebar): enhance pattern matching for local LLM (closes #588) #589
+12
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This update strengthens pattern matching to handle slight deviations in output introduced by local LLMs. Instead of manually adjusting templates for each LLM, we capture the most common variations to improve robustness, while ensuring compatibility with the officially supported LLM (e.g., Claude-3.5-Sonnet).
Enhanced Pattern Matching:
The primary pattern we are currently targeting is:
"Replace lines: 5-7"
This update also captures the following common deviations:
" Replace lines: 5-7"
— Extra whitespace after a line break."1. Replace lines: 5-7"
— Numbered changes."1 Replace lines: 5-7"
— Numbering without punctuation."1) Replace lines: 5-7"
and"1.) Replace lines: 5-7"
— Different numbering formats."Replace lines 5-7"
— Missing colon (:
), now optional."Replace line: 5"
— Singular line references."And replace lines: 5-7"
— Optional keywords before the pattern."replace lines: 5-7"
— Case-insensitive matching.Additionally, we now support indented code blocks, allowing for whitespace before the opening backticks (```). Previously, code blocks could not be indented, which caused issues when certain LLMs added indentation to code snippets. This update ensures that these blocks can be correctly processed and included in the original file.
By broadening pattern recognition, this update ensures we capture common deviations from local LLMs while preserving compatibility with officially supported models.