From 576d4d9ee156799a5ced13f8daa05d8b237ca6c8 Mon Sep 17 00:00:00 2001 From: Sourab Mangrulkar <13534540+pacman100@users.noreply.github.com> Date: Mon, 4 Mar 2024 13:40:55 +0530 Subject: [PATCH 1/3] fix prefix and suffix percentage in the final prompt. --- src/extension/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension/utils.ts b/src/extension/utils.ts index 38d4946d..c2201ee7 100644 --- a/src/extension/utils.ts +++ b/src/extension/utils.ts @@ -58,7 +58,7 @@ export const getPrefixSuffix = ( numLines: number, document: TextDocument, position: Position, - contextRatio = [0.15, 0.85] + contextRatio = [0.85, 0.15] ): PrefixSuffix => { const currentLine = position.line const numLinesToEnd = document.lineCount - currentLine From f727b96f8fcc9797bf7704c876b8230e6814baa3 Mon Sep 17 00:00:00 2001 From: rjmacarthy Date: Mon, 4 Mar 2024 10:39:06 +0000 Subject: [PATCH 2/3] fill the context if close to start of document --- src/extension/utils.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/extension/utils.ts b/src/extension/utils.ts index c2201ee7..869f84d2 100644 --- a/src/extension/utils.ts +++ b/src/extension/utils.ts @@ -62,10 +62,14 @@ export const getPrefixSuffix = ( ): PrefixSuffix => { const currentLine = position.line const numLinesToEnd = document.lineCount - currentLine - let numLinesPrefix = Math.floor(Math.abs(numLines * contextRatio[0])) let numLinesSuffix = Math.ceil(Math.abs(numLines * contextRatio[1])) + if (numLinesPrefix > currentLine) { + numLinesSuffix += numLinesPrefix - currentLine + numLinesPrefix = currentLine + } + if (numLinesSuffix > numLinesToEnd) { numLinesPrefix += numLinesSuffix - numLinesToEnd numLinesSuffix = numLinesToEnd From 4693136b872640ec4c26b92bb08de66eb5df935a Mon Sep 17 00:00:00 2001 From: rjmacarthy Date: Mon, 4 Mar 2024 10:39:34 +0000 Subject: [PATCH 3/3] 3.7.10 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index a6aacfe8..16bd7fe3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "twinny", - "version": "3.7.9", + "version": "3.7.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "twinny", - "version": "3.7.9", + "version": "3.7.10", "license": "MIT", "dependencies": { "@types/react": "^18.2.46", diff --git a/package.json b/package.json index 383f0245..a9c5ae64 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "twinny", "displayName": "twinny - AI Code Completion and Chat", "description": "Locally hosted AI code completion plugin for vscode", - "version": "3.7.9", + "version": "3.7.10", "icon": "assets/icon.png", "keywords": [ "code-inference",