clerk-sdk 0.5.8__py3-none-any.whl → 0.5.9__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.
clerk/__init__.py CHANGED
@@ -1,4 +1,4 @@
1
1
  from .client import Clerk
2
2
 
3
3
 
4
- __version__ = "0.5.8"
4
+ __version__ = "0.5.9"
clerk/client.py CHANGED
@@ -2,6 +2,7 @@ from typing import Any, Dict, List, Literal
2
2
 
3
3
  from clerk.base import BaseClerk
4
4
  from clerk.models.document import Document, GetDocumentsRequest, UploadDocumentRequest
5
+ from clerk.models.prevalidation import FileClassificationResponse
5
6
  from .models.file import ParsedFile, UploadFile
6
7
 
7
8
 
@@ -141,3 +142,24 @@ class ClerkDocument(BaseClerk):
141
142
  params = {"type": type}
142
143
  files_data = [f.to_multipart_format() for f in files]
143
144
  self.post_request(endpoint, params=params, files=files_data)
145
+
146
+ def prevalidate_file(
147
+ self, project_id: str, workflow_id: str, file: UploadFile
148
+ ) -> Dict[str, Any]:
149
+ """Submit a prevalidation for a specific file. Returns the id for fetching the results later."""
150
+ endpoint = f"/prevalidation/file"
151
+ files_data = [file.to_multipart_format()]
152
+ res = self.post_request(
153
+ endpoint,
154
+ files=files_data,
155
+ data={"project_id": project_id, "workflow_id": workflow_id},
156
+ )
157
+ return res.data[0]
158
+
159
+ def get_prevalidation_results(
160
+ self, workflow_run_id: str
161
+ ) -> FileClassificationResponse:
162
+ """Fetch the results of a previously submitted prevalidation."""
163
+ endpoint = f"/prevalidation/file"
164
+ res = self.get_request(endpoint, params={"workflow_run_id": workflow_run_id})
165
+ return FileClassificationResponse(**res.data[0])
@@ -0,0 +1,33 @@
1
+ from typing import Dict, List, Optional
2
+ from pydantic import BaseModel, Field
3
+
4
+
5
+ class LabelWithDescriptions(BaseModel):
6
+ label: str = Field(..., description="The label/category name")
7
+ description: Optional[str] = Field(
8
+ None, description="Optional description of the label/category"
9
+ )
10
+ attributes: Optional[List[str]] = Field(
11
+ None, description="Optional attributes for the label/category"
12
+ )
13
+ start_page: Optional[int] = Field(
14
+ None, description="Start page for classification (0-based, inclusive)"
15
+ )
16
+ end_page: Optional[int] = Field(
17
+ None, description="End page for classification (0-based, exclusive)"
18
+ )
19
+
20
+
21
+ class FileClassificationResponse(BaseModel):
22
+ valid: bool = Field(False, description="Whether the file classification is valid")
23
+ filename: str = Field(..., description="The name of the file that was classified")
24
+ classification: Optional[str] = Field(
25
+ None, description="The selected classification category"
26
+ )
27
+ reason: Optional[str] = Field(
28
+ None,
29
+ description="The reasoning behind the classification. To be filled if no classification is made.",
30
+ )
31
+ possible_categories: Optional[Dict[str, LabelWithDescriptions]] = Field(
32
+ None, description="Possible categories for classification"
33
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clerk-sdk
3
- Version: 0.5.8
3
+ Version: 0.5.9
4
4
  Summary: Library for interacting with Clerk
5
5
  Project-URL: Homepage, https://github.com/F-ONE-Group/clerk_pypi
6
6
  Author-email: F-One <contact@f-one.group>
@@ -1,6 +1,6 @@
1
- clerk/__init__.py,sha256=VzJGCDzhcxnxxL_3jMTrJkSpzpBvf-eENxpTCtkRKO8,50
1
+ clerk/__init__.py,sha256=T8POtk74JbOxx1goIgcDxg7-nUH3newanTKZydi4AVE,50
2
2
  clerk/base.py,sha256=lbFTdpdDfsmYIQUFH93S1aw0-L6GNJwAcubW1tdMFX4,3967
3
- clerk/client.py,sha256=JGhDUb4m8R7ZTHLxFsAwAw0vNA1kxewg5-GC6qOFYDk,5244
3
+ clerk/client.py,sha256=XkXyC92rR59tq854wZ56M91tCzo299pu5bKtWC0n0ao,6186
4
4
  clerk/decorator/__init__.py,sha256=yGGcS17VsZ7cZ-hVGCm3I3vGDJMiJIAqmDGzriIi0DI,65
5
5
  clerk/decorator/models.py,sha256=nFMdVSG3nJ4hrEXs9YbI_GgjHbVjhSWZokOCzUh-lqQ,521
6
6
  clerk/decorator/task_decorator.py,sha256=H8caRvNvvl-IRwyREP66gBGVM-SpQJ1W7oAFImO-6Jw,3769
@@ -57,14 +57,15 @@ clerk/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
57
57
  clerk/models/document.py,sha256=KCO2f255Nodi2JY4BeK3oGSaQ_aMHvrAAaKbOARu8Ww,3039
58
58
  clerk/models/document_statuses.py,sha256=67EMwh7FUNEOkb563mO5WtckK1EICY-sk9pRhD-BYK4,347
59
59
  clerk/models/file.py,sha256=wfMGoNTsIBFxpPUzOTOkUYZ-FGxXg6n2mZhDCBt6Jbc,733
60
+ clerk/models/prevalidation.py,sha256=UKdpaQG1FuOVJtLLTgvlLMVA5U6kcUYAJ80F27YhDVo,1317
60
61
  clerk/models/remote_device.py,sha256=2jijS-9WWq7y6xIbAaDaPnzZo3-tjp2-dCQvNKP8YSU,109
61
62
  clerk/models/response_model.py,sha256=R62daUN1YVOwgnrh_epvFRsQcOwT7R4u97l73egvm-c,232
62
63
  clerk/models/ui_operator.py,sha256=mKTJUFZgv7PeEt5oys28HVZxHOJsofmRQOcRpqj0dbU,293
63
64
  clerk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
65
  clerk/utils/logger.py,sha256=NrMIlJfVmRjjRw_N_Jngkl0qqv7btXUbg5wxcRmFEH4,3800
65
66
  clerk/utils/save_artifact.py,sha256=94aYkYNVGcSUaSWZmdjiY6Oc-3yCKb2XWCZ56IAXQqk,1158
66
- clerk_sdk-0.5.8.dist-info/METADATA,sha256=TytUb6ss1EOrO1WG1_6qxaLxu4Fj8z2N8nUHQTuN8ro,9635
67
- clerk_sdk-0.5.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
68
- clerk_sdk-0.5.8.dist-info/entry_points.txt,sha256=VoUmW07sRRSioms5pqQ4A6CYxNEyhGA93GtyBlB_wGw,53
69
- clerk_sdk-0.5.8.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
70
- clerk_sdk-0.5.8.dist-info/RECORD,,
67
+ clerk_sdk-0.5.9.dist-info/METADATA,sha256=UayF7_QaSLg9o_Ah3jc42jn2cDyX6Gjrqospip4Poag,9635
68
+ clerk_sdk-0.5.9.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
69
+ clerk_sdk-0.5.9.dist-info/entry_points.txt,sha256=VoUmW07sRRSioms5pqQ4A6CYxNEyhGA93GtyBlB_wGw,53
70
+ clerk_sdk-0.5.9.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
71
+ clerk_sdk-0.5.9.dist-info/RECORD,,