Skip to content

Commit abb8f35

Browse files
author
mengqian
committed
feat: support OCR handwriting recognition feature
1 parent cde9ac7 commit abb8f35

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/zai/api_resource/file_parser/handwriting_ocr.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
__all__ = ["HandwritingOCR"]
2626

27+
2728
class HandwritingOCR(BaseAPI):
2829

2930
def __init__(self, client: "ZaiClient") -> None:
@@ -34,7 +35,7 @@ def handwriting_ocr(
3435
*,
3536
file: FileTypes,
3637
tool_type: Literal["hand_write"],
37-
language_type: str = None, # optional
38+
language_type: str = None, # optional
3839
extra_headers: Headers | None = None,
3940
extra_body: Body | None = None,
4041
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
@@ -61,4 +62,4 @@ def handwriting_ocr(
6162
extra_headers=extra_headers, extra_body=extra_body, timeout=timeout
6263
),
6364
cast_type=HandwritingOCRResp,
64-
)
65+
)

src/zai/types/file_parser/handwriting_ocr_params.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
__all__ = ["HandwritingOCRParams"]
77

8+
89
class HandwritingOCRParams(TypedDict, total=False):
910
file: FileTypes # Required
1011
tool_type: Literal["hand_write"] # Required
11-
language_type: str # Optional
12+
language_type: str # Optional

src/zai/types/file_parser/handwriting_ocr_resp.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@
55

66
__all__ = ["HandwritingOCRResp"]
77

8+
89
class Location(BaseModel):
910
left: int
1011
top: int
1112
width: int
1213
height: int
1314

15+
1416
class WordsResult(BaseModel):
1517
location: Location
1618
words: str
1719

20+
1821
class HandwritingOCRResp(BaseModel):
19-
task_id: str # Task ID or Result ID
20-
message: str # Status message
21-
status: str # OCR task status
22-
words_result_num: int # Number of recognition results
23-
words_result: Optional[List[WordsResult]] = None # List of recognition resultst details (if any)
22+
task_id: str # Task ID or Result ID
23+
message: str # Status message
24+
status: str # OCR task status
25+
words_result_num: int # Number of recognition results
26+
words_result: Optional[List[WordsResult]] = None # List of recognition resultst details (if any)

0 commit comments

Comments
 (0)