From 32aa2d24ff5652477e4946c9cd021d616386e2c3 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Wed, 8 Nov 2023 11:37:51 -0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20warning=20if=20exceeding=20context?= =?UTF-8?q?=20limit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- extensions/intellij/gradle.properties | 2 +- gui/src/components/ComboBox.tsx | 32 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/extensions/intellij/gradle.properties b/extensions/intellij/gradle.properties index 30519f0cb..b162e53cc 100644 --- a/extensions/intellij/gradle.properties +++ b/extensions/intellij/gradle.properties @@ -4,7 +4,7 @@ pluginGroup = com.github.continuedev.continueintellijextension pluginName = continue-intellij-extension pluginRepositoryUrl = https://github.com/continuedev/continue # SemVer format -> https://semver.org -pluginVersion = 0.0.16 +pluginVersion = 0.0.17 # Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html pluginSinceBuild = 223 diff --git a/gui/src/components/ComboBox.tsx b/gui/src/components/ComboBox.tsx index 49fdd3646..3a6880b90 100644 --- a/gui/src/components/ComboBox.tsx +++ b/gui/src/components/ComboBox.tsx @@ -28,6 +28,7 @@ import { ChevronRightIcon, Cog6ToothIcon, CommandLineIcon, + ExclamationTriangleIcon, FolderIcon, FolderOpenIcon, GlobeAltIcon, @@ -797,6 +798,24 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { ] ); + const [contextLengthFillPercentage, setContextLengthFillPercentage] = + useState(0); + + const contextLength = useSelector( + (store: RootStore) => + store.serverState.config.models?.default?.context_length || 4096 + ); + + useEffect(() => { + let tokenEstimate = selectedContextItems.reduce((acc, item) => { + return acc + item.content.length / Math.E; // Just an estimate of tokens / char + }, 0); + tokenEstimate += downshiftProps.inputValue.length / Math.E; + setContextLengthFillPercentage( + tokenEstimate / Math.max(1, contextLength - 600) + ); + }, [selectedContextItems, contextLength]); + const [isComposing, setIsComposing] = useState(false); const [showContextToggleOn, setShowContextToggleOn] = useState(false); @@ -1034,6 +1053,19 @@ const ComboBox = React.forwardRef((props: ComboBoxProps, ref) => { wFull={false} > )} + {contextLengthFillPercentage > 1 && ( + + + + )} ) : (