Skip to content

Commit cd7dbf9

Browse files
authored
Merge pull request #351 from edenai/SD2-1394-fix-mistral-ocr-async
[Fix] bounding box optional for ocr async
2 parents 0a060fe + e804a4d commit cd7dbf9

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

edenai_apis/apis/mistral/mistral_api.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -343,12 +343,12 @@ def ocr__ocr_async__get_job_result(
343343
pages = []
344344
for page in response_data["pages"]:
345345
raw_text += page["markdown"]
346-
# markdown_lines = page["markdown"].split("\n")
347-
# lines = []
348-
# for line_text in markdown_lines:
349-
# line = Line(text=line_text, bounding_box=BoundingBox())
350-
# lines.append(line)
351-
# pages.append(Page(lines=lines))
346+
markdown_lines = page["markdown"].split("\n")
347+
lines = []
348+
for line_text in markdown_lines:
349+
line = Line(text=line_text, confidence=100)
350+
lines.append(line)
351+
pages.append(Page(lines=lines))
352352

353353
return AsyncResponseType(
354354
original_response=response_data,

edenai_apis/features/ocr/ocr_async/ocr_async_dataclass.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ class Line(BaseModel):
187187

188188
text: str = Field(description="Text detected in the line")
189189
words: Sequence[Word] = Field(default_factory=list, description="List of words")
190-
bounding_box: BoundingBox = Field(
191-
description="Bounding boxes of the words in the line"
190+
bounding_box: Optional[BoundingBox] = Field(
191+
default=None, description="Bounding box of the line, can be None"
192192
)
193193
confidence: Optional[float] = Field(..., description="Confidence of the line")
194194

0 commit comments

Comments
 (0)