feat: add translation feature and ban character set functionality

This commit is contained in:
Kwaroran
2024-12-29 04:03:21 +09:00
parent ebdcd5ffcd
commit cd092a5a01
12 changed files with 221 additions and 56 deletions

View File

@@ -226,6 +226,19 @@ export async function requestChatData(arg:requestDataArgument, model:ModelModeEx
}
}
if(da.type === 'success' && db.banCharacterset?.length > 0){
for(const set of db.banCharacterset){
const checkRegex = new RegExp(`\\p{Script=${set}}`, 'gu')
if(checkRegex.test(da.result)){
return {
type: 'fail',
result: 'Banned character found'
}
}
}
}
if(da.type !== 'fail' || da.noRetry){
return da