- Drop image padding in GLMOCREndToEndService.recognize(); use raw image directly - Fix F821 undefined `padded` references replaced with `image` - Fix F601 duplicate dict key "≠" in converter - Fix F841 unused `image_cls_ids` variable in layout_postprocess - Fix E702 semicolon-separated statements in layout_postprocess - Fix UP031 percent-format replaced with f-string in logging_config - Auto-fix 44 additional ruff violations (import order, UP035/UP045/UP006, F401, F541) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Request and response schemas for format conversion endpoints."""
|
|
|
|
from pydantic import BaseModel, Field, field_validator
|
|
|
|
|
|
class MarkdownToDocxRequest(BaseModel):
|
|
"""Request body for markdown to DOCX conversion endpoint."""
|
|
|
|
markdown: str = Field(..., description="Markdown content to convert")
|
|
filename: str = Field("texpixel", description="Optional output filename (without extension)")
|
|
|
|
@field_validator("markdown")
|
|
@classmethod
|
|
def validate_markdown_not_empty(cls, v: str) -> str:
|
|
"""Validate that markdown content is not empty."""
|
|
if not v or not v.strip():
|
|
raise ValueError("Markdown content cannot be empty")
|
|
return v
|
|
|
|
|
|
class LatexToOmmlRequest(BaseModel):
|
|
"""Request body for LaTeX to OMML conversion endpoint."""
|
|
|
|
latex: str = Field(..., description="Pure LaTeX formula (without $ or $$ delimiters)")
|
|
|
|
@field_validator("latex")
|
|
@classmethod
|
|
def validate_latex_not_empty(cls, v: str) -> str:
|
|
"""Validate that LaTeX formula is not empty."""
|
|
if not v or not v.strip():
|
|
raise ValueError("LaTeX formula cannot be empty")
|
|
return v
|
|
|
|
|
|
class LatexToOmmlResponse(BaseModel):
|
|
"""Response body for LaTeX to OMML conversion endpoint."""
|
|
|
|
omml: str = Field("", description="OMML (Office Math Markup Language) representation")
|