mistocr 0.2.10__py3-none-any.whl → 0.2.12__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mistocr/__init__.py +1 -1
- mistocr/_modidx.py +1 -0
- mistocr/core.py +7 -1
- mistocr/refine.py +8 -3
- {mistocr-0.2.10.dist-info → mistocr-0.2.12.dist-info}/METADATA +1 -1
- mistocr-0.2.12.dist-info/RECORD +11 -0
- mistocr-0.2.10.dist-info/RECORD +0 -11
- {mistocr-0.2.10.dist-info → mistocr-0.2.12.dist-info}/WHEEL +0 -0
- {mistocr-0.2.10.dist-info → mistocr-0.2.12.dist-info}/entry_points.txt +0 -0
- {mistocr-0.2.10.dist-info → mistocr-0.2.12.dist-info}/licenses/LICENSE +0 -0
- {mistocr-0.2.10.dist-info → mistocr-0.2.12.dist-info}/top_level.txt +0 -0
mistocr/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.2.
|
|
1
|
+
__version__ = "0.2.12"
|
mistocr/_modidx.py
CHANGED
|
@@ -22,6 +22,7 @@ d = { 'settings': { 'branch': 'main',
|
|
|
22
22
|
'mistocr.core.wait_for_job': ('core.html#wait_for_job', 'mistocr/core.py')},
|
|
23
23
|
'mistocr.pipeline': {'mistocr.pipeline.pdf_to_md': ('pipeline.html#pdf_to_md', 'mistocr/pipeline.py')},
|
|
24
24
|
'mistocr.refine': { 'mistocr.refine.HeadingCorrection': ('refine.html#headingcorrection', 'mistocr/refine.py'),
|
|
25
|
+
'mistocr.refine.HeadingCorrections': ('refine.html#headingcorrections', 'mistocr/refine.py'),
|
|
25
26
|
'mistocr.refine.ImgDescription': ('refine.html#imgdescription', 'mistocr/refine.py'),
|
|
26
27
|
'mistocr.refine.add_descs_to_pg': ('refine.html#add_descs_to_pg', 'mistocr/refine.py'),
|
|
27
28
|
'mistocr.refine.add_descs_to_pgs': ('refine.html#add_descs_to_pgs', 'mistocr/refine.py'),
|
mistocr/core.py
CHANGED
|
@@ -79,11 +79,17 @@ def submit_batch(
|
|
|
79
79
|
def wait_for_job(
|
|
80
80
|
job:dict, # Job dict,
|
|
81
81
|
c:Mistral=None, # Mistral client,
|
|
82
|
-
poll_interval:int=1 # Poll interval in seconds
|
|
82
|
+
poll_interval:int=1, # Poll interval in seconds
|
|
83
|
+
queued_timeout:int=300 # Timeout for QUEUED status in seconds
|
|
83
84
|
) -> dict: # Job dict (with status)
|
|
84
85
|
"Poll job until completion and return final job status"
|
|
86
|
+
queued_time = 0
|
|
85
87
|
while job.status in ["QUEUED", "RUNNING"]:
|
|
86
88
|
print(f'Mistral batch job status: {job.status}')
|
|
89
|
+
if job.status == "QUEUED":
|
|
90
|
+
queued_time += poll_interval
|
|
91
|
+
if queued_time >= queued_timeout:
|
|
92
|
+
raise TimeoutError(f"Job stayed in QUEUED status for {queued_time}s, exceeding timeout of {queued_timeout}s. Check your balance or Mistral Status.")
|
|
87
93
|
time.sleep(poll_interval)
|
|
88
94
|
job = c.batch.jobs.get(job_id=job.id)
|
|
89
95
|
return job
|
mistocr/refine.py
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
# %% auto 0
|
|
6
6
|
__all__ = ['prompt_fix_hdgs', 'describe_img_prompt', 'get_hdgs', 'add_pg_hdgs', 'read_pgs_pg', 'fmt_hdgs_idx',
|
|
7
|
-
'HeadingCorrection', '
|
|
8
|
-
'
|
|
9
|
-
'add_img_descs']
|
|
7
|
+
'HeadingCorrection', 'HeadingCorrections', 'fix_hdg_hierarchy', 'mk_fixes_lut', 'apply_hdg_fixes',
|
|
8
|
+
'fix_hdgs', 'ImgDescription', 'describe_img', 'limit', 'parse_r', 'describe_imgs', 'save_img_descs',
|
|
9
|
+
'add_descs_to_pg', 'add_descs_to_pgs', 'add_img_descs']
|
|
10
10
|
|
|
11
11
|
# %% ../nbs/01_refine.ipynb 3
|
|
12
12
|
from fastcore.all import *
|
|
@@ -64,6 +64,11 @@ class HeadingCorrection(BaseModel):
|
|
|
64
64
|
index: int
|
|
65
65
|
corrected: str
|
|
66
66
|
|
|
67
|
+
# %% ../nbs/01_refine.ipynb 19
|
|
68
|
+
class HeadingCorrections(BaseModel):
|
|
69
|
+
"Collection of heading corrections returned by the LLM"
|
|
70
|
+
corrections: list[HeadingCorrection]
|
|
71
|
+
|
|
67
72
|
# %% ../nbs/01_refine.ipynb 21
|
|
68
73
|
prompt_fix_hdgs = """Fix markdown heading hierarchy errors while preserving the document's intended structure.
|
|
69
74
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
mistocr/__init__.py,sha256=X4KG3FscE5AhbGbcdDDgdDC550CVpxNMwdNLcx6EQ7M,23
|
|
2
|
+
mistocr/_modidx.py,sha256=55k_EmMPrRmLa04qCE-_8lukJPCax66q5MALfpa8T4A,4154
|
|
3
|
+
mistocr/core.py,sha256=ohh2ru05gUKbIQCRHPMz_hw4ui39FtpoV3_S3n4bl_c,7592
|
|
4
|
+
mistocr/pipeline.py,sha256=k5rtr9ccxTgwQAzw533iMIL9qwiCofugWv0fhotLzaI,1639
|
|
5
|
+
mistocr/refine.py,sha256=hQg4ZYRTkPFEiCNNBU2ykgXFfVLCNAp2IuwOwHBVQ2k,12983
|
|
6
|
+
mistocr-0.2.12.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
7
|
+
mistocr-0.2.12.dist-info/METADATA,sha256=MB_1D5vpqGUIA_jl-jNHj7E5LHJol6YGU8lw-ZCFj_4,8417
|
|
8
|
+
mistocr-0.2.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
+
mistocr-0.2.12.dist-info/entry_points.txt,sha256=HjAiHozobM-alm_6bTF-ehRr2DD3KYE9PgRngelONOY,36
|
|
10
|
+
mistocr-0.2.12.dist-info/top_level.txt,sha256=LelTYnSpSXLy1Hb1m2YP3gt8luwP-I8KV0NjP_ucdSs,8
|
|
11
|
+
mistocr-0.2.12.dist-info/RECORD,,
|
mistocr-0.2.10.dist-info/RECORD
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
mistocr/__init__.py,sha256=waXgc7p-jgGCsUjdVfO_KjlVZblnCvrzf4A0dsBj_lg,23
|
|
2
|
-
mistocr/_modidx.py,sha256=WTS9JpZdbrp2LghjhOV-CK0JYChHE4PzttgKfh7pTy4,4028
|
|
3
|
-
mistocr/core.py,sha256=KH5ND6ZMmETj9m9A-Ivtw5N2L-qm9vGwYgvHAzg-BsA,7218
|
|
4
|
-
mistocr/pipeline.py,sha256=k5rtr9ccxTgwQAzw533iMIL9qwiCofugWv0fhotLzaI,1639
|
|
5
|
-
mistocr/refine.py,sha256=H_IAF02k6CwBQdDJm9txknzUcTlz245zXitaHELX-P4,12791
|
|
6
|
-
mistocr-0.2.10.dist-info/licenses/LICENSE,sha256=xV8xoN4VOL0uw9X8RSs2IMuD_Ss_a9yAbtGNeBWZwnw,11337
|
|
7
|
-
mistocr-0.2.10.dist-info/METADATA,sha256=mkMu_9nYAXZ5jFdJd01AZqK3t93_Rt0xkkD0rRnl9Ew,8417
|
|
8
|
-
mistocr-0.2.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
9
|
-
mistocr-0.2.10.dist-info/entry_points.txt,sha256=HjAiHozobM-alm_6bTF-ehRr2DD3KYE9PgRngelONOY,36
|
|
10
|
-
mistocr-0.2.10.dist-info/top_level.txt,sha256=LelTYnSpSXLy1Hb1m2YP3gt8luwP-I8KV0NjP_ucdSs,8
|
|
11
|
-
mistocr-0.2.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|