mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-17 14:33:41 +08:00
修复日志图表的问题
This commit is contained in:
@@ -1,7 +1,27 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { insertUser } from "@/lib/auth";
|
||||
import { getTokenLength } from "@/app/utils/token";
|
||||
// import { getTokenLength } from "@/app/utils/token";
|
||||
// import { Tiktoken } from "tiktoken/lite"
|
||||
// import cl100k_base from "tiktoken/encoders/cl100k_base.json"
|
||||
import "tiktoken";
|
||||
import { get_encoding } from "tiktoken";
|
||||
|
||||
function getTokenLength(input: string): number {
|
||||
// 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 encoding = get_encoding("cl100k_base");
|
||||
|
||||
const tokenLength = encoding.encode(input).length;
|
||||
// console.log('[TOKEN],=========', input, tokenLength)
|
||||
|
||||
return tokenLength;
|
||||
}
|
||||
|
||||
async function handle(
|
||||
req: NextRequest,
|
||||
|
||||
Reference in New Issue
Block a user