Spaces:
Running on Zero
Running on Zero
Map formula prompt key to the equation block type
Browse files
app.py
CHANGED
|
@@ -104,6 +104,8 @@ REGION_TASKS = [
|
|
| 104 |
("Chart / scientific figure \u2192 table", "char"),
|
| 105 |
("Seal", "seal"),
|
| 106 |
]
|
|
|
|
|
|
|
| 107 |
# The model prefixes recognized code with its own language marker, e.g. `<_Python_>`.
|
| 108 |
CODE_LANG_RE = re.compile(r"^\s*<_([A-Za-z0-9+#._\- ]+)_>\s*")
|
| 109 |
|
|
@@ -297,7 +299,11 @@ def parse_document(
|
|
| 297 |
DEFAULT_PROMPTS[task],
|
| 298 |
_sampling_params(task, max_new_tokens),
|
| 299 |
)
|
| 300 |
-
block = ContentBlock(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 301 |
blocks = helper.post_process([block]) or [block]
|
| 302 |
raw_markdown, display_markdown = blocks_to_markdown(page, blocks, False)
|
| 303 |
seconds = time.time() - started
|
|
|
|
| 104 |
("Chart / scientific figure \u2192 table", "char"),
|
| 105 |
("Seal", "seal"),
|
| 106 |
]
|
| 107 |
+
# Prompt keys and block-type names differ for formulas ("formula" vs "equation").
|
| 108 |
+
TASK_BLOCK_TYPES = {"formula": "equation"}
|
| 109 |
# The model prefixes recognized code with its own language marker, e.g. `<_Python_>`.
|
| 110 |
CODE_LANG_RE = re.compile(r"^\s*<_([A-Za-z0-9+#._\- ]+)_>\s*")
|
| 111 |
|
|
|
|
| 299 |
DEFAULT_PROMPTS[task],
|
| 300 |
_sampling_params(task, max_new_tokens),
|
| 301 |
)
|
| 302 |
+
block = ContentBlock(
|
| 303 |
+
type=TASK_BLOCK_TYPES.get(task, task),
|
| 304 |
+
bbox=[[0.0, 0.0], [1.0, 1.0]],
|
| 305 |
+
content=output,
|
| 306 |
+
)
|
| 307 |
blocks = helper.post_process([block]) or [block]
|
| 308 |
raw_markdown, display_markdown = blocks_to_markdown(page, blocks, False)
|
| 309 |
seconds = time.time() - started
|