mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-29 17:37:39 -05:00
ui : escape sidecar tokens in the regex alternation
Assisted-by: pi:zai-org/GLM-5.3-Flash
This commit is contained in:
@@ -15,7 +15,15 @@ export const SIDECAR_TOKENS: string[] = [
|
||||
|
||||
/** Separator between token alternatives in the sidecar regexes. */
|
||||
const REGEX_ALTERNATION_SEPARATOR = '|';
|
||||
const SIDECAR_TOKEN_ALTERNATION = SIDECAR_TOKENS.join(REGEX_ALTERNATION_SEPARATOR);
|
||||
|
||||
/** Escape regex metacharacters so a token change cannot silently corrupt the alternation. */
|
||||
function escapeRegExp(token: string): string {
|
||||
return token.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
}
|
||||
|
||||
const SIDECAR_TOKEN_ALTERNATION = SIDECAR_TOKENS.map(escapeRegExp).join(
|
||||
REGEX_ALTERNATION_SEPARATOR
|
||||
);
|
||||
|
||||
export const MODEL_ID = {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user