mirror of
https://github.com/ikechan8370/chatgpt-plugin.git
synced 2025-12-17 05:47:11 +00:00
fix: node-rs jieba error
This commit is contained in:
parent
db72462b8e
commit
c35c3a66ce
1 changed files with 7 additions and 3 deletions
|
|
@ -4,7 +4,7 @@ let nodejieba
|
||||||
try {
|
try {
|
||||||
nodejieba = (await import('@node-rs/jieba')).default
|
nodejieba = (await import('@node-rs/jieba')).default
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.info('未安装nodejieba,娱乐功能-词云统计不可用')
|
logger.info('未安装@node-rs/jieba,娱乐功能-词云统计不可用')
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Tokenizer {
|
export class Tokenizer {
|
||||||
|
|
@ -56,11 +56,15 @@ export class Tokenizer {
|
||||||
|
|
||||||
async getTodayKeywordTopK (groupId, topK = 100) {
|
async getTodayKeywordTopK (groupId, topK = 100) {
|
||||||
if (!nodejieba) {
|
if (!nodejieba) {
|
||||||
throw new Error('未安装nodejieba,娱乐功能-词云统计不可用')
|
throw new Error('未安装node-rs/jieba,娱乐功能-词云统计不可用')
|
||||||
}
|
}
|
||||||
let chats = await this.getTodayHistory(groupId)
|
let chats = await this.getTodayHistory(groupId)
|
||||||
logger.mark(`聊天记录拉去完成,获取到今日内${chats.length}条聊天记录,准备分词中`)
|
logger.mark(`聊天记录拉去完成,获取到今日内${chats.length}条聊天记录,准备分词中`)
|
||||||
|
try {
|
||||||
nodejieba.load()
|
nodejieba.load()
|
||||||
|
} catch (err) {
|
||||||
|
// ignore already load error
|
||||||
|
}
|
||||||
let chatContent = chats
|
let chatContent = chats
|
||||||
.map(c => c.raw_message
|
.map(c => c.raw_message
|
||||||
.replaceAll('[图片]', '')
|
.replaceAll('[图片]', '')
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue