arbi 0.1.0__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.

Potentially problematic release.


This version of arbi might be problematic. Click here for more details.

Files changed (143) hide show
  1. arbi/__init__.py +90 -0
  2. arbi/_base_client.py +1995 -0
  3. arbi/_client.py +394 -0
  4. arbi/_compat.py +219 -0
  5. arbi/_constants.py +14 -0
  6. arbi/_exceptions.py +108 -0
  7. arbi/_files.py +123 -0
  8. arbi/_models.py +829 -0
  9. arbi/_qs.py +150 -0
  10. arbi/_resource.py +43 -0
  11. arbi/_response.py +830 -0
  12. arbi/_streaming.py +333 -0
  13. arbi/_types.py +219 -0
  14. arbi/_utils/__init__.py +57 -0
  15. arbi/_utils/_logs.py +25 -0
  16. arbi/_utils/_proxy.py +65 -0
  17. arbi/_utils/_reflection.py +42 -0
  18. arbi/_utils/_resources_proxy.py +24 -0
  19. arbi/_utils/_streams.py +12 -0
  20. arbi/_utils/_sync.py +86 -0
  21. arbi/_utils/_transform.py +447 -0
  22. arbi/_utils/_typing.py +151 -0
  23. arbi/_utils/_utils.py +422 -0
  24. arbi/_version.py +4 -0
  25. arbi/lib/.keep +4 -0
  26. arbi/py.typed +0 -0
  27. arbi/resources/__init__.py +19 -0
  28. arbi/resources/api/__init__.py +145 -0
  29. arbi/resources/api/api.py +422 -0
  30. arbi/resources/api/assistant.py +300 -0
  31. arbi/resources/api/configs.py +499 -0
  32. arbi/resources/api/conversation/__init__.py +33 -0
  33. arbi/resources/api/conversation/conversation.py +555 -0
  34. arbi/resources/api/conversation/user.py +270 -0
  35. arbi/resources/api/document/__init__.py +33 -0
  36. arbi/resources/api/document/annotation.py +384 -0
  37. arbi/resources/api/document/document.py +873 -0
  38. arbi/resources/api/health.py +304 -0
  39. arbi/resources/api/sso.py +333 -0
  40. arbi/resources/api/tag.py +614 -0
  41. arbi/resources/api/user/__init__.py +33 -0
  42. arbi/resources/api/user/settings.py +251 -0
  43. arbi/resources/api/user/user.py +532 -0
  44. arbi/resources/api/workspace.py +1061 -0
  45. arbi/types/__init__.py +8 -0
  46. arbi/types/api/__init__.py +84 -0
  47. arbi/types/api/assistant_query_params.py +59 -0
  48. arbi/types/api/assistant_retrieve_params.py +59 -0
  49. arbi/types/api/chunker_config_param.py +9 -0
  50. arbi/types/api/config_create_params.py +45 -0
  51. arbi/types/api/config_create_response.py +15 -0
  52. arbi/types/api/config_delete_response.py +11 -0
  53. arbi/types/api/config_get_versions_response.py +19 -0
  54. arbi/types/api/config_retrieve_response.py +46 -0
  55. arbi/types/api/conversation/__init__.py +8 -0
  56. arbi/types/api/conversation/user_add_params.py +11 -0
  57. arbi/types/api/conversation/user_add_response.py +11 -0
  58. arbi/types/api/conversation/user_remove_params.py +11 -0
  59. arbi/types/api/conversation/user_remove_response.py +11 -0
  60. arbi/types/api/conversation_delete_message_response.py +11 -0
  61. arbi/types/api/conversation_delete_response.py +11 -0
  62. arbi/types/api/conversation_retrieve_threads_response.py +91 -0
  63. arbi/types/api/conversation_share_response.py +11 -0
  64. arbi/types/api/conversation_update_title_params.py +12 -0
  65. arbi/types/api/conversation_update_title_response.py +13 -0
  66. arbi/types/api/doc_response.py +48 -0
  67. arbi/types/api/document/__init__.py +8 -0
  68. arbi/types/api/document/annotation_create_params.py +16 -0
  69. arbi/types/api/document/annotation_delete_response.py +11 -0
  70. arbi/types/api/document/annotation_update_params.py +16 -0
  71. arbi/types/api/document/doc_tag_response.py +26 -0
  72. arbi/types/api/document_date_extractor_llm_config.py +29 -0
  73. arbi/types/api/document_date_extractor_llm_config_param.py +28 -0
  74. arbi/types/api/document_delete_response.py +11 -0
  75. arbi/types/api/document_get_parsed_response.py +26 -0
  76. arbi/types/api/document_get_tags_response.py +10 -0
  77. arbi/types/api/document_update_params.py +19 -0
  78. arbi/types/api/document_update_response.py +22 -0
  79. arbi/types/api/document_upload_params.py +23 -0
  80. arbi/types/api/document_view_params.py +13 -0
  81. arbi/types/api/embedder_config.py +18 -0
  82. arbi/types/api/embedder_config_param.py +17 -0
  83. arbi/types/api/health_check_app_response.py +9 -0
  84. arbi/types/api/health_check_models_response.py +21 -0
  85. arbi/types/api/health_check_services_response.py +23 -0
  86. arbi/types/api/health_get_models_response.py +19 -0
  87. arbi/types/api/model_citation_config.py +23 -0
  88. arbi/types/api/model_citation_config_param.py +23 -0
  89. arbi/types/api/parser_config_param.py +9 -0
  90. arbi/types/api/query_llm_config.py +30 -0
  91. arbi/types/api/query_llm_config_param.py +29 -0
  92. arbi/types/api/reranker_config.py +21 -0
  93. arbi/types/api/reranker_config_param.py +20 -0
  94. arbi/types/api/retriever_config.py +23 -0
  95. arbi/types/api/retriever_config_param.py +23 -0
  96. arbi/types/api/sso_invite_params.py +11 -0
  97. arbi/types/api/sso_invite_response.py +11 -0
  98. arbi/types/api/sso_login_params.py +16 -0
  99. arbi/types/api/sso_login_response.py +15 -0
  100. arbi/types/api/sso_rotate_passcode_response.py +11 -0
  101. arbi/types/api/tag_apply_to_docs_params.py +12 -0
  102. arbi/types/api/tag_apply_to_docs_response.py +13 -0
  103. arbi/types/api/tag_create_params.py +18 -0
  104. arbi/types/api/tag_create_response.py +11 -0
  105. arbi/types/api/tag_delete_response.py +9 -0
  106. arbi/types/api/tag_get_docs_response.py +10 -0
  107. arbi/types/api/tag_remove_from_docs_params.py +12 -0
  108. arbi/types/api/tag_remove_from_docs_response.py +13 -0
  109. arbi/types/api/tag_update_params.py +14 -0
  110. arbi/types/api/tag_update_response.py +17 -0
  111. arbi/types/api/title_llm_config.py +29 -0
  112. arbi/types/api/title_llm_config_param.py +28 -0
  113. arbi/types/api/token.py +13 -0
  114. arbi/types/api/user/__init__.py +6 -0
  115. arbi/types/api/user/setting_retrieve_response.py +36 -0
  116. arbi/types/api/user/setting_update_params.py +24 -0
  117. arbi/types/api/user_list_workspaces_response.py +10 -0
  118. arbi/types/api/user_login_params.py +13 -0
  119. arbi/types/api/user_logout_response.py +9 -0
  120. arbi/types/api/user_register_params.py +17 -0
  121. arbi/types/api/user_response.py +19 -0
  122. arbi/types/api/workspace_create_protected_params.py +14 -0
  123. arbi/types/api/workspace_delete_response.py +9 -0
  124. arbi/types/api/workspace_get_conversations_response.py +28 -0
  125. arbi/types/api/workspace_get_doctags_response.py +10 -0
  126. arbi/types/api/workspace_get_documents_response.py +10 -0
  127. arbi/types/api/workspace_get_stats_response.py +13 -0
  128. arbi/types/api/workspace_get_tags_response.py +30 -0
  129. arbi/types/api/workspace_get_users_response.py +17 -0
  130. arbi/types/api/workspace_remove_user_params.py +11 -0
  131. arbi/types/api/workspace_remove_user_response.py +11 -0
  132. arbi/types/api/workspace_response.py +24 -0
  133. arbi/types/api/workspace_share_params.py +11 -0
  134. arbi/types/api/workspace_share_response.py +21 -0
  135. arbi/types/api/workspace_update_params.py +14 -0
  136. arbi/types/chunk.py +12 -0
  137. arbi/types/chunk_metadata.py +31 -0
  138. arbi/types/chunk_metadata_param.py +32 -0
  139. arbi/types/chunk_param.py +15 -0
  140. arbi-0.1.0.dist-info/METADATA +410 -0
  141. arbi-0.1.0.dist-info/RECORD +143 -0
  142. arbi-0.1.0.dist-info/WHEEL +4 -0
  143. arbi-0.1.0.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,873 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import List, Union, Mapping, Optional, cast
