DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(partners): do not treat empty markdown rows as table separators (#682)
Santh968921b13532
diff --git a/deeptutor/partners/channels/telegram.py b/deeptutor/partners/channels/telegram.pyindex e47235d0a..237d0cedf 100644--- a/deeptutor/partners/channels/telegram.py+++ b/deeptutor/partners/channels/telegram.py@@ -21,7 +21,7 @@ from deeptutor.partners.bus.queue import MessageBusfrom deeptutor.partners.channels.base import BaseChannelfrom deeptutor.partners.config.paths import get_media_dirfrom deeptutor.partners.config.schema import DeliveryOverrides, StreamingSupport-from deeptutor.partners.helpers import split_message+from deeptutor.partners.helpers import is_markdown_table_separator_row, split_messagefrom deeptutor.services.partners.commands import build_partner_help_text, partner_command_paletteTELEGRAM_MAX_MESSAGE_LEN = 4000 # Telegram message character limit@@ -81,7 +81,7 @@ def _render_table_box(table_lines: list[str]) -> str:has_sep = Falsefor line in table_lines:cells = [_strip_md(c) for c in line.strip().strip("|").split("|")]- if all(re.match(r"^:?-+:?$", c) for c in cells if c):+ if is_markdown_table_separator_row(cells):has_sep = Truecontinuerows.append(cells)diff --git a/deeptutor/partners/helpers.py b/deeptutor/partners/helpers.pyindex 8537d01c5..c0c5e8032 100644--- a/deeptutor/partners/helpers.py+++ b/deeptutor/partners/helpers.py@@ -72,3 +72,13 @@ def split_message(content: str, max_len: int = 2000) -> list[str]:chunks.append(content[:pos])content = content[pos:].lstrip()return chunks+++def is_markdown_table_separator_row(cells: list[str]) -> bool:+ """True if *cells* look like a markdown table separator row.++ An all-empty row is not a separator (`all([])` would otherwise be True).+ """+ return bool(any(c for c in cells)) and all(+ re.match(r"^:?-+:?$", c) for c in cells if c+ )diff --git a/tests/partners/test_markdown_table_separator_row.py b/tests/partners/test_markdown_table_separator_row.pynew file mode 100644index 000000000..615f22a7d--- /dev/null+++ b/tests/partners/test_markdown_table_separator_row.py@@ -0,0 +1,18 @@+"""All-empty markdown table rows are not separators."""++from deeptutor.partners.helpers import is_markdown_table_separator_row+++def test_empty_row_is_not_separator() -> None:+ assert is_markdown_table_separator_row(["", "", ""]) is False+ assert is_markdown_table_separator_row([]) is False+++def test_dash_row_is_separator() -> None:+ assert is_markdown_table_separator_row(["---", "---"]) is True+ assert is_markdown_table_separator_row([":---", "---:"]) is True+++def test_data_row_is_not_separator() -> None:+ assert is_markdown_table_separator_row(["1", "2"]) is False+ assert is_markdown_table_separator_row(["1", "", "3"]) is False