Narrow trivial input skip rules

This commit is contained in:
Hao19911125
2026-04-05 23:52:59 +08:00
parent e3c819b5cf
commit d77b64e05a
2 changed files with 3 additions and 50 deletions

View File

@@ -323,23 +323,6 @@ export function normalizeRecallInputText(value) {
.trim();
}
const TRIVIAL_INPUT_MIN_TOKENS = 2;
const TRIVIAL_INPUT_CJK_TOKEN_REGEX =
/\p{Script=Han}|\p{Script=Hiragana}|\p{Script=Katakana}|\p{Script=Hangul}/gu;
function estimateTrivialInputTokens(text = "") {
const normalized = normalizeRecallInputText(text);
if (!normalized) return 0;
const cjkMatches = normalized.match(TRIVIAL_INPUT_CJK_TOKEN_REGEX) || [];
const nonCjkText = normalized.replace(TRIVIAL_INPUT_CJK_TOKEN_REGEX, " ");
const wordTokens = nonCjkText
.split(/\s+/)
.filter(Boolean);
return cjkMatches.length + wordTokens.length;
}
export function isTrivialUserInput(text) {
const normalizedText = normalizeRecallInputText(text);
if (!normalizedText) {
@@ -358,14 +341,6 @@ export function isTrivialUserInput(text) {
};
}
if (estimateTrivialInputTokens(normalizedText) < TRIVIAL_INPUT_MIN_TOKENS) {
return {
trivial: true,
reason: "under-min-tokens",
normalizedText,
};
}
return {
trivial: false,
reason: "",