fix: handle yuyar typo variant of yuyay-response tags
Models occasionally misspell yuyay as yuyar since it's a made-up word. Use [yr] character class in all regexes and partial tag prefixes.
This commit is contained in:
parent
be16715163
commit
5580bc87cc
2 changed files with 11 additions and 4 deletions
|
|
@ -72,13 +72,20 @@ import re as _re
|
||||||
# streaming responses and executes the contained ops in real-time.
|
# streaming responses and executes the contained ops in real-time.
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
_TAG_OPEN_RE = _re.compile(r"<(memory_cleanup|yuyay-response)")
|
_TAG_OPEN_RE = _re.compile(r"<(memory_cleanup|yuya[yr]-response)")
|
||||||
_TAG_CLOSE_RE = _re.compile(r"</(memory_cleanup|yuyay-response)>")
|
_TAG_CLOSE_RE = _re.compile(r"</(memory_cleanup|yuya[yr]-response)>")
|
||||||
|
|
||||||
# Matches a trailing '<' optionally followed by a prefix of a known tag name
|
# Matches a trailing '<' optionally followed by a prefix of a known tag name
|
||||||
# or '</'. Used to detect partial tag openers that arrive split across SSE
|
# or '</'. Used to detect partial tag openers that arrive split across SSE
|
||||||
# text deltas (e.g. "<y", "<mem", "</memory_cl").
|
# text deltas (e.g. "<y", "<mem", "</memory_cl").
|
||||||
_KNOWN_TAG_PREFIXES = ("memory_cleanup", "yuyay-response", "/memory_cleanup", "/yuyay-response")
|
_KNOWN_TAG_PREFIXES = (
|
||||||
|
"memory_cleanup",
|
||||||
|
"yuyay-response",
|
||||||
|
"yuyar-response",
|
||||||
|
"/memory_cleanup",
|
||||||
|
"/yuyay-response",
|
||||||
|
"/yuyar-response",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def _has_partial_tag(buf: str) -> bool:
|
def _has_partial_tag(buf: str) -> bool:
|
||||||
|
|
|
||||||
|
|
@ -166,7 +166,7 @@ def parse_cleanup_tags(text: str) -> CleanupOps:
|
||||||
|
|
||||||
# Match <yuyay-response>...</yuyay-response> blocks
|
# Match <yuyay-response>...</yuyay-response> blocks
|
||||||
_YUYAY_RESPONSE_PATTERN = re.compile(
|
_YUYAY_RESPONSE_PATTERN = re.compile(
|
||||||
r"<yuyay-response>\s*(.*?)\s*</yuyay-response>",
|
r"<yuya[yr]-response>\s*(.*?)\s*</yuya[yr]-response>",
|
||||||
re.DOTALL,
|
re.DOTALL,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue