mirror of
https://github.com/ItzCrazyKns/Perplexica.git
synced 2026-04-10 05:44:25 +00:00
feat(split-text): export token count function
This commit is contained in:
@@ -4,7 +4,7 @@ const splitRegex = /(?<=\. |\n|! |\? |; |:\s|\d+\.\s|- |\* )/g;
|
|||||||
|
|
||||||
const enc = getEncoding('cl100k_base');
|
const enc = getEncoding('cl100k_base');
|
||||||
|
|
||||||
const getTokenCount = (text: string): number => {
|
export const getTokenCount = (text: string): number => {
|
||||||
try {
|
try {
|
||||||
return enc.encode(text).length;
|
return enc.encode(text).length;
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user