Skip to content

Commit

Permalink
tokenCount: useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
yoziru committed Jul 28, 2024
1 parent b71e3ef commit c7a0120
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/components/chat/chat-bottombar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,17 @@ export default function ChatBottombar({
handleSubmit(e as unknown as React.FormEvent<HTMLFormElement>);
}
};
const tokenCount = input ? llama3Tokenizer.encode(input).length - 1 : 0;

const [tokenLimit, setTokenLimit] = React.useState<number>(4096);
React.useEffect(() => {
getTokenLimit(basePath).then((limit) => setTokenLimit(limit));
}, [hasMounted]);

const tokenCount = React.useMemo(
() => (input ? llama3Tokenizer.encode(input).length - 1 : 0),
[input]
);

return (
<div>
<div className="stretch flex flex-row gap-3 last:mb-2 md:last:mb-6 mx-2 md:mx-4 md:mx-auto md:max-w-2xl xl:max-w-3xl">
Expand Down

0 comments on commit c7a0120

Please sign in to comment.