mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-13 12:13:43 +08:00
v3.7.0
This commit is contained in:
5
dist/common/utils/getTokenCount.js
vendored
5
dist/common/utils/getTokenCount.js
vendored
@@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getTokenCount = void 0;
|
||||
const tiktoken_1 = require("@dqbd/tiktoken");
|
||||
const gpt_tokenizer_1 = require("gpt-tokenizer");
|
||||
const getTokenCount = async (input) => {
|
||||
let text = '';
|
||||
if (Array.isArray(input)) {
|
||||
@@ -25,7 +25,6 @@ const getTokenCount = async (input) => {
|
||||
text = String(input);
|
||||
}
|
||||
text = text.replace(/<\|endoftext\|>/g, '');
|
||||
const tokenizer = (0, tiktoken_1.get_encoding)('cl100k_base');
|
||||
return tokenizer.encode(text).length;
|
||||
return (0, gpt_tokenizer_1.encode)(text).length;
|
||||
};
|
||||
exports.getTokenCount = getTokenCount;
|
||||
|
||||
Reference in New Issue
Block a user