Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: keep ticked Word form check boxes in Chat with files (#13485)
Nilay1e87a426e756
diff --git a/studio/backend/core/rag/parsers.py b/studio/backend/core/rag/parsers.pyindex 99382c12772..830f544c024 100644--- a/studio/backend/core/rag/parsers.py+++ b/studio/backend/core/rag/parsers.py@@ -798,11 +798,31 @@ def _docx_math_text(element) -> str:return "".join(_docx_math_text(child) for child in element.iterchildren("*"))+def _docx_checkbox(field) -> str:+ box = field.find(f"{_W}ffData/{_W}checkBox")+ if box is None:+ return ""+ flag = box.find(_W + "checked")+ if flag is None:+ flag = box.find(_W + "default")+ ticked = flag is not None and flag.get(_W + "val", "true") not in ("0", "false", "off")+ return "☒" if ticked else "☐"+++def _docx_run_text(run) -> str:+ if run.find(f"{_W}fldChar/{_W}ffData/{_W}checkBox") is None:+ return run.text+ return "".join(+ _docx_checkbox(e) if e.tag == _W + "fldChar" else str(e)+ for e in run.xpath("w:br | w:cr | w:noBreakHyphen | w:ptab | w:t | w:tab | w:fldChar")+ )++def _docx_paragraph_text(paragraph) -> str:"""Paragraph.text skips runs wrapped in w:ins, w:sdt, w:fldSimple, w:smartTag, and equations."""p = paragraph._preturn "".join(- _docx_math_text(node) if node.tag in _DOCX_MATH else node.text+ _docx_math_text(node) if node.tag in _DOCX_MATH else _docx_run_text(node)for node in p.iter(_W + "r", *_DOCX_MATH)if not _docx_inside(node, p, _DOCX_SKIP_RUNS_OR_MATH))diff --git a/studio/backend/tests/test_rag_parsing.py b/studio/backend/tests/test_rag_parsing.pyindex bab99e2bf20..9dbd3a97178 100644--- a/studio/backend/tests/test_rag_parsing.py+++ b/studio/backend/tests/test_rag_parsing.py@@ -555,6 +555,45 @@ def test_docx_reads_one_branch_of_alternate_content(tmp_path):assert text == "Preferred"+def _legacy_checkbox(state):+ return (+ f'<w:r><w:fldChar w:fldCharType="begin"><w:ffData><w:checkBox><w:sizeAuto/>{state}</w:checkBox>'+ "</w:ffData></w:fldChar></w:r>"+ '<w:r><w:instrText xml:space="preserve"> FORMCHECKBOX </w:instrText></w:r>'+ '<w:r><w:fldChar w:fldCharType="separate"/></w:r><w:r><w:fldChar w:fldCharType="end"/></w:r>'+ )+++def test_docx_keeps_ticked_state_of_legacy_form_checkboxes(tmp_path):+ ticked = _legacy_checkbox('<w:default w:val="0"/><w:checked/>')+ unticked = _legacy_checkbox('<w:default w:val="0"/>')+ ticked_by_default = _legacy_checkbox("<w:default/>")+ cleared = _legacy_checkbox('<w:default w:val="1"/><w:checked w:val="0"/>')+ text = _docx_from_xml(+ tmp_path,+ f"<w:p>{_r('Smoker: ')}{ticked}{_r(' Yes ')}{unticked}{_r(' No')}</w:p>",+ f"<w:tbl><w:tr><w:tc><w:p>{_r('Allergies')}</w:p></w:tc>"+ f"<w:tc><w:p>{ticked_by_default}{_r(' Yes ')}{cleared}{_r(' No')}</w:p></w:tc></w:tr></w:tbl>",+ )+ assert text == "Smoker: ☒ Yes ☐ No\nAllergies | ☒ Yes ☐ No"+++def test_docx_legacy_checkbox_sharing_a_run_with_its_label_stays_in_place(tmp_path):+ def labelled_box(label, state):+ return (+ f'<w:r><w:t xml:space="preserve">{label}</w:t><w:fldChar w:fldCharType="begin">'+ f"<w:ffData><w:checkBox>{state}</w:checkBox></w:ffData></w:fldChar></w:r>"+ '<w:r><w:instrText xml:space="preserve"> FORMCHECKBOX </w:instrText></w:r>'+ '<w:r><w:fldChar w:fldCharType="end"/></w:r>'+ )++ text = _docx_from_xml(+ tmp_path,+ f"<w:p>{labelled_box('Smoker: ', '')}{labelled_box(' Yes ', '<w:checked/>')}{_r(' No')}</w:p>",+ )+ assert text == "Smoker: ☐ Yes ☒ No"++def _m(text):return f'<m:r><w:rPr><w:rFonts w:ascii="Cambria Math"/></w:rPr><m:t>{text}</m:t></m:r>'