Skip to content

Commit f0d6cfd

Browse files
Merge pull request #55 from JigsawStack/feat/vocr-prompt-optional
made vocr prompt optional
2 parents 759ab50 + 282ac77 commit f0d6cfd

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

jigsawstack/vision.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Point(TypedDict):
1212
"""
1313
X coordinate of the point
1414
"""
15-
15+
1616
y: int
1717
"""
1818
Y coordinate of the point
@@ -24,27 +24,27 @@ class BoundingBox(TypedDict):
2424
"""
2525
Top-left corner of the bounding box
2626
"""
27-
27+
2828
top_right: Point
2929
"""
3030
Top-right corner of the bounding box
3131
"""
32-
32+
3333
bottom_left: Point
3434
"""
3535
Bottom-left corner of the bounding box
3636
"""
37-
37+
3838
bottom_right: Point
3939
"""
4040
Bottom-right corner of the bounding box
4141
"""
42-
42+
4343
width: int
4444
"""
4545
Width of the bounding box
4646
"""
47-
47+
4848
height: int
4949
"""
5050
Height of the bounding box
@@ -56,7 +56,7 @@ class GuiElement(TypedDict):
5656
"""
5757
Bounding box coordinates of the GUI element
5858
"""
59-
59+
6060
content: Union[str, None]
6161
"""
6262
Content of the GUI element, can be null if no object detected
@@ -68,40 +68,39 @@ class DetectedObject(TypedDict):
6868
"""
6969
Bounding box coordinates of the detected object
7070
"""
71-
71+
7272
mask: NotRequired[str]
7373
"""
7474
URL or base64 string depending on return_type - only present for some objects
7575
"""
7676

7777

78-
7978
class ObjectDetectionParams(TypedDict):
8079
url: NotRequired[str]
8180
"""
8281
URL of the image to process
8382
"""
84-
83+
8584
file_store_key: NotRequired[str]
8685
"""
8786
File store key of the image to process
8887
"""
89-
88+
9089
prompts: NotRequired[List[str]]
9190
"""
9291
List of prompts for object detection
9392
"""
94-
93+
9594
features: NotRequired[List[Literal["object_detection", "gui"]]]
9695
"""
9796
List of features to enable: object_detection, gui
9897
"""
99-
98+
10099
annotated_image: NotRequired[bool]
101100
"""
102101
Whether to return an annotated image
103102
"""
104-
103+
105104
return_type: NotRequired[Literal["url", "base64"]]
106105
"""
107106
Format for returned images: url or base64
@@ -113,20 +112,20 @@ class ObjectDetectionResponse(TypedDict):
113112
"""
114113
URL or base64 string of annotated image (included only if annotated_image=true and objects/gui_elements exist)
115114
"""
116-
115+
117116
gui_elements: NotRequired[List[GuiElement]]
118117
"""
119118
List of detected GUI elements (included only if features includes "gui")
120119
"""
121-
120+
122121
objects: NotRequired[List[DetectedObject]]
123122
"""
124123
List of detected objects (included only if features includes "object_detection")
125124
"""
126125

127126

128127
class VOCRParams(TypedDict):
129-
prompt: Union[str, List[str]]
128+
prompt: NotRequired[Union[str, List[str]]]
130129
url: NotRequired[str]
131130
file_store_key: NotRequired[str]
132131
page_range: NotRequired[List[int]]
@@ -173,7 +172,9 @@ def vocr(self, params: VOCRParams) -> OCRResponse:
173172
).perform_with_content()
174173
return resp
175174

176-
def object_detection(self, params: ObjectDetectionParams) -> ObjectDetectionResponse:
175+
def object_detection(
176+
self, params: ObjectDetectionParams
177+
) -> ObjectDetectionResponse:
177178
path = "/object_detection"
178179
resp = Request(
179180
config=self.config,
@@ -210,7 +211,9 @@ async def vocr(self, params: VOCRParams) -> OCRResponse:
210211
).perform_with_content()
211212
return resp
212213

213-
async def object_detection(self, params: ObjectDetectionParams) -> ObjectDetectionResponse:
214+
async def object_detection(
215+
self, params: ObjectDetectionParams
216+
) -> ObjectDetectionResponse:
214217
path = "/object_detection"
215218
resp = await AsyncRequest(
216219
config=self.config,

0 commit comments

Comments
 (0)