retab 0.0.36__py3-none-any.whl → 0.0.38__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.
Files changed (123) hide show
  1. retab/__init__.py +4 -0
  2. {uiform → retab}/_resource.py +5 -5
  3. {uiform → retab}/_utils/ai_models.py +2 -2
  4. {uiform → retab}/_utils/benchmarking.py +15 -16
  5. {uiform → retab}/_utils/chat.py +29 -34
  6. {uiform → retab}/_utils/display.py +0 -3
  7. {uiform → retab}/_utils/json_schema.py +9 -14
  8. {uiform → retab}/_utils/mime.py +11 -14
  9. {uiform → retab}/_utils/responses.py +16 -10
  10. {uiform → retab}/_utils/stream_context_managers.py +1 -1
  11. {uiform → retab}/_utils/usage/usage.py +31 -31
  12. {uiform → retab}/client.py +54 -53
  13. {uiform → retab}/resources/consensus/client.py +19 -38
  14. {uiform → retab}/resources/consensus/completions.py +36 -59
  15. {uiform → retab}/resources/consensus/completions_stream.py +35 -47
  16. {uiform → retab}/resources/consensus/responses.py +37 -86
  17. {uiform → retab}/resources/consensus/responses_stream.py +41 -89
  18. retab/resources/documents/client.py +455 -0
  19. {uiform → retab}/resources/documents/extractions.py +192 -101
  20. {uiform → retab}/resources/evals.py +56 -43
  21. retab/resources/evaluations/__init__.py +3 -0
  22. retab/resources/evaluations/client.py +301 -0
  23. retab/resources/evaluations/documents.py +233 -0
  24. retab/resources/evaluations/iterations.py +452 -0
  25. {uiform → retab}/resources/files.py +2 -2
  26. {uiform → retab}/resources/jsonlUtils.py +225 -221
  27. retab/resources/models.py +73 -0
  28. retab/resources/processors/automations/client.py +244 -0
  29. {uiform → retab}/resources/processors/automations/endpoints.py +79 -120
  30. retab/resources/processors/automations/links.py +294 -0
  31. {uiform → retab}/resources/processors/automations/logs.py +30 -19
  32. retab/resources/processors/automations/mailboxes.py +397 -0
  33. retab/resources/processors/automations/outlook.py +337 -0
  34. {uiform → retab}/resources/processors/automations/tests.py +22 -25
  35. {uiform → retab}/resources/processors/client.py +181 -166
  36. {uiform → retab}/resources/schemas.py +78 -66
  37. {uiform → retab}/resources/secrets/external_api_keys.py +1 -5
  38. retab/resources/secrets/webhook.py +64 -0
  39. {uiform → retab}/resources/usage.py +41 -4
  40. {uiform → retab}/types/ai_models.py +17 -17
  41. {uiform → retab}/types/automations/cron.py +19 -12
  42. {uiform → retab}/types/automations/endpoints.py +7 -4
  43. {uiform → retab}/types/automations/links.py +7 -3
  44. {uiform → retab}/types/automations/mailboxes.py +10 -10
  45. {uiform → retab}/types/automations/outlook.py +15 -11
  46. {uiform → retab}/types/automations/webhooks.py +1 -1
  47. retab/types/browser_canvas.py +3 -0
  48. retab/types/chat.py +8 -0
  49. {uiform → retab}/types/completions.py +12 -15
  50. retab/types/consensus.py +19 -0
  51. {uiform → retab}/types/db/annotations.py +3 -3
  52. {uiform → retab}/types/db/files.py +8 -6
  53. {uiform → retab}/types/documents/create_messages.py +20 -22
  54. {uiform → retab}/types/documents/extractions.py +71 -26
  55. {uiform → retab}/types/evals.py +5 -5
  56. retab/types/evaluations/__init__.py +31 -0
  57. retab/types/evaluations/documents.py +30 -0
  58. retab/types/evaluations/iterations.py +112 -0
  59. retab/types/evaluations/model.py +73 -0
  60. retab/types/events.py +79 -0
  61. {uiform → retab}/types/extractions.py +36 -13
  62. retab/types/inference_settings.py +15 -0
  63. retab/types/jobs/base.py +54 -0
  64. retab/types/jobs/batch_annotation.py +12 -0
  65. {uiform → retab}/types/jobs/evaluation.py +1 -2
  66. {uiform → retab}/types/logs.py +37 -34
  67. retab/types/metrics.py +32 -0
  68. {uiform → retab}/types/mime.py +22 -20
  69. {uiform → retab}/types/modalities.py +10 -10
  70. retab/types/predictions.py +19 -0
  71. {uiform → retab}/types/schemas/enhance.py +4 -2
  72. {uiform → retab}/types/schemas/evaluate.py +7 -4
  73. {uiform → retab}/types/schemas/generate.py +6 -3
  74. {uiform → retab}/types/schemas/layout.py +1 -1
  75. {uiform → retab}/types/schemas/object.py +16 -17
  76. {uiform → retab}/types/schemas/templates.py +1 -3
  77. {uiform → retab}/types/secrets/external_api_keys.py +0 -1
  78. {uiform → retab}/types/standards.py +18 -1
  79. {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/METADATA +78 -77
  80. retab-0.0.38.dist-info/RECORD +107 -0
  81. retab-0.0.38.dist-info/top_level.txt +1 -0
  82. retab-0.0.36.dist-info/RECORD +0 -96
  83. retab-0.0.36.dist-info/top_level.txt +0 -1
  84. uiform/__init__.py +0 -4
  85. uiform/_utils/benchmarking copy.py +0 -588
  86. uiform/resources/documents/client.py +0 -255
  87. uiform/resources/models.py +0 -45
  88. uiform/resources/processors/automations/client.py +0 -78
  89. uiform/resources/processors/automations/links.py +0 -356
  90. uiform/resources/processors/automations/mailboxes.py +0 -435
  91. uiform/resources/processors/automations/outlook.py +0 -444
  92. uiform/resources/secrets/webhook.py +0 -62
  93. uiform/types/chat.py +0 -8
  94. uiform/types/consensus.py +0 -10
  95. uiform/types/events.py +0 -76
  96. uiform/types/jobs/base.py +0 -150
  97. uiform/types/jobs/batch_annotation.py +0 -22
  98. {uiform → retab}/_utils/__init__.py +0 -0
  99. {uiform → retab}/_utils/usage/__init__.py +0 -0
  100. {uiform → retab}/py.typed +0 -0
  101. {uiform → retab}/resources/__init__.py +0 -0
  102. {uiform → retab}/resources/consensus/__init__.py +0 -0
  103. {uiform → retab}/resources/documents/__init__.py +0 -0
  104. {uiform → retab}/resources/finetuning.py +0 -0
  105. {uiform → retab}/resources/openai_example.py +0 -0
  106. {uiform → retab}/resources/processors/__init__.py +0 -0
  107. {uiform → retab}/resources/processors/automations/__init__.py +0 -0
  108. {uiform → retab}/resources/prompt_optimization.py +0 -0
  109. {uiform → retab}/resources/secrets/__init__.py +0 -0
  110. {uiform → retab}/resources/secrets/client.py +0 -0
  111. {uiform → retab}/types/__init__.py +0 -0
  112. {uiform → retab}/types/automations/__init__.py +0 -0
  113. {uiform → retab}/types/db/__init__.py +0 -0
  114. {uiform → retab}/types/documents/__init__.py +0 -0
  115. {uiform → retab}/types/documents/correct_orientation.py +0 -0
  116. {uiform → retab}/types/jobs/__init__.py +0 -0
  117. {uiform → retab}/types/jobs/finetune.py +0 -0
  118. {uiform → retab}/types/jobs/prompt_optimization.py +0 -0
  119. {uiform → retab}/types/jobs/webcrawl.py +0 -0
  120. {uiform → retab}/types/pagination.py +0 -0
  121. {uiform → retab}/types/schemas/__init__.py +0 -0
  122. {uiform → retab}/types/secrets/__init__.py +0 -0
  123. {retab-0.0.36.dist-info → retab-0.0.38.dist-info}/WHEEL +0 -0
@@ -1,32 +1,23 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Any, AsyncGenerator, Generator
4
-
5
1
  from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
6
- from openai.types.chat.parsed_chat_completion import ParsedChatCompletionMessage
7
2
  from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
8
- #from openai.lib._parsing import ResponseFormatT
9
- from pydantic import BaseModel as ResponseFormatT
10
3
 
4
+ # from openai.lib._parsing import ResponseFormatT
5
+ from pydantic import BaseModel as ResponseFormatT
11
6
 
12
7
  from ..._resource import AsyncAPIResource, SyncAPIResource
13
8
  from ..._utils.ai_models import assert_valid_model_extraction
14
- from ..._utils.json_schema import load_json_schema, unflatten_dict
15
- from ..._utils.stream_context_managers import as_async_context_manager, as_context_manager
16
- from ...types.chat import ChatCompletionUiformMessage
9
+ from ...types.chat import ChatCompletionRetabMessage
17
10
  from ...types.completions import UiChatCompletionsRequest
18
- from ...types.documents.extractions import UiParsedChatCompletion, UiParsedChatCompletionChunk, UiParsedChoice
19
- from ...types.standards import PreparedRequest
11
+ from ...types.documents.extractions import UiParsedChatCompletion
20
12
  from ...types.schemas.object import Schema
21
-
13
+ from ...types.standards import PreparedRequest
22
14
 
23
15
 
24
16
  class BaseCompletionsMixin:
25
-
26
17
  def prepare_parse(
27
18
  self,
28
19
  response_format: type[ResponseFormatT],
29
- messages: list[ChatCompletionUiformMessage],
20
+ messages: list[ChatCompletionRetabMessage],
30
21
  model: str,
31
22
  temperature: float,
32
23
  reasoning_effort: ChatCompletionReasoningEffort,
@@ -40,9 +31,10 @@ class BaseCompletionsMixin:
40
31
 
41
32
  schema_obj = Schema(json_schema=json_schema)
42
33
 
43
- data = {
44
- "messages": messages,
45
- "response_format": {
34
+ request = UiChatCompletionsRequest(
35
+ model=model,
36
+ messages=messages,
37
+ response_format={
46
38
  "type": "json_schema",
47
39
  "json_schema": {
48
40
  "name": schema_obj.id,
@@ -50,23 +42,17 @@ class BaseCompletionsMixin:
50
42
  "strict": True,
51
43
  },
52
44
  },
53
- "model": model,
54
- "temperature": temperature,
55
- "stream": stream,
56
- "reasoning_effort": reasoning_effort,
57
- "n_consensus": n_consensus,
58
- }
59
-
60
- # Validate DocumentAPIRequest data (raises exception if invalid)
61
- ui_chat_completions_request = UiChatCompletionsRequest.model_validate(data)
62
-
63
- return PreparedRequest(method="POST", url="/v1/completions", data=ui_chat_completions_request.model_dump(), idempotency_key=idempotency_key)
64
-
45
+ temperature=temperature,
46
+ stream=stream,
47
+ reasoning_effort=reasoning_effort,
48
+ n_consensus=n_consensus,
49
+ )
50
+ return PreparedRequest(method="POST", url="/v1/completions", data=request.model_dump(), idempotency_key=idempotency_key)
65
51
 
66
52
  def prepare_create(
67
53
  self,
68
54
  response_format: ResponseFormatJSONSchema,
69
- messages: list[ChatCompletionUiformMessage],
55
+ messages: list[ChatCompletionRetabMessage],
70
56
  model: str,
71
57
  temperature: float,
72
58
  reasoning_effort: ChatCompletionReasoningEffort,
@@ -74,16 +60,16 @@ class BaseCompletionsMixin:
74
60
  n_consensus: int,
75
61
  idempotency_key: str | None = None,
76
62
  ) -> PreparedRequest:
77
-
78
63
  json_schema = response_format["json_schema"].get("schema")
79
64
 
80
65
  assert isinstance(json_schema, dict), f"json_schema must be a dictionary, got {type(json_schema)}"
81
66
 
82
67
  schema_obj = Schema(json_schema=json_schema)
83
68
 
84
- data = {
85
- "messages": messages,
86
- "response_format": {
69
+ request = UiChatCompletionsRequest(
70
+ model=model,
71
+ messages=messages,
72
+ response_format={
87
73
  "type": "json_schema",
88
74
  "json_schema": {
89
75
  "name": schema_obj.id,
@@ -91,17 +77,12 @@ class BaseCompletionsMixin:
91
77
  "strict": True,
92
78
  },
93
79
  },
94
- "model": model,
95
- "temperature": temperature,
96
- "stream": stream,
97
- "reasoning_effort": reasoning_effort,
98
- "n_consensus": n_consensus,
99
- }
100
-
101
- # Validate DocumentAPIRequest data (raises exception if invalid)
102
- ui_chat_completions_request = UiChatCompletionsRequest.model_validate(data)
103
-
104
- return PreparedRequest(method="POST", url="/v1/completions", data=ui_chat_completions_request.model_dump(), idempotency_key=idempotency_key)
80
+ temperature=temperature,
81
+ stream=stream,
82
+ reasoning_effort=reasoning_effort,
83
+ n_consensus=n_consensus,
84
+ )
85
+ return PreparedRequest(method="POST", url="/v1/completions", data=request.model_dump(), idempotency_key=idempotency_key)
105
86
 
106
87
 
107
88
  class Completions(SyncAPIResource, BaseCompletionsMixin):
@@ -110,7 +91,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
110
91
  def create(
111
92
  self,
112
93
  response_format: ResponseFormatJSONSchema,
113
- messages: list[ChatCompletionUiformMessage],
94
+ messages: list[ChatCompletionRetabMessage],
114
95
  model: str = "gpt-4o-2024-08-06",
115
96
  temperature: float = 0,
116
97
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -119,7 +100,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
119
100
  stream: bool = False,
120
101
  ) -> UiParsedChatCompletion:
121
102
  """
122
- Create a completion using the UiForm API.
103
+ Create a completion using the Retab API.
123
104
  """
124
105
 
125
106
  request = self.prepare_create(
@@ -137,11 +118,10 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
137
118
 
138
119
  return UiParsedChatCompletion.model_validate(response)
139
120
 
140
-
141
121
  def parse(
142
122
  self,
143
123
  response_format: type[ResponseFormatT],
144
- messages: list[ChatCompletionUiformMessage],
124
+ messages: list[ChatCompletionRetabMessage],
145
125
  model: str = "gpt-4o-2024-08-06",
146
126
  temperature: float = 0,
147
127
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -149,7 +129,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
149
129
  idempotency_key: str | None = None,
150
130
  ) -> UiParsedChatCompletion:
151
131
  """
152
- Parse messages using the UiForm API to extract structured data according to the provided JSON schema.
132
+ Parse messages using the Retab API to extract structured data according to the provided JSON schema.
153
133
 
154
134
  Args:
155
135
  response_format: JSON schema defining the expected data structure
@@ -158,7 +138,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
158
138
  temperature: Model temperature setting (0-1)
159
139
  reasoning_effort: The effort level for the model to reason about the input data
160
140
  idempotency_key: Idempotency key for request
161
- store: Whether to store the data in the UiForm database
141
+ store: Whether to store the data in the Retab database
162
142
 
163
143
  Returns:
164
144
  UiParsedChatCompletion: Parsed response from the API
@@ -184,7 +164,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
184
164
  async def create(
185
165
  self,
186
166
  response_format: ResponseFormatJSONSchema,
187
- messages: list[ChatCompletionUiformMessage],
167
+ messages: list[ChatCompletionRetabMessage],
188
168
  model: str = "gpt-4o-2024-08-06",
189
169
  temperature: float = 0,
190
170
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -193,7 +173,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
193
173
  stream: bool = False,
194
174
  ) -> UiParsedChatCompletion:
195
175
  """
196
- Create a completion using the UiForm API.
176
+ Create a completion using the Retab API.
197
177
  """
198
178
 
199
179
  request = self.prepare_create(
@@ -210,13 +190,10 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
210
190
  response = await self._client._prepared_request(request)
211
191
  return UiParsedChatCompletion.model_validate(response)
212
192
 
213
-
214
-
215
-
216
193
  async def parse(
217
194
  self,
218
195
  response_format: type[ResponseFormatT],
219
- messages: list[ChatCompletionUiformMessage],
196
+ messages: list[ChatCompletionRetabMessage],
220
197
  model: str = "gpt-4o-2024-08-06",
221
198
  temperature: float = 0,
222
199
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -224,7 +201,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
224
201
  idempotency_key: str | None = None,
225
202
  ) -> UiParsedChatCompletion:
226
203
  """
227
- Parse messages using the UiForm API asynchronously.
204
+ Parse messages using the Retab API asynchronously.
228
205
 
229
206
  Args:
230
207
  json_schema: JSON schema defining the expected data structure
@@ -1,32 +1,29 @@
1
1
  import json
2
- from pathlib import Path
3
- from typing import Any, AsyncGenerator, Generator
2
+ from typing import AsyncGenerator, Generator
4
3
 
5
4
  from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
6
5
  from openai.types.chat.parsed_chat_completion import ParsedChatCompletionMessage
7
6
  from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
8
- #from openai.lib._parsing import ResponseFormatT
9
- from pydantic import BaseModel as ResponseFormatT
10
7
 
8
+ # from openai.lib._parsing import ResponseFormatT
9
+ from pydantic import BaseModel as ResponseFormatT
11
10
 
12
11
  from ..._resource import AsyncAPIResource, SyncAPIResource
13
12
  from ..._utils.ai_models import assert_valid_model_extraction
14
- from ..._utils.json_schema import load_json_schema, unflatten_dict
13
+ from ..._utils.json_schema import unflatten_dict
15
14
  from ..._utils.stream_context_managers import as_async_context_manager, as_context_manager
16
- from ...types.chat import ChatCompletionUiformMessage
15
+ from ...types.chat import ChatCompletionRetabMessage
17
16
  from ...types.completions import UiChatCompletionsRequest
18
17
  from ...types.documents.extractions import UiParsedChatCompletion, UiParsedChatCompletionChunk, UiParsedChoice
19
- from ...types.standards import PreparedRequest
20
18
  from ...types.schemas.object import Schema
21
-
19
+ from ...types.standards import PreparedRequest
22
20
 
23
21
 
24
22
  class BaseCompletionsMixin:
25
-
26
23
  def prepare_parse(
27
24
  self,
28
25
  response_format: type[ResponseFormatT],
29
- messages: list[ChatCompletionUiformMessage],
26
+ messages: list[ChatCompletionRetabMessage],
30
27
  model: str,
31
28
  temperature: float,
32
29
  reasoning_effort: ChatCompletionReasoningEffort,
@@ -37,12 +34,11 @@ class BaseCompletionsMixin:
37
34
  assert_valid_model_extraction(model)
38
35
 
39
36
  json_schema = response_format.model_json_schema()
40
-
41
37
  schema_obj = Schema(json_schema=json_schema)
42
38
 
43
- data = {
44
- "messages": messages,
45
- "response_format": {
39
+ request = UiChatCompletionsRequest(
40
+ messages=messages,
41
+ response_format={
46
42
  "type": "json_schema",
47
43
  "json_schema": {
48
44
  "name": schema_obj.id,
@@ -50,23 +46,19 @@ class BaseCompletionsMixin:
50
46
  "strict": True,
51
47
  },
52
48
  },
53
- "model": model,
54
- "temperature": temperature,
55
- "stream": stream,
56
- "reasoning_effort": reasoning_effort,
57
- "n_consensus": n_consensus,
58
- }
59
-
60
- # Validate DocumentAPIRequest data (raises exception if invalid)
61
- ui_chat_completions_request = UiChatCompletionsRequest.model_validate(data)
62
-
63
- return PreparedRequest(method="POST", url="/v1/completions", data=ui_chat_completions_request.model_dump(), idempotency_key=idempotency_key)
49
+ model=model,
50
+ temperature=temperature,
51
+ stream=stream,
52
+ reasoning_effort=reasoning_effort,
53
+ n_consensus=n_consensus,
54
+ )
64
55
 
56
+ return PreparedRequest(method="POST", url="/v1/completions", data=request.model_dump(), idempotency_key=idempotency_key)
65
57
 
66
58
  def prepare_create(
67
59
  self,
68
60
  response_format: ResponseFormatJSONSchema,
69
- messages: list[ChatCompletionUiformMessage],
61
+ messages: list[ChatCompletionRetabMessage],
70
62
  model: str,
71
63
  temperature: float,
72
64
  reasoning_effort: ChatCompletionReasoningEffort,
@@ -74,16 +66,17 @@ class BaseCompletionsMixin:
74
66
  n_consensus: int,
75
67
  idempotency_key: str | None = None,
76
68
  ) -> PreparedRequest:
77
-
78
69
  json_schema = response_format["json_schema"].get("schema")
79
70
 
80
71
  assert isinstance(json_schema, dict), f"json_schema must be a dictionary, got {type(json_schema)}"
81
72
 
82
73
  schema_obj = Schema(json_schema=json_schema)
83
74
 
84
- data = {
85
- "messages": messages,
86
- "response_format": {
75
+ # Validate DocumentAPIRequest data (raises exception if invalid)
76
+ request = UiChatCompletionsRequest(
77
+ model=model,
78
+ messages=messages,
79
+ response_format={
87
80
  "type": "json_schema",
88
81
  "json_schema": {
89
82
  "name": schema_obj.id,
@@ -91,17 +84,13 @@ class BaseCompletionsMixin:
91
84
  "strict": True,
92
85
  },
93
86
  },
94
- "model": model,
95
- "temperature": temperature,
96
- "stream": stream,
97
- "reasoning_effort": reasoning_effort,
98
- "n_consensus": n_consensus,
99
- }
100
-
101
- # Validate DocumentAPIRequest data (raises exception if invalid)
102
- ui_chat_completions_request = UiChatCompletionsRequest.model_validate(data)
87
+ temperature=temperature,
88
+ stream=stream,
89
+ reasoning_effort=reasoning_effort,
90
+ n_consensus=n_consensus,
91
+ )
103
92
 
104
- return PreparedRequest(method="POST", url="/v1/completions", data=ui_chat_completions_request.model_dump(), idempotency_key=idempotency_key)
93
+ return PreparedRequest(method="POST", url="/v1/completions", data=request.model_dump(), idempotency_key=idempotency_key)
105
94
 
106
95
 
107
96
  class Completions(SyncAPIResource, BaseCompletionsMixin):
@@ -111,7 +100,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
111
100
  def stream(
112
101
  self,
113
102
  response_format: type[ResponseFormatT],
114
- messages: list[ChatCompletionUiformMessage],
103
+ messages: list[ChatCompletionRetabMessage],
115
104
  model: str = "gpt-4o-2024-08-06",
116
105
  temperature: float = 0,
117
106
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -119,7 +108,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
119
108
  idempotency_key: str | None = None,
120
109
  ) -> Generator[UiParsedChatCompletion, None, None]:
121
110
  """
122
- Process messages using the UiForm API with streaming enabled.
111
+ Process messages using the Retab API with streaming enabled.
123
112
 
124
113
  Args:
125
114
  response_format: JSON schema defining the expected data structure
@@ -134,7 +123,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
134
123
 
135
124
  Usage:
136
125
  ```python
137
- with uiform.completions.stream(json_schema, messages, model, temperature, reasoning_effort) as stream:
126
+ with retab.devpletions.stream(json_schema, messages, model, temperature, reasoning_effort) as stream:
138
127
  for response in stream:
139
128
  print(response)
140
129
  ```
@@ -193,12 +182,11 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
193
182
  class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
194
183
  """Multi-provider Completions API wrapper for asynchronous usage."""
195
184
 
196
-
197
185
  @as_async_context_manager
198
186
  async def stream(
199
187
  self,
200
188
  response_format: type[ResponseFormatT],
201
- messages: list[ChatCompletionUiformMessage],
189
+ messages: list[ChatCompletionRetabMessage],
202
190
  model: str = "gpt-4o-2024-08-06",
203
191
  temperature: float = 0,
204
192
  reasoning_effort: ChatCompletionReasoningEffort = "medium",
@@ -206,7 +194,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
206
194
  idempotency_key: str | None = None,
207
195
  ) -> AsyncGenerator[UiParsedChatCompletion, None]:
208
196
  """
209
- Parse messages using the UiForm API asynchronously with streaming.
197
+ Parse messages using the Retab API asynchronously with streaming.
210
198
 
211
199
  Args:
212
200
  json_schema: JSON schema defining the expected data structure
@@ -222,7 +210,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
222
210
 
223
211
  Usage:
224
212
  ```python
225
- async with uiform.completions.stream(json_schema, messages, model, temperature, reasoning_effort, n_consensus) as stream:
213
+ async with retab.devpletions.stream(json_schema, messages, model, temperature, reasoning_effort, n_consensus) as stream:
226
214
  async for response in stream:
227
215
  print(response)
228
216
  ```
@@ -1,33 +1,20 @@
1
- import json
2
- from pathlib import Path
3
- from typing import Any, AsyncGenerator, Generator, TypeVar, Generic, Optional, Union, List, Sequence, cast
1
+ from typing import Optional, TypeVar, Union
4
2
 
5
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
6
- from openai.types.chat.parsed_chat_completion import ParsedChatCompletionMessage
7
3
  from openai.types.responses.response import Response
8
- from openai.types.responses.response_input_param import ResponseInputParam, ResponseInputItemParam
9
- from openai.types.responses.response_output_item import ResponseOutputItem
10
- from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
4
+ from openai.types.responses.response_input_param import ResponseInputParam
5
+ from openai.types.responses.response_text_config_param import ResponseTextConfigParam
6
+ from openai.types.shared_params.reasoning import Reasoning
11
7
  from pydantic import BaseModel
12
8
 
13
9
  from ..._resource import AsyncAPIResource, SyncAPIResource
14
10
  from ..._utils.ai_models import assert_valid_model_extraction
15
- from ..._utils.json_schema import load_json_schema, unflatten_dict
16
- from ..._utils.responses import convert_to_openai_format, convert_from_openai_format, parse_openai_responses_response
17
- from ..._utils.stream_context_managers import as_async_context_manager, as_context_manager
18
- from ...types.chat import ChatCompletionUiformMessage
19
- from ...types.completions import UiChatResponseCreateRequest, UiChatCompletionsRequest
20
- from ...types.documents.extractions import UiParsedChatCompletion, UiParsedChatCompletionChunk, UiParsedChoice, UiResponse
21
- from ...types.standards import PreparedRequest
11
+ from ...types.completions import UiChatResponseCreateRequest
12
+ from ...types.documents.extractions import UiResponse
22
13
  from ...types.schemas.object import Schema
14
+ from ...types.standards import PreparedRequest
23
15
 
24
- from typing import Optional, Union
25
- from openai.types.shared_params.reasoning import Reasoning
26
- from openai.types.responses.response_input_param import ResponseInputParam
27
- from openai.types.responses.response_text_config_param import ResponseTextConfigParam
28
- from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
16
+ T = TypeVar("T", bound=BaseModel)
29
17
 
30
- T = TypeVar('T', bound=BaseModel)
31
18
 
32
19
  class BaseResponsesMixin:
33
20
  def prepare_create(
@@ -55,35 +42,20 @@ class BaseResponsesMixin:
55
42
 
56
43
  if instructions is None:
57
44
  instructions = schema_obj.developer_system_prompt
58
-
45
+
59
46
  # Create the request object based on the UiChatResponseCreateRequest model
60
- data = UiChatResponseCreateRequest(
47
+ request = UiChatResponseCreateRequest(
61
48
  model=model,
62
49
  input=input,
63
50
  temperature=temperature,
64
51
  stream=False,
65
- reasoning=reasoning,
52
+ reasoning=reasoning,
66
53
  n_consensus=n_consensus,
67
- text={
68
- "format": {
69
- "type": "json_schema",
70
- "name": schema_obj.id,
71
- "schema": schema_obj.inference_json_schema,
72
- "strict": True
73
- }
74
- },
54
+ text={"format": {"type": "json_schema", "name": schema_obj.id, "schema": schema_obj.inference_json_schema, "strict": True}},
75
55
  instructions=instructions,
76
56
  )
77
57
 
78
- # Validate the request data
79
- ui_chat_response_create_request = UiChatResponseCreateRequest.model_validate(data)
80
-
81
- return PreparedRequest(
82
- method="POST",
83
- url="/v1/responses",
84
- data=ui_chat_response_create_request.model_dump(),
85
- idempotency_key=idempotency_key
86
- )
58
+ return PreparedRequest(method="POST", url="/v1/responses", data=request.model_dump(), idempotency_key=idempotency_key)
87
59
 
88
60
  def prepare_parse(
89
61
  self,
@@ -106,47 +78,29 @@ class BaseResponsesMixin:
106
78
 
107
79
  if instructions is None:
108
80
  instructions = schema_obj.developer_system_prompt
109
-
81
+
110
82
  # Create the request object based on the UiChatResponseCreateRequest model
111
- data = UiChatResponseCreateRequest(
83
+ request = UiChatResponseCreateRequest(
112
84
  model=model,
113
85
  input=input,
114
86
  temperature=temperature,
115
87
  stream=False,
116
- reasoning=reasoning,
88
+ reasoning=reasoning,
117
89
  n_consensus=n_consensus,
118
- text={
119
- "format": {
120
- "type": "json_schema",
121
- "name": schema_obj.id,
122
- "schema": schema_obj.inference_json_schema,
123
- "strict": True
124
- }
125
- },
90
+ text={"format": {"type": "json_schema", "name": schema_obj.id, "schema": schema_obj.inference_json_schema, "strict": True}},
126
91
  instructions=instructions,
127
92
  )
128
93
 
129
- # Validate the request data
130
- ui_chat_response_create_request = UiChatResponseCreateRequest.model_validate(data)
131
-
132
- return PreparedRequest(
133
- method="POST",
134
- url="/v1/responses",
135
- data=ui_chat_response_create_request.model_dump(),
136
- idempotency_key=idempotency_key
137
- )
138
-
139
-
140
94
  return PreparedRequest(
141
- method="POST",
142
- url="/v1/completions",
143
- data=ui_chat_completions_request.model_dump(),
144
- idempotency_key=idempotency_key
95
+ method="POST",
96
+ url="/v1/responses",
97
+ data=request.model_dump(),
98
+ idempotency_key=idempotency_key,
145
99
  )
146
100
 
147
101
 
148
102
  class Responses(SyncAPIResource, BaseResponsesMixin):
149
- """UiForm Responses API compatible with OpenAI Responses API"""
103
+ """Retab Responses API compatible with OpenAI Responses API"""
150
104
 
151
105
  def create(
152
106
  self,
@@ -160,8 +114,8 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
160
114
  idempotency_key: Optional[str] = None,
161
115
  ) -> Response:
162
116
  """
163
- Create a completion using the UiForm API with OpenAI Responses API compatible interface.
164
-
117
+ Create a completion using the Retab API with OpenAI Responses API compatible interface.
118
+
165
119
  Args:
166
120
  model: The model to use
167
121
  input: The input text or message array
@@ -187,9 +141,9 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
187
141
 
188
142
  result = self._client._prepared_request(request)
189
143
  response = UiResponse.model_validate(result)
190
-
144
+
191
145
  return response
192
-
146
+
193
147
  def parse(
194
148
  self,
195
149
  model: str,
@@ -202,8 +156,8 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
202
156
  idempotency_key: Optional[str] = None,
203
157
  ) -> Response:
204
158
  """
205
- Parse content using the UiForm API with OpenAI Responses API compatible interface.
206
-
159
+ Parse content using the Retab API with OpenAI Responses API compatible interface.
160
+
207
161
  Args:
208
162
  model: The model to use
209
163
  input: The input text or message array
@@ -213,7 +167,7 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
213
167
  n_consensus: Number of consensus models to use
214
168
  instructions: Optional system instructions
215
169
  idempotency_key: Idempotency key for request
216
-
170
+
217
171
  Returns:
218
172
  Response: OpenAI Responses API compatible response with parsed content
219
173
  """
@@ -230,12 +184,12 @@ class Responses(SyncAPIResource, BaseResponsesMixin):
230
184
 
231
185
  result = self._client._prepared_request(request)
232
186
  response = UiResponse.model_validate(result)
233
-
187
+
234
188
  return response
235
189
 
236
190
 
237
191
  class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
238
- """UiForm Responses API compatible with OpenAI Responses API for async usage"""
192
+ """Retab Responses API compatible with OpenAI Responses API for async usage"""
239
193
 
240
194
  async def create(
241
195
  self,
@@ -249,8 +203,8 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
249
203
  idempotency_key: Optional[str] = None,
250
204
  ) -> UiResponse:
251
205
  """
252
- Create a completion using the UiForm API asynchronously with OpenAI Responses API compatible interface.
253
-
206
+ Create a completion using the Retab API asynchronously with OpenAI Responses API compatible interface.
207
+
254
208
  Args:
255
209
  model: The model to use
256
210
  input: The input text or message array
@@ -260,7 +214,7 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
260
214
  n_consensus: Number of consensus models to use
261
215
  instructions: Optional system instructions
262
216
  idempotency_key: Idempotency key for request
263
-
217
+
264
218
  Returns:
265
219
  Response: OpenAI Responses API compatible response
266
220
  """
@@ -278,9 +232,7 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
278
232
  result = await self._client._prepared_request(request)
279
233
  response = UiResponse.model_validate(result)
280
234
  return response
281
-
282
235
 
283
-
284
236
  async def parse(
285
237
  self,
286
238
  model: str,
@@ -293,8 +245,8 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
293
245
  idempotency_key: Optional[str] = None,
294
246
  ) -> UiResponse:
295
247
  """
296
- Parse content using the UiForm API asynchronously with OpenAI Responses API compatible interface.
297
-
248
+ Parse content using the Retab API asynchronously with OpenAI Responses API compatible interface.
249
+
298
250
  Args:
299
251
  model: The model to use
300
252
  input: The input text or message array
@@ -304,7 +256,7 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
304
256
  n_consensus: Number of consensus models to use
305
257
  instructions: Optional system instructions
306
258
  idempotency_key: Idempotency key for request
307
-
259
+
308
260
  Returns:
309
261
  Response: OpenAI Responses API compatible response with parsed content
310
262
  """
@@ -322,4 +274,3 @@ class AsyncResponses(AsyncAPIResource, BaseResponsesMixin):
322
274
  result = await self._client._prepared_request(request)
323
275
  response = UiResponse.model_validate(result)
324
276
  return response
325
-