Add Chinese symbols to end_trim_to_sentence

Chinese symbols have been added to end_trim_to_sentence to provide better support for truncation in Chinese chat.
This commit is contained in:
deedlitelf
2023-06-14 23:12:52 +08:00
committed by GitHub
parent 7b7a545eeb
commit 7862f93182

View File

@ -219,7 +219,7 @@ export function sortByCssOrder(a, b) {
export function end_trim_to_sentence(input, include_newline = false) { export function end_trim_to_sentence(input, include_newline = false) {
// inspired from https://github.com/kaihordewebui/kaihordewebui.github.io/blob/06b95e6b7720eb85177fbaf1a7f52955d7cdbc02/index.html#L4853-L4867 // inspired from https://github.com/kaihordewebui/kaihordewebui.github.io/blob/06b95e6b7720eb85177fbaf1a7f52955d7cdbc02/index.html#L4853-L4867
const punctuation = new Set(['.', '!', '?', '*', '"', ')', '}', '`', ']', '$']); // extend this as you see fit const punctuation = new Set(['.', '!', '?', '*', '"', ')', '}', '`', ']', '$', '。', '', '', '”', '', '】', '】', '', '」', '】']); // extend this as you see fit
let last = -1; let last = -1;
for (let i = input.length - 1; i >= 0; i--) { for (let i = input.length - 1; i >= 0; i--) {