mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 22:13:47 +08:00
用户页面增加使用token显示
This commit is contained in:
@@ -23,19 +23,19 @@ export function estimateTokenLength(input: string): number {
|
||||
|
||||
// import { get_encoding } from "tiktoken";
|
||||
|
||||
export function getTokenLength(input: string): number {
|
||||
// const { get_encoding } = require( "tiktoken" );
|
||||
// const encoding = get_encoding("cl100k_base");
|
||||
|
||||
const { Tiktoken } = require("tiktoken/lite");
|
||||
const cl100k_base = require("tiktoken/encoders/cl100k_base.json");
|
||||
const encoding = new Tiktoken(
|
||||
cl100k_base.bpe_ranks,
|
||||
cl100k_base.special_tokens,
|
||||
cl100k_base.pat_str,
|
||||
);
|
||||
const tokenLength = encoding.encode(input).length;
|
||||
// console.log('[TOKEN],=========', input, tokenLength)
|
||||
|
||||
return tokenLength;
|
||||
}
|
||||
// export function getTokenLength(input: string): number {
|
||||
// // const { get_encoding } = require( "tiktoken" );
|
||||
// // const encoding = get_encoding("cl100k_base");
|
||||
//
|
||||
// const { Tiktoken } = require("tiktoken/lite");
|
||||
// const cl100k_base = require("tiktoken/encoders/cl100k_base.json");
|
||||
// const encoding = new Tiktoken(
|
||||
// cl100k_base.bpe_ranks,
|
||||
// cl100k_base.special_tokens,
|
||||
// cl100k_base.pat_str,
|
||||
// );
|
||||
// const tokenLength = encoding.encode(input).length;
|
||||
// // console.log('[TOKEN],=========', input, tokenLength)
|
||||
//
|
||||
// return tokenLength;
|
||||
// }
|
||||
|
||||
Reference in New Issue
Block a user