diff --git a/src/components/chat/chat-bottombar.tsx b/src/components/chat/chat-bottombar.tsx index 33bc1a9..c59d4bf 100644 --- a/src/components/chat/chat-bottombar.tsx +++ b/src/components/chat/chat-bottombar.tsx @@ -41,13 +41,17 @@ export default function ChatBottombar({ handleSubmit(e as unknown as React.FormEvent); } }; - const tokenCount = input ? llama3Tokenizer.encode(input).length - 1 : 0; const [tokenLimit, setTokenLimit] = React.useState(4096); React.useEffect(() => { getTokenLimit(basePath).then((limit) => setTokenLimit(limit)); }, [hasMounted]); + const tokenCount = React.useMemo( + () => (input ? llama3Tokenizer.encode(input).length - 1 : 0), + [input] + ); + return (