From e20c801ff0904ea1763a742c8f4f370643d4c374 Mon Sep 17 00:00:00 2001 From: Louis Date: Sun, 15 Jun 2025 18:20:17 +0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8enhancement:=20out=20of=20context=20tr?= =?UTF-8?q?oubleshooting=20(#5275)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨enhancement: out of context troubleshooting * 🔧refactor: clean up --- .../containers/dialogs/OutOfContextDialog.tsx | 27 +- web-app/src/hooks/useChat.ts | 232 ++++++++++++------ .../settings/providers/$providerName.tsx | 3 + web-app/src/services/models.ts | 4 +- 4 files changed, 188 insertions(+), 78 deletions(-) diff --git a/web-app/src/containers/dialogs/OutOfContextDialog.tsx b/web-app/src/containers/dialogs/OutOfContextDialog.tsx index fb01d7907..92e72950a 100644 --- a/web-app/src/containers/dialogs/OutOfContextDialog.tsx +++ b/web-app/src/containers/dialogs/OutOfContextDialog.tsx @@ -14,7 +14,9 @@ import { Button } from '@/components/ui/button' export function useOutOfContextPromiseModal() { const [isOpen, setIsOpen] = useState(false) const [modalProps, setModalProps] = useState<{ - resolveRef: ((value: unknown) => void) | null + resolveRef: + | ((value: 'ctx_len' | 'context_shift' | undefined) => void) + | null }>({ resolveRef: null, }) @@ -33,17 +35,23 @@ export function useOutOfContextPromiseModal() { return null } - const handleConfirm = () => { + const handleContextLength = () => { setIsOpen(false) if (modalProps.resolveRef) { - modalProps.resolveRef(true) + modalProps.resolveRef('ctx_len') } } + const handleContextShift = () => { + setIsOpen(false) + if (modalProps.resolveRef) { + modalProps.resolveRef('context_shift') + } + } const handleCancel = () => { setIsOpen(false) if (modalProps.resolveRef) { - modalProps.resolveRef(false) + modalProps.resolveRef(undefined) } } @@ -64,7 +72,7 @@ export function useOutOfContextPromiseModal() { {t( 'outOfContextError.description', - 'This chat is reaching the AI’s memory limit, like a whiteboard filling up. We can expand the memory window (called context size) so it remembers more, but it may use more of your computer’s memory.' + 'This chat is reaching the AI’s memory limit, like a whiteboard filling up. We can expand the memory window (called context size) so it remembers more, but it may use more of your computer’s memory. We can also truncate the input, which means it will forget some of the chat history to make room for new messages.' )}

@@ -77,14 +85,17 @@ export function useOutOfContextPromiseModal() {