From eec5418e1447b054cf9bd86f2be8a6e52fa94d2a Mon Sep 17 00:00:00 2001 From: sijinhui Date: Wed, 27 Dec 2023 22:17:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtiktoken=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=89=93=E5=8C=85=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/app/(admin)/admin/usage-by-model.tsx | 4 ++-- next.config.mjs | 14 ++++++++++++++ package.json | 1 + 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/app/app/(admin)/admin/usage-by-model.tsx b/app/app/(admin)/admin/usage-by-model.tsx index 75c5d4416..dfcbd8d54 100644 --- a/app/app/(admin)/admin/usage-by-model.tsx +++ b/app/app/(admin)/admin/usage-by-model.tsx @@ -88,11 +88,11 @@ export default async function UsageByModel() { }, }); - console.log("========", todayLog[todayLog.length - 1]); + // console.log("========", todayLog[todayLog.length - 1]); // @ts-ignore const log_data = HandleLogData(todayLog); - // console.log('[log_data]====---==', log_data) + console.log("[log_data]====---==", todayLog); const usageByModelOption: EChartsOption = { tooltip: { diff --git a/next.config.mjs b/next.config.mjs index 68d9a78ca..3fb779f62 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -9,6 +9,9 @@ console.log("[Next] build with chunk: ", disableChunk); /** @type {import('next').NextConfig} */ // const isProd = process.env.NODE_ENV === 'production' +// 为了修复tiktoken的插件问题 +import CopyPlugin from "copy-webpack-plugin"; + const nextConfig = { webpack(config) { config.module.rules.push({ @@ -21,6 +24,17 @@ const nextConfig = { new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 }), ) } + config.plugins.push( + new CopyPlugin({ + patterns: [ + { + from: ".//node_modules/tiktoken/tiktoken_bg.wasm", + to: "tiktoken_bg.wasm", + toType: "file", + } + ] + }) + ) config.optimization.minimize = true config.optimization.splitChunks = { diff --git a/package.json b/package.json index c21149ba5..78b37ce8b 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "@types/react-katex": "^3.0.0", "@types/spark-md5": "^3.0.4", "autoprefixer": "^10.4.16", + "copy-webpack-plugin": "^11.0.0", "cross-env": "^7.0.3", "eslint": "^8.55.0", "eslint-config-next": "^14.0.3",