Changesets · Branches · Tags · Compare
| Changeset | 9f61c1672388fee0841cb5437b6e1542fb8e8a5316b213d2003633fc49629b0f |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-17 03:39 +02:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-07-17 03:39 +02:00 |
| Parents | e1c15e4ba824 |
4 files changed
modified core/llm/countTokens.ts +5 −8
| @@ -444,13 +444,6 @@ | ||
| 444 | 444 | |
| 445 | 445 | msgsCopy = addSpaceToAnyEmptyMessages(msgsCopy); |
| 446 | 446 | |
| 447 | - while (msgsCopy.length > 1) { | |
| 448 | - if (isUserOrToolMsg(msgsCopy.at(-1))) { | |
| 449 | - break; | |
| 450 | - } | |
| 451 | - msgsCopy.pop(); | |
| 452 | - } | |
| 453 | - | |
| 454 | 447 | // Extract the tool sequence from the end of the message array |
| 455 | 448 | const toolSequence = extractToolSequence(msgsCopy); |
| 456 | 449 | |
| @@ -531,7 +524,11 @@ | ||
| 531 | 524 | reassembled.push(...historyWithTokens.map(({ tokens, ...rest }) => rest)); |
| 532 | 525 | reassembled.push(...toolSequence); |
| 533 | 526 | |
| 534 | - const contextPercentage = currentTotal / contextLength; | |
| 527 | + const inputTokens = | |
| 528 | + currentTotal + systemMsgTokens + toolTokens + lastMessagesTokens; | |
| 529 | + const availableTokens = | |
| 530 | + contextLength - countingSafetyBuffer - minOutputTokens; | |
| 531 | + const contextPercentage = inputTokens / availableTokens; | |
| 535 | 532 | return { |
| 536 | 533 | compiledChatMessages: reassembled, |
| 537 | 534 | didPrune, |
modified gui/src/components/mainInput/ContinueInputBox.tsx +0 −2
| @@ -7,7 +7,6 @@ | ||
| 7 | 7 | import { ContextItemsPeek } from "./belowMainInput/ContextItemsPeek"; |
| 8 | 8 | import { RulesPeek } from "./belowMainInput/RulesPeek"; |
| 9 | 9 | import { GradientBorder } from "./GradientBorder"; |
| 10 | -import InlineErrorMessage from "./InlineErrorMessage"; | |
| 11 | 10 | import { ToolbarOptions } from "./InputToolbar"; |
| 12 | 11 | import { Lump } from "./Lump"; |
| 13 | 12 | import { TipTapEditor } from "./TipTapEditor"; |
| @@ -120,7 +119,6 @@ | ||
| 120 | 119 | /> |
| 121 | 120 | </div> |
| 122 | 121 | )} |
| 123 | - {props.isLastUserInput && <InlineErrorMessage />} | |
| 124 | 122 | </div> |
| 125 | 123 | ); |
| 126 | 124 | } |
modified gui/src/components/mainInput/InlineErrorMessage.tsx +4 −4
| @@ -1,10 +1,12 @@ | ||
| 1 | 1 | import { useContext } from "react"; |
| 2 | 2 | import { IdeMessengerContext } from "../../context/IdeMessenger"; |
| 3 | -import { useAppSelector } from "../../redux/hooks"; | |
| 3 | +import { useAppDispatch, useAppSelector } from "../../redux/hooks"; | |
| 4 | +import { setInlineErrorMessage } from "../../redux/slices/sessionSlice"; | |
| 4 | 5 | |
| 5 | 6 | export type InlineErrorMessageType = "out-of-context"; |
| 6 | 7 | |
| 7 | 8 | export default function InlineErrorMessage() { |
| 9 | + const dispatch = useAppDispatch(); | |
| 8 | 10 | const ideMessenger = useContext(IdeMessengerContext); |
| 9 | 11 | const inlineErrorMessage = useAppSelector( |
| 10 | 12 | (state) => state.session.inlineErrorMessage, |
| @@ -33,9 +35,7 @@ | ||
| 33 | 35 | <span |
| 34 | 36 | className="cursor-pointer text-xs hover:underline" |
| 35 | 37 | onClick={() => { |
| 36 | - ideMessenger.post("config/openProfile", { | |
| 37 | - profileId: undefined, | |
| 38 | - }); | |
| 38 | + dispatch(setInlineErrorMessage(undefined)); | |
| 39 | 39 | }} |
| 40 | 40 | > |
| 41 | 41 | Hide |
modified gui/src/pages/gui/Chat.tsx +2 −0
| @@ -44,6 +44,7 @@ | ||
| 44 | 44 | import { ToolCallDiv } from "./ToolCallDiv"; |
| 45 | 45 | |
| 46 | 46 | import ContextStatus from "../../components/mainInput/ContextStatus"; |
| 47 | +import InlineErrorMessage from "../../components/mainInput/InlineErrorMessage"; | |
| 47 | 48 | import { cancelStream } from "../../redux/thunks/cancelStream"; |
| 48 | 49 | import { EmptyChatBody } from "./EmptyChatBody"; |
| 49 | 50 | import { ExploreDialogWatcher } from "./ExploreDialogWatcher"; |
| @@ -389,6 +390,7 @@ | ||
| 389 | 390 | > |
| 390 | 391 | {renderChatHistoryItem(item, index)} |
| 391 | 392 | </ErrorBoundary> |
| 393 | + {index === history.length - 1 && <InlineErrorMessage />} | |
| 392 | 394 | </div> |
| 393 | 395 | ))} |
| 394 | 396 | </StepsDiv> |