clerk-sdk 0.5.8__py3-none-any.whl → 0.5.10__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.10"
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
 
@@ -70,74 +71,23 @@ class Clerk(BaseClerk):
70
71
  files_data = [f.to_multipart_format() for f in files]
71
72
  self.post_request(endpoint, params=params, files=files_data)
72
73
 
73
-
74
- class ClerkDocument(BaseClerk):
75
- endpoint: str = "/document"
76
-
77
- def upload_document(self, request: UploadDocumentRequest) -> Document:
78
- endpoint = "/document"
74
+ def prevalidate_file(
75
+ self, project_id: str, workflow_id: str, file: UploadFile
76
+ ) -> Dict[str, Any]:
77
+ """Submit a prevalidation for a specific file. Returns the id for fetching the results later."""
78
+ endpoint = f"/prevalidation/file"
79
+ files_data = [file.to_multipart_format()]
79
80
  res = self.post_request(
80
- endpoint=endpoint, data=request.data, files=request.files_
81
+ endpoint,
82
+ files=files_data,
83
+ data={"project_id": project_id, "workflow_id": workflow_id},
81
84
  )
82
- return Document(**res.data[0])
83
-
84
- def reprocess_document(self, document_id: str, workflow_id: str) -> Document:
85
- endpoint = f"/document/{document_id}/reprocess"
86
- res = self.put_request(endpoint=endpoint, data={"workflow_id": workflow_id})
87
- return Document(**res.data[0])
88
-
89
- def cancel_document_run(self, document_id: str) -> Document:
90
- endpoint = f"/document/{document_id}/cancel"
91
- res = self.post_request(endpoint=endpoint)
92
- return Document(**res.data[0])
93
-
94
- def update_document_structured_data(
95
- self, document_id: str, updated_structured_data: Dict[str, Any]
96
- ) -> Document:
97
- endpoint = f"/document/{document_id}"
98
- payload = dict(structured_data=updated_structured_data)
99
- res = self.put_request(endpoint, json=payload)
100
-
101
- return Document(**res.data[0])
102
-
103
- def get_document(self, document_id: str) -> Document:
104
- endpoint = f"/document/{document_id}"
105
- res = self.get_request(endpoint=endpoint)
106
- return Document(**res.data[0])
107
-
108
- def get_documents(self, request: GetDocumentsRequest) -> List[Document]:
109
- if not any(
110
- [
111
- request.organization_id,
112
- request.project_id,
113
- request.start_date,
114
- request.end_date,
115
- request.query,
116
- request.include_statuses,
117
- ]
118
- ):
119
- raise ValueError(
120
- "At least one query parameter (organization_id, project_id, start_date, end_date, query, or include_statuses) must be provided."
121
- )
122
-
123
- endpoint = f"/documents"
124
- params = request.model_dump(mode="json")
125
- res = self.get_request(endpoint, params=params)
126
-
127
- return [Document(**d) for d in res.data]
128
-
129
- def get_files_document(self, document_id: str) -> List[ParsedFile]:
130
- endpoint = f"/document/{document_id}/files"
131
- res = self.get_request(endpoint=endpoint)
132
- return [ParsedFile(**d) for d in res.data]
133
-
134
- def add_files_to_document(
135
- self,
136
- document_id: str,
137
- type: Literal["input", "output"],
138
- files: List[UploadFile],
139
- ):
140
- endpoint = f"/document/{document_id}/files/upload"
141
- params = {"type": type}
142
- files_data = [f.to_multipart_format() for f in files]
143
- self.post_request(endpoint, params=params, files=files_data)
85
+ return res.data[0]
86
+
87
+ def get_prevalidation_results(
88
+ self, workflow_run_id: str
89
+ ) -> FileClassificationResponse:
90
+ """Fetch the results of a previously submitted prevalidation."""
91
+ endpoint = f"/prevalidation/file"
92
+ res = self.get_request(endpoint, params={"workflow_run_id": workflow_run_id})
93
+ 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.10
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=guyotbECs9C88el84Xes-MMJ_X80QdLi8y-tOQFXK9s,51
2
2
  clerk/base.py,sha256=lbFTdpdDfsmYIQUFH93S1aw0-L6GNJwAcubW1tdMFX4,3967
3
- clerk/client.py,sha256=JGhDUb4m8R7ZTHLxFsAwAw0vNA1kxewg5-GC6qOFYDk,5244
3
+ clerk/client.py,sha256=Es6FyRlxXhiHBag2Hhy3gw5aQyP3Nlfn3Nt01C-VJt0,3519
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.10.dist-info/METADATA,sha256=QRgxgexHqT-Vp5kTDuMk6u66m-RVtxEdbEb9YSAvjsE,9636
68
+ clerk_sdk-0.5.10.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
69
+ clerk_sdk-0.5.10.dist-info/entry_points.txt,sha256=VoUmW07sRRSioms5pqQ4A6CYxNEyhGA93GtyBlB_wGw,53
70
+ clerk_sdk-0.5.10.dist-info/licenses/LICENSE,sha256=GTVQl3vH6ht70wJXKC0yMT8CmXKHxv_YyO_utAgm7EA,1065
71
+ clerk_sdk-0.5.10.dist-info/RECORD,,