6
+ from datetime import date
7
+ from typing_extensions import Literal
8
+
9
+ import httpx
10
+
11
+ from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven, FileTypes
12
+ from ...._utils import extract_files, maybe_transform, deepcopy_minimal, async_maybe_transform
13
+ from ...._compat import cached_property
14
+ from .annotation import (
15
+ AnnotationResource,
16
+ AsyncAnnotationResource,
17
+ AnnotationResourceWithRawResponse,
18
+ AsyncAnnotationResourceWithRawResponse,
19
+ AnnotationResourceWithStreamingResponse,
20
+ AsyncAnnotationResourceWithStreamingResponse,
21
+ )
22
+ from ...._resource import SyncAPIResource, AsyncAPIResource
23
+ from ...._response import (
24
+ to_raw_response_wrapper,
25
+ to_streamed_response_wrapper,
26
+ async_to_raw_response_wrapper,
27
+ async_to_streamed_response_wrapper,
28
+ )
29
+ from ....types.api import document_view_params, document_update_params, document_upload_params
30
+ from ...._base_client import make_request_options
31
+ from ....types.api.doc_response import DocResponse
32
+ from ....types.api.document_delete_response import DocumentDeleteResponse
33
+ from ....types.api.document_update_response import DocumentUpdateResponse
34
+ from ....types.api.document_get_tags_response import DocumentGetTagsResponse
35
+ from ....types.api.document_get_parsed_response import DocumentGetParsedResponse
36
+
37
+ __all__ = ["DocumentResource", "AsyncDocumentResource"]
38
+
39
+
40
+ class DocumentResource(SyncAPIResource):
41
+ @cached_property
42
+ def annotation(self) -> AnnotationResource:
43
+ return AnnotationResource(self._client)
44
+
45
+ @cached_property
46
+ def with_raw_response(self) -> DocumentResourceWithRawResponse:
47
+ """
48
+ This property can be used as a prefix for any HTTP method call to return
49
+ the raw response object instead of the parsed content.
50
+
51
+ For more information, see https://www.github.com/arbitrationcity/arbi-python#accessing-raw-response-data-eg-headers
52
+ """
53
+ return DocumentResourceWithRawResponse(self)
54
+
55
+ @cached_property
56
+ def with_streaming_response(self) -> DocumentResourceWithStreamingResponse:
57
+ """
58
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
59
+
60
+ For more information, see https://www.github.com/arbitrationcity/arbi-python#with_streaming_response
61
+ """
62
+ return DocumentResourceWithStreamingResponse(self)
63
+
64
+ def update(
65
+ self,
66
+ document_ext_id: str,
67
+ *,
68
+ doc_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
69
+ shared: Optional[bool] | NotGiven = NOT_GIVEN,
70
+ title: Optional[str] | NotGiven = NOT_GIVEN,
71
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
72
+ # The extra values given here take precedence over values defined on the client or passed to this method.
73
+ extra_headers: Headers | None = None,
74
+ extra_query: Query | None = None,
75
+ extra_body: Body | None = None,
76
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
77
+ ) -> DocumentUpdateResponse:
78
+ """Update document metadata such as title, date, or sharing status.
79
+
80
+ Changes are
81
+ encrypted before storage in the database.
82
+
83
+ Args:
84
+ extra_headers: Send extra headers
85
+
86
+ extra_query: Add additional query parameters to the request
87
+
88
+ extra_body: Add additional JSON properties to the request
89
+
90
+ timeout: Override the client-level default timeout for this request, in seconds
91
+ """
92
+ if not document_ext_id:
93
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
94
+ return self._patch(
95
+ f"/api/document/{document_ext_id}",
96
+ body=maybe_transform(
97
+ {
98
+ "doc_date": doc_date,
99
+ "shared": shared,
100
+ "title": title,
101
+ },
102
+ document_update_params.DocumentUpdateParams,
103
+ ),
104
+ options=make_request_options(
105
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
106
+ ),
107
+ cast_to=DocumentUpdateResponse,
108
+ )
109
+
110
+ def delete(
111
+ self,
112
+ document_ext_id: str,
113
+ *,
114
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
115
+ # The extra values given here take precedence over values defined on the client or passed to this method.
116
+ extra_headers: Headers | None = None,
117
+ extra_query: Query | None = None,
118
+ extra_body: Body | None = None,
119
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
120
+ ) -> DocumentDeleteResponse:
121
+ """Delete a document by its external ID.
122
+
123
+ Removes the document from both database
124
+ and vector store.
125
+
126
+ Args:
127
+ extra_headers: Send extra headers
128
+
129
+ extra_query: Add additional query parameters to the request
130
+
131
+ extra_body: Add additional JSON properties to the request
132
+
133
+ timeout: Override the client-level default timeout for this request, in seconds
134
+ """
135
+ if not document_ext_id:
136
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
137
+ return self._delete(
138
+ f"/api/document/{document_ext_id}",
139
+ options=make_request_options(
140
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
141
+ ),
142
+ cast_to=DocumentDeleteResponse,
143
+ )
144
+
145
+ def download(
146
+ self,
147
+ document_ext_id: str,
148
+ *,
149
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
150
+ # The extra values given here take precedence over values defined on the client or passed to this method.
151
+ extra_headers: Headers | None = None,
152
+ extra_query: Query | None = None,
153
+ extra_body: Body | None = None,
154
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
155
+ ) -> object:
156
+ """Download a document by its external ID.
157
+
158
+ Retrieves and decrypts the document for
159
+ downloading as an attachment.
160
+
161
+ Args:
162
+ extra_headers: Send extra headers
163
+
164
+ extra_query: Add additional query parameters to the request
165
+
166
+ extra_body: Add additional JSON properties to the request
167
+
168
+ timeout: Override the client-level default timeout for this request, in seconds
169
+ """
170
+ if not document_ext_id:
171
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
172
+ return self._get(
173
+ f"/api/document/{document_ext_id}/download",
174
+ options=make_request_options(
175
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
176
+ ),
177
+ cast_to=object,
178
+ )
179
+
180
+ def get(
181
+ self,
182
+ document_ext_id: str,
183
+ *,
184
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
185
+ # The extra values given here take precedence over values defined on the client or passed to this method.
186
+ extra_headers: Headers | None = None,
187
+ extra_query: Query | None = None,
188
+ extra_body: Body | None = None,
189
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
190
+ ) -> DocResponse:
191
+ """Retrieve document metadata by its external ID.
192
+
193
+ Returns decrypted document
194
+ information with proper access controls.
195
+
196
+ Args:
197
+ extra_headers: Send extra headers
198
+
199
+ extra_query: Add additional query parameters to the request
200
+
201
+ extra_body: Add additional JSON properties to the request
202
+
203
+ timeout: Override the client-level default timeout for this request, in seconds
204
+ """
205
+ if not document_ext_id:
206
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
207
+ return self._get(
208
+ f"/api/document/{document_ext_id}",
209
+ options=make_request_options(
210
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
211
+ ),
212
+ cast_to=DocResponse,
213
+ )
214
+
215
+ def get_parsed(
216
+ self,
217
+ stage: Literal["marker", "subchunk", "final"],
218
+ *,
219
+ document_ext_id: str,
220
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
221
+ # The extra values given here take precedence over values defined on the client or passed to this method.
222
+ extra_headers: Headers | None = None,
223
+ extra_query: Query | None = None,
224
+ extra_body: Body | None = None,
225
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
226
+ ) -> DocumentGetParsedResponse:
227
+ """Retrieve the full parsed document to be handled by the frontend.
228
+
229
+ Only requires
230
+ document_ext_id, workspace is determined through RLS.
231
+
232
+ Args:
233
+ extra_headers: Send extra headers
234
+
235
+ extra_query: Add additional query parameters to the request
236
+
237
+ extra_body: Add additional JSON properties to the request
238
+
239
+ timeout: Override the client-level default timeout for this request, in seconds
240
+ """
241
+ if not document_ext_id:
242
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
243
+ if not stage:
244
+ raise ValueError(f"Expected a non-empty value for `stage` but received {stage!r}")
245
+ return self._get(
246
+ f"/api/document/{document_ext_id}/parsed-{stage}",
247
+ options=make_request_options(
248
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
249
+ ),
250
+ cast_to=DocumentGetParsedResponse,
251
+ )
252
+
253
+ def get_tags(
254
+ self,
255
+ doc_ext_id: str,
256
+ *,
257
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
258
+ # The extra values given here take precedence over values defined on the client or passed to this method.
259
+ extra_headers: Headers | None = None,
260
+ extra_query: Query | None = None,
261
+ extra_body: Body | None = None,
262
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
263
+ ) -> DocumentGetTagsResponse:
264
+ """
265
+ Get all tags applied to a specific document along with doctag metadata.
266
+
267
+ Args:
268
+ extra_headers: Send extra headers
269
+
270
+ extra_query: Add additional query parameters to the request
271
+
272
+ extra_body: Add additional JSON properties to the request
273
+
274
+ timeout: Override the client-level default timeout for this request, in seconds
275
+ """
276
+ if not doc_ext_id:
277
+ raise ValueError(f"Expected a non-empty value for `doc_ext_id` but received {doc_ext_id!r}")
278
+ return self._get(
279
+ f"/api/document/{doc_ext_id}/tags",
280
+ options=make_request_options(
281
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
282
+ ),
283
+ cast_to=DocumentGetTagsResponse,
284
+ )
285
+
286
+ def upload(
287
+ self,
288
+ *,
289
+ workspace_ext_id: str,
290
+ files: List[FileTypes],
291
+ config_ext_id: Optional[str] | NotGiven = NOT_GIVEN,
292
+ shared: bool | NotGiven = NOT_GIVEN,
293
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
294
+ # The extra values given here take precedence over values defined on the client or passed to this method.
295
+ extra_headers: Headers | None = None,
296
+ extra_query: Query | None = None,
297
+ extra_body: Body | None = None,
298
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
299
+ ) -> object:
300
+ """Upload multiple documents to a workspace with encryption.
301
+
302
+ Documents are queued
303
+ for processing, parsed, and indexed for vector search.
304
+
305
+ Args:
306
+ files: Multiple files to upload
307
+
308
+ config_ext_id: Configuration to use for processing
309
+
310
+ shared: Whether the document should be shared with workspace members
311
+
312
+ extra_headers: Send extra headers
313
+
314
+ extra_query: Add additional query parameters to the request
315
+
316
+ extra_body: Add additional JSON properties to the request
317
+
318
+ timeout: Override the client-level default timeout for this request, in seconds
319
+ """
320
+ body = deepcopy_minimal({"files": files})
321
+ extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
322
+ # It should be noted that the actual Content-Type header that will be
323
+ # sent to the server will contain a `boundary` parameter, e.g.
324
+ # multipart/form-data; boundary=---abc--
325
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
326
+ return self._post(
327
+ "/api/document/upload",
328
+ body=maybe_transform(body, document_upload_params.DocumentUploadParams),
329
+ files=extracted_files,
330
+ options=make_request_options(
331
+ extra_headers=extra_headers,
332
+ extra_query=extra_query,
333
+ extra_body=extra_body,
334
+ timeout=timeout,
335
+ query=maybe_transform(
336
+ {
337
+ "workspace_ext_id": workspace_ext_id,
338
+ "config_ext_id": config_ext_id,
339
+ "shared": shared,
340
+ },
341
+ document_upload_params.DocumentUploadParams,
342
+ ),
343
+ ),
344
+ cast_to=object,
345
+ )
346
+
347
+ def view(
348
+ self,
349
+ document_ext_id: str,
350
+ *,
351
+ page: Optional[int] | NotGiven = NOT_GIVEN,
352
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
353
+ # The extra values given here take precedence over values defined on the client or passed to this method.
354
+ extra_headers: Headers | None = None,
355
+ extra_query: Query | None = None,
356
+ extra_body: Body | None = None,
357
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
358
+ ) -> object:
359
+ """View a document inline in the browser.
360
+
361
+ Retrieves and decrypts the document for
362
+ inline viewing with optional page specification.
363
+
364
+ Args:
365
+ page: Optional page to open on load
366
+
367
+ extra_headers: Send extra headers
368
+
369
+ extra_query: Add additional query parameters to the request
370
+
371
+ extra_body: Add additional JSON properties to the request
372
+
373
+ timeout: Override the client-level default timeout for this request, in seconds
374
+ """
375
+ if not document_ext_id:
376
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
377
+ return self._get(
378
+ f"/api/document/{document_ext_id}/view",
379
+ options=make_request_options(
380
+ extra_headers=extra_headers,
381
+ extra_query=extra_query,
382
+ extra_body=extra_body,
383
+ timeout=timeout,
384
+ query=maybe_transform({"page": page}, document_view_params.DocumentViewParams),
385
+ ),
386
+ cast_to=object,
387
+ )
388
+
389
+
390
+ class AsyncDocumentResource(AsyncAPIResource):
391
+ @cached_property
392
+ def annotation(self) -> AsyncAnnotationResource:
393
+ return AsyncAnnotationResource(self._client)
394
+
395
+ @cached_property
396
+ def with_raw_response(self) -> AsyncDocumentResourceWithRawResponse:
397
+ """
398
+ This property can be used as a prefix for any HTTP method call to return
399
+ the raw response object instead of the parsed content.
400
+
401
+ For more information, see https://www.github.com/arbitrationcity/arbi-python#accessing-raw-response-data-eg-headers
402
+ """
403
+ return AsyncDocumentResourceWithRawResponse(self)
404
+
405
+ @cached_property
406
+ def with_streaming_response(self) -> AsyncDocumentResourceWithStreamingResponse:
407
+ """
408
+ An alternative to `.with_raw_response` that doesn't eagerly read the response body.
409
+
410
+ For more information, see https://www.github.com/arbitrationcity/arbi-python#with_streaming_response
411
+ """
412
+ return AsyncDocumentResourceWithStreamingResponse(self)
413
+
414
+ async def update(
415
+ self,
416
+ document_ext_id: str,
417
+ *,
418
+ doc_date: Union[str, date, None] | NotGiven = NOT_GIVEN,
419
+ shared: Optional[bool] | NotGiven = NOT_GIVEN,
420
+ title: Optional[str] | NotGiven = NOT_GIVEN,
421
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
422
+ # The extra values given here take precedence over values defined on the client or passed to this method.
423
+ extra_headers: Headers | None = None,
424
+ extra_query: Query | None = None,
425
+ extra_body: Body | None = None,
426
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
427
+ ) -> DocumentUpdateResponse:
428
+ """Update document metadata such as title, date, or sharing status.
429
+
430
+ Changes are
431
+ encrypted before storage in the database.
432
+
433
+ Args:
434
+ extra_headers: Send extra headers
435
+
436
+ extra_query: Add additional query parameters to the request
437
+
438
+ extra_body: Add additional JSON properties to the request
439
+
440
+ timeout: Override the client-level default timeout for this request, in seconds
441
+ """
442
+ if not document_ext_id:
443
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
444
+ return await self._patch(
445
+ f"/api/document/{document_ext_id}",
446
+ body=await async_maybe_transform(
447
+ {
448
+ "doc_date": doc_date,
449
+ "shared": shared,
450
+ "title": title,
451
+ },
452
+ document_update_params.DocumentUpdateParams,
453
+ ),
454
+ options=make_request_options(
455
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
456
+ ),
457
+ cast_to=DocumentUpdateResponse,
458
+ )
459
+
460
+ async def delete(
461
+ self,
462
+ document_ext_id: str,
463
+ *,
464
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
465
+ # The extra values given here take precedence over values defined on the client or passed to this method.
466
+ extra_headers: Headers | None = None,
467
+ extra_query: Query | None = None,
468
+ extra_body: Body | None = None,
469
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
470
+ ) -> DocumentDeleteResponse:
471
+ """Delete a document by its external ID.
472
+
473
+ Removes the document from both database
474
+ and vector store.
475
+
476
+ Args:
477
+ extra_headers: Send extra headers
478
+
479
+ extra_query: Add additional query parameters to the request
480
+
481
+ extra_body: Add additional JSON properties to the request
482
+
483
+ timeout: Override the client-level default timeout for this request, in seconds
484
+ """
485
+ if not document_ext_id:
486
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
487
+ return await self._delete(
488
+ f"/api/document/{document_ext_id}",
489
+ options=make_request_options(
490
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
491
+ ),
492
+ cast_to=DocumentDeleteResponse,
493
+ )
494
+
495
+ async def download(
496
+ self,
497
+ document_ext_id: str,
498
+ *,
499
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
500
+ # The extra values given here take precedence over values defined on the client or passed to this method.
501
+ extra_headers: Headers | None = None,
502
+ extra_query: Query | None = None,
503
+ extra_body: Body | None = None,
504
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
505
+ ) -> object:
506
+ """Download a document by its external ID.
507
+
508
+ Retrieves and decrypts the document for
509
+ downloading as an attachment.
510
+
511
+ Args:
512
+ extra_headers: Send extra headers
513
+
514
+ extra_query: Add additional query parameters to the request
515
+
516
+ extra_body: Add additional JSON properties to the request
517
+
518
+ timeout: Override the client-level default timeout for this request, in seconds
519
+ """
520
+ if not document_ext_id:
521
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
522
+ return await self._get(
523
+ f"/api/document/{document_ext_id}/download",
524
+ options=make_request_options(
525
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
526
+ ),
527
+ cast_to=object,
528
+ )
529
+
530
+ async def get(
531
+ self,
532
+ document_ext_id: str,
533
+ *,
534
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
535
+ # The extra values given here take precedence over values defined on the client or passed to this method.
536
+ extra_headers: Headers | None = None,
537
+ extra_query: Query | None = None,
538
+ extra_body: Body | None = None,
539
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
540
+ ) -> DocResponse:
541
+ """Retrieve document metadata by its external ID.
542
+
543
+ Returns decrypted document
544
+ information with proper access controls.
545
+
546
+ Args:
547
+ extra_headers: Send extra headers
548
+
549
+ extra_query: Add additional query parameters to the request
550
+
551
+ extra_body: Add additional JSON properties to the request
552
+
553
+ timeout: Override the client-level default timeout for this request, in seconds
554
+ """
555
+ if not document_ext_id:
556
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
557
+ return await self._get(
558
+ f"/api/document/{document_ext_id}",
559
+ options=make_request_options(
560
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
561
+ ),
562
+ cast_to=DocResponse,
563
+ )
564
+
565
+ async def get_parsed(
566
+ self,
567
+ stage: Literal["marker", "subchunk", "final"],
568
+ *,
569
+ document_ext_id: str,
570
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
571
+ # The extra values given here take precedence over values defined on the client or passed to this method.
572
+ extra_headers: Headers | None = None,
573
+ extra_query: Query | None = None,
574
+ extra_body: Body | None = None,
575
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
576
+ ) -> DocumentGetParsedResponse:
577
+ """Retrieve the full parsed document to be handled by the frontend.
578
+
579
+ Only requires
580
+ document_ext_id, workspace is determined through RLS.
581
+
582
+ Args:
583
+ extra_headers: Send extra headers
584
+
585
+ extra_query: Add additional query parameters to the request
586
+
587
+ extra_body: Add additional JSON properties to the request
588
+
589
+ timeout: Override the client-level default timeout for this request, in seconds
590
+ """
591
+ if not document_ext_id:
592
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
593
+ if not stage:
594
+ raise ValueError(f"Expected a non-empty value for `stage` but received {stage!r}")
595
+ return await self._get(
596
+ f"/api/document/{document_ext_id}/parsed-{stage}",
597
+ options=make_request_options(
598
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
599
+ ),
600
+ cast_to=DocumentGetParsedResponse,
601
+ )
602
+
603
+ async def get_tags(
604
+ self,
605
+ doc_ext_id: str,
606
+ *,
607
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
608
+ # The extra values given here take precedence over values defined on the client or passed to this method.
609
+ extra_headers: Headers | None = None,
610
+ extra_query: Query | None = None,
611
+ extra_body: Body | None = None,
612
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
613
+ ) -> DocumentGetTagsResponse:
614
+ """
615
+ Get all tags applied to a specific document along with doctag metadata.
616
+
617
+ Args:
618
+ extra_headers: Send extra headers
619
+
620
+ extra_query: Add additional query parameters to the request
621
+
622
+ extra_body: Add additional JSON properties to the request
623
+
624
+ timeout: Override the client-level default timeout for this request, in seconds
625
+ """
626
+ if not doc_ext_id:
627
+ raise ValueError(f"Expected a non-empty value for `doc_ext_id` but received {doc_ext_id!r}")
628
+ return await self._get(
629
+ f"/api/document/{doc_ext_id}/tags",
630
+ options=make_request_options(
631
+ extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
632
+ ),
633
+ cast_to=DocumentGetTagsResponse,
634
+ )
635
+
636
+ async def upload(
637
+ self,
638
+ *,
639
+ workspace_ext_id: str,
640
+ files: List[FileTypes],
641
+ config_ext_id: Optional[str] | NotGiven = NOT_GIVEN,
642
+ shared: bool | NotGiven = NOT_GIVEN,
643
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
644
+ # The extra values given here take precedence over values defined on the client or passed to this method.
645
+ extra_headers: Headers | None = None,
646
+ extra_query: Query | None = None,
647
+ extra_body: Body | None = None,
648
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
649
+ ) -> object:
650
+ """Upload multiple documents to a workspace with encryption.
651
+
652
+ Documents are queued
653
+ for processing, parsed, and indexed for vector search.
654
+
655
+ Args:
656
+ files: Multiple files to upload
657
+
658
+ config_ext_id: Configuration to use for processing
659
+
660
+ shared: Whether the document should be shared with workspace members
661
+
662
+ extra_headers: Send extra headers
663
+
664
+ extra_query: Add additional query parameters to the request
665
+
666
+ extra_body: Add additional JSON properties to the request
667
+
668
+ timeout: Override the client-level default timeout for this request, in seconds
669
+ """
670
+ body = deepcopy_minimal({"files": files})
671
+ extracted_files = extract_files(cast(Mapping[str, object], body), paths=[["files", "<array>"]])
672
+ # It should be noted that the actual Content-Type header that will be
673
+ # sent to the server will contain a `boundary` parameter, e.g.
674
+ # multipart/form-data; boundary=---abc--
675
+ extra_headers = {"Content-Type": "multipart/form-data", **(extra_headers or {})}
676
+ return await self._post(
677
+ "/api/document/upload",
678
+ body=await async_maybe_transform(body, document_upload_params.DocumentUploadParams),
679
+ files=extracted_files,
680
+ options=make_request_options(
681
+ extra_headers=extra_headers,
682
+ extra_query=extra_query,
683
+ extra_body=extra_body,
684
+ timeout=timeout,
685
+ query=await async_maybe_transform(
686
+ {
687
+ "workspace_ext_id": workspace_ext_id,
688
+ "config_ext_id": config_ext_id,
689
+ "shared": shared,
690
+ },
691
+ document_upload_params.DocumentUploadParams,
692
+ ),
693
+ ),
694
+ cast_to=object,
695
+ )
696
+
697
+ async def view(
698
+ self,
699
+ document_ext_id: str,
700
+ *,
701
+ page: Optional[int] | NotGiven = NOT_GIVEN,
702
+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
703
+ # The extra values given here take precedence over values defined on the client or passed to this method.
704
+ extra_headers: Headers | None = None,
705
+ extra_query: Query | None = None,
706
+ extra_body: Body | None = None,
707
+ timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
708
+ ) -> object:
709
+ """View a document inline in the browser.
710
+
711
+ Retrieves and decrypts the document for
712
+ inline viewing with optional page specification.
713
+
714
+ Args:
715
+ page: Optional page to open on load
716
+
717
+ extra_headers: Send extra headers
718
+
719
+ extra_query: Add additional query parameters to the request
720
+
721
+ extra_body: Add additional JSON properties to the request
722
+
723
+ timeout: Override the client-level default timeout for this request, in seconds
724
+ """
725
+ if not document_ext_id:
726
+ raise ValueError(f"Expected a non-empty value for `document_ext_id` but received {document_ext_id!r}")
727
+ return await self._get(
728
+ f"/api/document/{document_ext_id}/view",
729
+ options=make_request_options(
730
+ extra_headers=extra_headers,
731
+ extra_query=extra_query,
732
+ extra_body=extra_body,
733
+ timeout=timeout,
734
+ query=await async_maybe_transform({"page": page}, document_view_params.DocumentViewParams),
735
+ ),
736
+ cast_to=object,
737
+ )
738
+
739
+
740
+ class DocumentResourceWithRawResponse:
741
+ def __init__(self, document: DocumentResource) -> None:
742
+ self._document = document
743
+
744
+ self.update = to_raw_response_wrapper(
745
+ document.update,
746
+ )
747
+ self.delete = to_raw_response_wrapper(
748
+ document.delete,
749
+ )
750
+ self.download = to_raw_response_wrapper(
751
+ document.download,
752
+ )
753
+ self.get = to_raw_response_wrapper(
754
+ document.get,
755
+ )
756
+ self.get_parsed = to_raw_response_wrapper(
757
+ document.get_parsed,
758
+ )
759
+ self.get_tags = to_raw_response_wrapper(
760
+ document.get_tags,
761
+ )
762
+ self.upload = to_raw_response_wrapper(
763
+ document.upload,
764
+ )
765
+ self.view = to_raw_response_wrapper(
766
+ document.view,
767
+ )
768
+
769
+ @cached_property
770
+ def annotation(self) -> AnnotationResourceWithRawResponse:
771
+ return AnnotationResourceWithRawResponse(self._document.annotation)
772
+
773
+
774
+ class AsyncDocumentResourceWithRawResponse:
775
+ def __init__(self, document: AsyncDocumentResource) -> None:
776
+ self._document = document
777
+
778
+ self.update = async_to_raw_response_wrapper(
779
+ document.update,
780
+ )
781
+ self.delete = async_to_raw_response_wrapper(
782
+ document.delete,
783
+ )
784
+ self.download = async_to_raw_response_wrapper(
785
+ document.download,
786
+ )
787
+ self.get = async_to_raw_response_wrapper(
788
+ document.get,
789
+ )
790
+ self.get_parsed = async_to_raw_response_wrapper(
791
+ document.get_parsed,
792
+ )
793
+ self.get_tags = async_to_raw_response_wrapper(
794
+ document.get_tags,
795
+ )
796
+ self.upload = async_to_raw_response_wrapper(
797
+ document.upload,
798
+ )
799
+ self.view = async_to_raw_response_wrapper(
800
+ document.view,
801
+ )
802
+
803
+ @cached_property
804
+ def annotation(self) -> AsyncAnnotationResourceWithRawResponse:
805
+ return AsyncAnnotationResourceWithRawResponse(self._document.annotation)
806
+
807
+
808
+ class DocumentResourceWithStreamingResponse:
809
+ def __init__(self, document: DocumentResource) -> None:
810
+ self._document = document
811
+
812
+ self.update = to_streamed_response_wrapper(
813
+ document.update,
814
+ )
815
+ self.delete = to_streamed_response_wrapper(
816
+ document.delete,
817
+ )
818
+ self.download = to_streamed_response_wrapper(
819
+ document.download,
820
+ )
821
+ self.get = to_streamed_response_wrapper(
822
+ document.get,
823
+ )
824
+ self.get_parsed = to_streamed_response_wrapper(
825
+ document.get_parsed,
826
+ )
827
+ self.get_tags = to_streamed_response_wrapper(
828
+ document.get_tags,
829
+ )
830
+ self.upload = to_streamed_response_wrapper(
831
+ document.upload,
832
+ )
833
+ self.view = to_streamed_response_wrapper(
834
+ document.view,
835
+ )
836
+
837
+ @cached_property
838
+ def annotation(self) -> AnnotationResourceWithStreamingResponse:
839
+ return AnnotationResourceWithStreamingResponse(self._document.annotation)
840
+
841
+
842
+ class AsyncDocumentResourceWithStreamingResponse:
843
+ def __init__(self, document: AsyncDocumentResource) -> None:
844
+ self._document = document
845
+
846
+ self.update = async_to_streamed_response_wrapper(
847
+ document.update,
848
+ )
849
+ self.delete = async_to_streamed_response_wrapper(
850
+ document.delete,
851
+ )
852
+ self.download = async_to_streamed_response_wrapper(
853
+ document.download,
854
+ )
855
+ self.get = async_to_streamed_response_wrapper(
856
+ document.get,
857
+ )
858
+ self.get_parsed = async_to_streamed_response_wrapper(
859
+ document.get_parsed,
860
+ )
861
+ self.get_tags = async_to_streamed_response_wrapper(
862
+ document.get_tags,
863
+ )
864
+ self.upload = async_to_streamed_response_wrapper(
865
+ document.upload,
866
+ )
867
+ self.view = async_to_streamed_response_wrapper(
868
+ document.view,
869
+ )
870
+
871
+ @cached_property
872
+ def annotation(self) -> AsyncAnnotationResourceWithStreamingResponse:
873
+ return AsyncAnnotationResourceWithStreamingResponse(self._document.annotation)