retab 0.0.39__py3-none-any.whl → 0.0.41__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.
- retab/_utils/_model_cards/gemini.yaml +1 -1
- retab/resources/consensus/completions.py +1 -1
- retab/resources/consensus/completions_stream.py +3 -3
- retab/resources/consensus/responses.py +1 -1
- retab/resources/consensus/responses_stream.py +2 -2
- retab/resources/documents/client.py +3 -3
- retab/resources/documents/extractions.py +4 -4
- retab/resources/evals.py +1 -1
- retab/resources/evaluations/documents.py +1 -1
- retab/resources/jsonlUtils.py +4 -4
- retab/resources/processors/automations/endpoints.py +3 -3
- retab/resources/processors/automations/links.py +2 -2
- retab/resources/processors/automations/mailboxes.py +3 -3
- retab/resources/processors/automations/outlook.py +2 -2
- retab/resources/processors/automations/tests.py +1 -1
- retab/resources/processors/client.py +23 -14
- retab/resources/prompt_optimization.py +1 -1
- retab/resources/schemas.py +3 -3
- retab/types/ai_models.py +1 -1
- retab/types/completions.py +1 -1
- retab/types/documents/create_messages.py +4 -4
- retab/types/documents/extractions.py +1 -1
- retab/types/evals.py +2 -2
- retab/types/evaluations/iterations.py +2 -2
- retab/types/evaluations/model.py +2 -2
- retab/types/extractions.py +1 -1
- retab/types/jobs/prompt_optimization.py +1 -1
- retab/types/logs.py +3 -3
- retab/types/schemas/object.py +4 -4
- retab/types/schemas/templates.py +1 -1
- retab/utils/__init__.py +0 -0
- retab/utils/_model_cards/anthropic.yaml +59 -0
- retab/utils/_model_cards/auto.yaml +43 -0
- retab/utils/_model_cards/gemini.yaml +117 -0
- retab/utils/_model_cards/openai.yaml +301 -0
- retab/utils/_model_cards/xai.yaml +28 -0
- retab/utils/ai_models.py +138 -0
- retab/utils/benchmarking.py +484 -0
- retab/utils/chat.py +327 -0
- retab/utils/display.py +440 -0
- retab/utils/json_schema.py +2156 -0
- retab/utils/mime.py +165 -0
- retab/utils/responses.py +169 -0
- retab/utils/stream_context_managers.py +52 -0
- retab/utils/usage/__init__.py +0 -0
- retab/utils/usage/usage.py +301 -0
- {retab-0.0.39.dist-info → retab-0.0.41.dist-info}/METADATA +5 -5
- {retab-0.0.39.dist-info → retab-0.0.41.dist-info}/RECORD +50 -34
- {retab-0.0.39.dist-info → retab-0.0.41.dist-info}/WHEEL +0 -0
- {retab-0.0.39.dist-info → retab-0.0.41.dist-info}/top_level.txt +0 -0
@@ -108,7 +108,7 @@
|
|
108
108
|
prompt: 0.50
|
109
109
|
completion: 0.40
|
110
110
|
capabilities:
|
111
|
-
modalities: ["text", "image", "audio"
|
111
|
+
modalities: ["text", "image", "audio"]
|
112
112
|
endpoints: ["chat_completions"]
|
113
113
|
features: ["streaming", "structured_outputs"]
|
114
114
|
temperature_support: true
|
@@ -5,7 +5,7 @@ from openai.types.shared_params.response_format_json_schema import ResponseForma
|
|
5
5
|
from pydantic import BaseModel as ResponseFormatT
|
6
6
|
|
7
7
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
8
|
-
from ...
|
8
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
9
9
|
from ...types.chat import ChatCompletionRetabMessage
|
10
10
|
from ...types.completions import RetabChatCompletionsRequest
|
11
11
|
from ...types.documents.extractions import RetabParsedChatCompletion
|
@@ -9,9 +9,9 @@ from openai.types.shared_params.response_format_json_schema import ResponseForma
|
|
9
9
|
from pydantic import BaseModel as ResponseFormatT
|
10
10
|
|
11
11
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
12
|
-
from ...
|
13
|
-
from ...
|
14
|
-
from ...
|
12
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
13
|
+
from ...utils.json_schema import unflatten_dict
|
14
|
+
from ...utils.stream_context_managers import as_async_context_manager, as_context_manager
|
15
15
|
from ...types.chat import ChatCompletionRetabMessage
|
16
16
|
from ...types.completions import RetabChatCompletionsRequest
|
17
17
|
from ...types.documents.extractions import RetabParsedChatCompletion, RetabParsedChatCompletionChunk, RetabParsedChoice
|
@@ -7,7 +7,7 @@ from openai.types.shared_params.reasoning import Reasoning
|
|
7
7
|
from pydantic import BaseModel
|
8
8
|
|
9
9
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
10
|
-
from ...
|
10
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
11
11
|
from ...types.completions import RetabChatResponseCreateRequest
|
12
12
|
from ...types.documents.extractions import UiResponse
|
13
13
|
from ...types.schemas.object import Schema
|
@@ -6,8 +6,8 @@ from openai.types.shared_params.reasoning import Reasoning
|
|
6
6
|
from pydantic import BaseModel
|
7
7
|
|
8
8
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
9
|
-
from ...
|
10
|
-
from ...
|
9
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
10
|
+
from ...utils.stream_context_managers import as_async_context_manager, as_context_manager
|
11
11
|
from ...types.completions import RetabChatResponseCreateRequest
|
12
12
|
from ...types.documents.extractions import UiResponse
|
13
13
|
from ...types.schemas.object import Schema
|
@@ -8,9 +8,9 @@ from pydantic_core import PydanticUndefined
|
|
8
8
|
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
9
9
|
|
10
10
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
11
|
-
from ...
|
12
|
-
from ...
|
13
|
-
from ...
|
11
|
+
from ...utils.json_schema import load_json_schema, filter_auxiliary_fields_json
|
12
|
+
from ...utils.mime import convert_mime_data_to_pil_image, prepare_mime_document
|
13
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
14
14
|
from ...types.documents.create_messages import DocumentCreateInputRequest, DocumentCreateMessageRequest, DocumentMessage
|
15
15
|
from ...types.documents.extractions import DocumentExtractRequest, RetabParsedChatCompletion
|
16
16
|
from ...types.documents.parse import ParseRequest, ParseResult, TableParsingFormat
|
@@ -14,10 +14,10 @@ from pydantic_core import PydanticUndefined
|
|
14
14
|
from pydantic import HttpUrl
|
15
15
|
|
16
16
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
17
|
-
from ...
|
18
|
-
from ...
|
19
|
-
from ...
|
20
|
-
from ...
|
17
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
18
|
+
from ...utils.json_schema import filter_auxiliary_fields_json, load_json_schema, unflatten_dict
|
19
|
+
from ...utils.mime import MIMEData, prepare_mime_document
|
20
|
+
from ...utils.stream_context_managers import as_async_context_manager, as_context_manager
|
21
21
|
from ...types.chat import ChatCompletionRetabMessage
|
22
22
|
from ...types.documents.extractions import DocumentExtractRequest, LogExtractionRequest, RetabParsedChatCompletion, RetabParsedChatCompletionChunk, RetabParsedChoice
|
23
23
|
from ...types.browser_canvas import BrowserCanvas
|
retab/resources/evals.py
CHANGED
@@ -7,7 +7,7 @@ from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionRea
|
|
7
7
|
from pydantic import HttpUrl
|
8
8
|
|
9
9
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
10
|
-
from ..
|
10
|
+
from ..utils.mime import prepare_mime_document
|
11
11
|
from ..types.evals import (
|
12
12
|
CreateIterationRequest,
|
13
13
|
DistancesResult,
|
@@ -6,7 +6,7 @@ import PIL.Image
|
|
6
6
|
from pydantic import HttpUrl
|
7
7
|
|
8
8
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
9
|
-
from ...
|
9
|
+
from ...utils.mime import prepare_mime_document
|
10
10
|
from ...types.evaluations import DocumentItem, EvaluationDocument, PatchEvaluationDocumentRequest
|
11
11
|
from ...types.mime import MIMEData
|
12
12
|
from ...types.standards import PreparedRequest, DeleteResponse, FieldUnset
|
retab/resources/jsonlUtils.py
CHANGED
@@ -18,10 +18,10 @@ from pydantic_core import PydanticUndefined
|
|
18
18
|
from tqdm import tqdm
|
19
19
|
|
20
20
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
21
|
-
from ..
|
22
|
-
from ..
|
23
|
-
from ..
|
24
|
-
from ..
|
21
|
+
from ..utils.ai_models import assert_valid_model_extraction, get_provider_for_model
|
22
|
+
from ..utils.chat import convert_to_anthropic_format, convert_to_openai_format, separate_messages
|
23
|
+
from ..utils.display import Metrics, display_metrics, process_dataset_and_compute_metrics
|
24
|
+
from ..utils.json_schema import load_json_schema
|
25
25
|
from ..types.chat import ChatCompletionRetabMessage
|
26
26
|
from ..types.modalities import Modality
|
27
27
|
from ..types.schemas.object import Schema
|
@@ -3,7 +3,7 @@ from typing import Literal, Optional
|
|
3
3
|
from pydantic_core import PydanticUndefined
|
4
4
|
|
5
5
|
from ...._resource import AsyncAPIResource, SyncAPIResource
|
6
|
-
from ....
|
6
|
+
from ....utils.ai_models import assert_valid_model_extraction
|
7
7
|
from ....types.automations.endpoints import Endpoint, ListEndpoints, UpdateEndpointRequest
|
8
8
|
from ....types.standards import PreparedRequest
|
9
9
|
|
@@ -120,7 +120,7 @@ class Endpoints(SyncAPIResource, EndpointsMixin):
|
|
120
120
|
need_validation=need_validation,
|
121
121
|
)
|
122
122
|
response = self._client._prepared_request(request)
|
123
|
-
print(f"Endpoint
|
123
|
+
print(f"Endpoint Created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
124
124
|
return Endpoint.model_validate(response)
|
125
125
|
|
126
126
|
def list(
|
@@ -229,7 +229,7 @@ class AsyncEndpoints(AsyncAPIResource, EndpointsMixin):
|
|
229
229
|
need_validation=need_validation,
|
230
230
|
)
|
231
231
|
response = await self._client._prepared_request(request)
|
232
|
-
print(f"Endpoint
|
232
|
+
print(f"Endpoint Created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
233
233
|
|
234
234
|
return Endpoint.model_validate(response)
|
235
235
|
|
@@ -128,7 +128,7 @@ class Links(SyncAPIResource, LinksMixin):
|
|
128
128
|
)
|
129
129
|
response = self._client._prepared_request(request)
|
130
130
|
|
131
|
-
print(f"
|
131
|
+
print(f"Link Created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
132
132
|
return Link.model_validate(response)
|
133
133
|
|
134
134
|
def list(
|
@@ -248,7 +248,7 @@ class AsyncLinks(AsyncAPIResource, LinksMixin):
|
|
248
248
|
password=password,
|
249
249
|
)
|
250
250
|
response = await self._client._prepared_request(request)
|
251
|
-
print(f"
|
251
|
+
print(f"Link Created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
252
252
|
return Link.model_validate(response)
|
253
253
|
|
254
254
|
async def list(
|
@@ -6,7 +6,7 @@ from pydantic import EmailStr, HttpUrl
|
|
6
6
|
from pydantic_core import PydanticUndefined
|
7
7
|
|
8
8
|
from ...._resource import AsyncAPIResource, SyncAPIResource
|
9
|
-
from ....
|
9
|
+
from ....utils.mime import prepare_mime_document
|
10
10
|
from ....types.automations.mailboxes import ListMailboxes, Mailbox, UpdateMailboxRequest
|
11
11
|
from ....types.mime import EmailData, MIMEData
|
12
12
|
from ....types.standards import PreparedRequest
|
@@ -144,7 +144,7 @@ class Mailboxes(SyncAPIResource, MailBoxesMixin):
|
|
144
144
|
)
|
145
145
|
response = self._client._prepared_request(request)
|
146
146
|
|
147
|
-
print(f"
|
147
|
+
print(f"Mailbox {response['email']} created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
148
148
|
|
149
149
|
return Mailbox.model_validate(response)
|
150
150
|
|
@@ -278,7 +278,7 @@ class AsyncMailboxes(AsyncAPIResource, MailBoxesMixin):
|
|
278
278
|
)
|
279
279
|
response = await self._client._prepared_request(request)
|
280
280
|
|
281
|
-
print(f"
|
281
|
+
print(f"Mailbox {response['email']} created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
282
282
|
|
283
283
|
return Mailbox.model_validate(response)
|
284
284
|
|
@@ -149,7 +149,7 @@ class Outlooks(SyncAPIResource, OutlooksMixin):
|
|
149
149
|
)
|
150
150
|
response = self._client._prepared_request(request)
|
151
151
|
|
152
|
-
print(f"Outlook
|
152
|
+
print(f"Outlook plugin created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
153
153
|
|
154
154
|
return Outlook.model_validate(response)
|
155
155
|
|
@@ -280,7 +280,7 @@ class AsyncOutlooks(AsyncAPIResource, OutlooksMixin):
|
|
280
280
|
fetch_params=fetch_params,
|
281
281
|
)
|
282
282
|
response = await self._client._prepared_request(request)
|
283
|
-
print(f"Outlook
|
283
|
+
print(f"Outlook plugin created. Url: https://www.retab.dev/dashboard/processors/automations/{response['id']}")
|
284
284
|
return Outlook.model_validate(response)
|
285
285
|
|
286
286
|
async def list(
|
@@ -6,7 +6,7 @@ from PIL.Image import Image
|
|
6
6
|
from pydantic import HttpUrl
|
7
7
|
|
8
8
|
from ...._resource import AsyncAPIResource, SyncAPIResource
|
9
|
-
from ....
|
9
|
+
from ....utils.mime import prepare_mime_document
|
10
10
|
from ....types.logs import AutomationLog
|
11
11
|
from ....types.mime import MIMEData
|
12
12
|
from ....types.standards import PreparedRequest
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import base64
|
2
2
|
from io import IOBase
|
3
3
|
from pathlib import Path
|
4
|
-
from typing import Any,
|
4
|
+
from typing import Any, List, Literal
|
5
5
|
|
6
6
|
import PIL.Image
|
7
7
|
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
@@ -9,8 +9,9 @@ from pydantic import BaseModel, HttpUrl
|
|
9
9
|
from pydantic_core import PydanticUndefined
|
10
10
|
|
11
11
|
from ..._resource import AsyncAPIResource, SyncAPIResource
|
12
|
-
from ...
|
13
|
-
from ...
|
12
|
+
from ...utils.ai_models import assert_valid_model_extraction
|
13
|
+
from ...utils.json_schema import load_json_schema
|
14
|
+
from ...utils.mime import MIMEData, prepare_mime_document
|
14
15
|
from ...types.browser_canvas import BrowserCanvas
|
15
16
|
from ...types.documents.extractions import RetabParsedChatCompletion
|
16
17
|
from ...types.logs import ProcessorConfig, UpdateProcessorRequest
|
@@ -31,7 +32,7 @@ class ProcessorsMixin:
|
|
31
32
|
def prepare_create(
|
32
33
|
self,
|
33
34
|
name: str,
|
34
|
-
json_schema: dict[str, Any],
|
35
|
+
json_schema: dict[str, Any] | Path | str,
|
35
36
|
modality: Modality = "native",
|
36
37
|
model: str = "gpt-4o-mini",
|
37
38
|
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
@@ -42,9 +43,12 @@ class ProcessorsMixin:
|
|
42
43
|
) -> PreparedRequest:
|
43
44
|
assert_valid_model_extraction(model)
|
44
45
|
|
46
|
+
# Load the JSON schema from file path, string, or dict
|
47
|
+
loaded_schema = load_json_schema(json_schema)
|
48
|
+
|
45
49
|
processor_config = ProcessorConfig(
|
46
50
|
name=name,
|
47
|
-
json_schema=
|
51
|
+
json_schema=loaded_schema,
|
48
52
|
modality=modality,
|
49
53
|
model=model,
|
50
54
|
temperature=temperature,
|
@@ -104,7 +108,7 @@ class ProcessorsMixin:
|
|
104
108
|
image_resolution_dpi: int | None = None,
|
105
109
|
browser_canvas: BrowserCanvas | None = None,
|
106
110
|
model: str | None = None,
|
107
|
-
json_schema: dict[str, Any] | None = None,
|
111
|
+
json_schema: dict[str, Any] | Path | str | None = None,
|
108
112
|
temperature: float | None = None,
|
109
113
|
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
110
114
|
n_consensus: int | None = None,
|
@@ -112,13 +116,18 @@ class ProcessorsMixin:
|
|
112
116
|
if model is not None:
|
113
117
|
assert_valid_model_extraction(model)
|
114
118
|
|
119
|
+
# Load the JSON schema from file path, string, or dict if provided
|
120
|
+
loaded_schema = None
|
121
|
+
if json_schema is not None:
|
122
|
+
loaded_schema = load_json_schema(json_schema)
|
123
|
+
|
115
124
|
update_request = UpdateProcessorRequest(
|
116
125
|
name=name,
|
117
126
|
modality=modality,
|
118
127
|
image_resolution_dpi=image_resolution_dpi,
|
119
128
|
browser_canvas=browser_canvas,
|
120
129
|
model=model,
|
121
|
-
json_schema=
|
130
|
+
json_schema=loaded_schema,
|
122
131
|
temperature=temperature,
|
123
132
|
reasoning_effort=reasoning_effort,
|
124
133
|
n_consensus=n_consensus,
|
@@ -203,7 +212,7 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
203
212
|
def create(
|
204
213
|
self,
|
205
214
|
name: str,
|
206
|
-
json_schema:
|
215
|
+
json_schema: dict[str, Any] | Path | str,
|
207
216
|
modality: Modality = "native",
|
208
217
|
model: str = "gpt-4o-mini",
|
209
218
|
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
@@ -216,7 +225,7 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
216
225
|
|
217
226
|
Args:
|
218
227
|
name: Name of the processor
|
219
|
-
json_schema: JSON schema for the processor
|
228
|
+
json_schema: JSON schema for the processor. Can be a dictionary, file path (Path or str), or JSON string.
|
220
229
|
image_resolution_dpi: Optional image resolution DPI
|
221
230
|
browser_canvas: Optional browser canvas size
|
222
231
|
modality: Processing modality (currently only "native" supported)
|
@@ -295,7 +304,7 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
295
304
|
image_resolution_dpi: int | None = None,
|
296
305
|
browser_canvas: BrowserCanvas | None = None,
|
297
306
|
model: str | None = None,
|
298
|
-
json_schema: dict[str, Any] | None = None,
|
307
|
+
json_schema: dict[str, Any] | Path | str | None = None,
|
299
308
|
temperature: float | None = None,
|
300
309
|
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
301
310
|
n_consensus: int | None = None,
|
@@ -309,7 +318,7 @@ class Processors(SyncAPIResource, ProcessorsMixin):
|
|
309
318
|
image_resolution_dpi: New image resolution DPI
|
310
319
|
browser_canvas: New browser canvas size
|
311
320
|
model: New AI model
|
312
|
-
json_schema: New JSON schema for the processor
|
321
|
+
json_schema: New JSON schema for the processor. Can be a dictionary, file path (Path or str), or JSON string.
|
313
322
|
temperature: New temperature setting
|
314
323
|
reasoning_effort: The effort level for the model to reason about the input data.
|
315
324
|
n_consensus: New number of consensus required
|
@@ -378,7 +387,7 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
378
387
|
async def create(
|
379
388
|
self,
|
380
389
|
name: str,
|
381
|
-
json_schema:
|
390
|
+
json_schema: dict[str, Any] | Path | str,
|
382
391
|
modality: Modality = "native",
|
383
392
|
model: str = "gpt-4o-mini",
|
384
393
|
temperature: float = PydanticUndefined, # type: ignore[assignment]
|
@@ -432,7 +441,7 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
432
441
|
image_resolution_dpi: int | None = None,
|
433
442
|
browser_canvas: BrowserCanvas | None = None,
|
434
443
|
model: str | None = None,
|
435
|
-
json_schema: dict[str, Any] | None = None,
|
444
|
+
json_schema: dict[str, Any] | Path | str | None = None,
|
436
445
|
temperature: float | None = None,
|
437
446
|
reasoning_effort: ChatCompletionReasoningEffort | None = None,
|
438
447
|
n_consensus: int | None = None,
|
@@ -446,7 +455,7 @@ class AsyncProcessors(AsyncAPIResource, ProcessorsMixin):
|
|
446
455
|
image_resolution_dpi: New image resolution DPI
|
447
456
|
browser_canvas: New browser canvas size
|
448
457
|
model: New AI model
|
449
|
-
json_schema: New JSON schema for the processor
|
458
|
+
json_schema: New JSON schema for the processor. Can be a dictionary, file path (Path or str), or JSON string.
|
450
459
|
temperature: New temperature setting
|
451
460
|
reasoning_effort: The effort level for the model to reason about the input data.
|
452
461
|
n_consensus: New number of consensus required
|
@@ -3,7 +3,7 @@
|
|
3
3
|
# import json
|
4
4
|
|
5
5
|
# from .._resource import SyncAPIResource, AsyncAPIResource
|
6
|
-
# from ..
|
6
|
+
# from ..utils.json_schema import load_json_schema
|
7
7
|
# from ..types.jobs import JobResponse
|
8
8
|
# from ..types.jobs.prompt_optimization import PromptOptimizationObject, PromptOptimizationProps, PromptOptimizationJobInputData, PromptOptimizationJob
|
9
9
|
|
retab/resources/schemas.py
CHANGED
@@ -7,9 +7,9 @@ from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionRea
|
|
7
7
|
from pydantic import BaseModel
|
8
8
|
|
9
9
|
from .._resource import AsyncAPIResource, SyncAPIResource
|
10
|
-
from ..
|
11
|
-
from ..
|
12
|
-
from ..
|
10
|
+
from ..utils.ai_models import assert_valid_model_schema_generation
|
11
|
+
from ..utils.json_schema import load_json_schema
|
12
|
+
from ..utils.mime import prepare_mime_document_list
|
13
13
|
from ..types.mime import MIMEData
|
14
14
|
from ..types.modalities import Modality
|
15
15
|
from ..types.schemas.enhance import EnhanceSchemaConfig, EnhanceSchemaConfigDict, EnhanceSchemaRequest
|
retab/types/ai_models.py
CHANGED
@@ -14,7 +14,7 @@ GeminiModel = Literal[
|
|
14
14
|
"gemini-2.5-pro-preview-03-25",
|
15
15
|
"gemini-2.5-flash-preview-05-20",
|
16
16
|
"gemini-2.5-flash-preview-04-17",
|
17
|
-
"gemini-2.5-flash-lite-preview-06-
|
17
|
+
"gemini-2.5-flash-lite-preview-06-17",
|
18
18
|
"gemini-2.5-pro-exp-03-25",
|
19
19
|
"gemini-2.0-flash-lite",
|
20
20
|
"gemini-2.0-flash",
|
retab/types/completions.py
CHANGED
@@ -7,7 +7,7 @@ from openai.types.shared_params.reasoning import Reasoning
|
|
7
7
|
from openai.types.shared_params.response_format_json_schema import ResponseFormatJSONSchema
|
8
8
|
from pydantic import BaseModel, ConfigDict, Field
|
9
9
|
|
10
|
-
from ..
|
10
|
+
from ..utils.ai_models import get_provider_for_model
|
11
11
|
from .ai_models import AIProvider
|
12
12
|
from .chat import ChatCompletionRetabMessage
|
13
13
|
|
@@ -10,10 +10,10 @@ from openai.types.chat.chat_completion_message_param import ChatCompletionMessag
|
|
10
10
|
from openai.types.responses.response_input_param import ResponseInputItemParam
|
11
11
|
from pydantic import BaseModel, Field, computed_field
|
12
12
|
|
13
|
-
from ...
|
14
|
-
from ...
|
15
|
-
from ...
|
16
|
-
from ...
|
13
|
+
from ...utils.chat import convert_to_anthropic_format, convert_to_google_genai_format, str_messages
|
14
|
+
from ...utils.chat import convert_to_openai_format as convert_to_openai_completions_api_format
|
15
|
+
from ...utils.display import count_image_tokens, count_text_tokens
|
16
|
+
from ...utils.responses import convert_to_openai_format as convert_to_openai_responses_api_format
|
17
17
|
from ..chat import ChatCompletionRetabMessage
|
18
18
|
from ..mime import MIMEData
|
19
19
|
from ..modalities import Modality
|
@@ -15,7 +15,7 @@ from openai.types.responses.response import Response
|
|
15
15
|
from openai.types.responses.response_input_param import ResponseInputItemParam
|
16
16
|
from pydantic import BaseModel, ConfigDict, Field, ValidationInfo, computed_field, field_validator, model_validator
|
17
17
|
|
18
|
-
from ...
|
18
|
+
from ...utils.usage.usage import CostBreakdown, compute_cost_from_model, compute_cost_from_model_with_breakdown
|
19
19
|
from ..ai_models import Amount
|
20
20
|
from ..chat import ChatCompletionRetabMessage
|
21
21
|
from ..mime import MIMEData
|
retab/types/evals.py
CHANGED
@@ -6,8 +6,8 @@ from typing import Any, List, Literal, Optional
|
|
6
6
|
import nanoid # type: ignore
|
7
7
|
from pydantic import BaseModel, Field, computed_field
|
8
8
|
|
9
|
-
from ..
|
10
|
-
from ..
|
9
|
+
from ..utils.json_schema import clean_schema, compute_schema_data_id
|
10
|
+
from ..utils.mime import generate_blake2b_hash_from_string
|
11
11
|
from .ai_models import Amount
|
12
12
|
from .inference_settings import InferenceSettings
|
13
13
|
from .mime import MIMEData
|
@@ -6,8 +6,8 @@ from typing import Any, Optional, Self
|
|
6
6
|
import nanoid # type: ignore
|
7
7
|
from pydantic import BaseModel, Field, computed_field, model_validator
|
8
8
|
|
9
|
-
from ...
|
10
|
-
from ...
|
9
|
+
from ...utils.json_schema import clean_schema
|
10
|
+
from ...utils.mime import generate_blake2b_hash_from_string
|
11
11
|
from ..inference_settings import InferenceSettings
|
12
12
|
from ..metrics import MetricResult
|
13
13
|
from ..predictions import PredictionData
|
retab/types/evaluations/model.py
CHANGED
@@ -5,8 +5,8 @@ from typing import Any, Optional
|
|
5
5
|
import nanoid # type: ignore
|
6
6
|
from pydantic import BaseModel, Field, computed_field
|
7
7
|
|
8
|
-
from ...
|
9
|
-
from ...
|
8
|
+
from ...utils.json_schema import compute_schema_data_id
|
9
|
+
from ...utils.mime import generate_blake2b_hash_from_string
|
10
10
|
from ..inference_settings import InferenceSettings
|
11
11
|
from .documents import EvaluationDocument
|
12
12
|
from .iterations import Iteration
|
retab/types/extractions.py
CHANGED
@@ -9,7 +9,7 @@ from pydantic import BaseModel, Field, computed_field, model_validator
|
|
9
9
|
from retab.types.chat import ChatCompletionRetabMessage
|
10
10
|
from retab.types.documents.extractions import RetabParsedChatCompletion
|
11
11
|
|
12
|
-
from ..
|
12
|
+
from ..utils.usage.usage import CostBreakdown, compute_cost_from_model, compute_cost_from_model_with_breakdown
|
13
13
|
from .ai_models import Amount
|
14
14
|
from .modalities import Modality
|
15
15
|
|
retab/types/logs.py
CHANGED
@@ -7,9 +7,9 @@ from openai.types.chat.chat_completion import ChatCompletion
|
|
7
7
|
from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
|
8
8
|
from pydantic import BaseModel, EmailStr, Field, HttpUrl, computed_field, field_validator
|
9
9
|
|
10
|
-
from ..
|
11
|
-
from ..
|
12
|
-
from ..
|
10
|
+
from ..utils.json_schema import compute_schema_data_id
|
11
|
+
from ..utils.mime import generate_blake2b_hash_from_string
|
12
|
+
from ..utils.usage.usage import CostBreakdown, compute_cost_from_model, compute_cost_from_model_with_breakdown
|
13
13
|
from .ai_models import Amount
|
14
14
|
from .documents.extractions import RetabParsedChatCompletion
|
15
15
|
from .mime import BaseMIMEData
|
retab/types/schemas/object.py
CHANGED
@@ -10,9 +10,9 @@ from openai.types.chat.chat_completion_message_param import ChatCompletionMessag
|
|
10
10
|
from openai.types.responses.response_input_param import ResponseInputItemParam
|
11
11
|
from pydantic import BaseModel, Field, PrivateAttr, computed_field, model_validator
|
12
12
|
|
13
|
-
from ...
|
14
|
-
from ...
|
15
|
-
from ...
|
13
|
+
from ...utils.chat import convert_to_anthropic_format, convert_to_google_genai_format
|
14
|
+
from ...utils.chat import convert_to_openai_format as convert_to_openai_completions_api_format
|
15
|
+
from ...utils.json_schema import (
|
16
16
|
convert_basemodel_to_partial_basemodel,
|
17
17
|
convert_json_schema_to_basemodel,
|
18
18
|
create_reasoning_schema,
|
@@ -25,7 +25,7 @@ from ..._utils.json_schema import (
|
|
25
25
|
load_json_schema,
|
26
26
|
schema_to_ts_type,
|
27
27
|
)
|
28
|
-
from ...
|
28
|
+
from ...utils.responses import convert_to_openai_format as convert_to_openai_responses_api_format
|
29
29
|
from ...types.standards import StreamingBaseModel
|
30
30
|
from ..chat import ChatCompletionRetabMessage
|
31
31
|
|
retab/types/schemas/templates.py
CHANGED
@@ -4,7 +4,7 @@ from typing import Any, Literal, Optional
|
|
4
4
|
import nanoid # type: ignore
|
5
5
|
from pydantic import BaseModel, Field, PrivateAttr, computed_field
|
6
6
|
|
7
|
-
from ...
|
7
|
+
from ...utils.json_schema import generate_schema_data_id, generate_schema_id
|
8
8
|
from ...types.mime import MIMEData
|
9
9
|
|
10
10
|
|
retab/utils/__init__.py
ADDED
File without changes
|
@@ -0,0 +1,59 @@
|
|
1
|
+
- model: "claude-3-5-sonnet-latest"
|
2
|
+
pricing:
|
3
|
+
text:
|
4
|
+
prompt: 3.00
|
5
|
+
cached_discount: 0.5
|
6
|
+
completion: 15.00
|
7
|
+
audio: null
|
8
|
+
capabilities:
|
9
|
+
modalities: ["text", "image"]
|
10
|
+
endpoints: ["chat_completions"]
|
11
|
+
features: ["streaming", "function_calling"]
|
12
|
+
permissions:
|
13
|
+
show_in_free_picker: true
|
14
|
+
show_in_paid_picker: true
|
15
|
+
|
16
|
+
- model: "claude-3-5-sonnet-20241022"
|
17
|
+
inherits: "claude-3-5-sonnet-latest"
|
18
|
+
permissions:
|
19
|
+
show_in_free_picker: false
|
20
|
+
show_in_paid_picker: false
|
21
|
+
|
22
|
+
- model: "claude-3-opus-20240229"
|
23
|
+
pricing:
|
24
|
+
text:
|
25
|
+
prompt: 15.00
|
26
|
+
cached_discount: 0.5
|
27
|
+
completion: 75.00
|
28
|
+
audio: null
|
29
|
+
capabilities:
|
30
|
+
modalities: ["text", "image"]
|
31
|
+
endpoints: ["chat_completions"]
|
32
|
+
features: ["streaming", "function_calling"]
|
33
|
+
permissions:
|
34
|
+
show_in_free_picker: true
|
35
|
+
show_in_paid_picker: true
|
36
|
+
|
37
|
+
- model: "claude-3-sonnet-20240229"
|
38
|
+
pricing:
|
39
|
+
text:
|
40
|
+
prompt: 3.00
|
41
|
+
cached_discount: 0.5
|
42
|
+
completion: 15.00
|
43
|
+
audio: null
|
44
|
+
capabilities:
|
45
|
+
modalities: ["text", "image"]
|
46
|
+
endpoints: ["chat_completions"]
|
47
|
+
features: ["streaming", "function_calling"]
|
48
|
+
|
49
|
+
- model: "claude-3-haiku-20240307"
|
50
|
+
pricing:
|
51
|
+
text:
|
52
|
+
prompt: 0.25
|
53
|
+
cached_discount: 0.5
|
54
|
+
completion: 1.25
|
55
|
+
audio: null
|
56
|
+
capabilities:
|
57
|
+
modalities: ["text", "image"]
|
58
|
+
endpoints: ["chat_completions"]
|
59
|
+
features: ["streaming", "function_calling"]
|
@@ -0,0 +1,43 @@
|
|
1
|
+
- model: "auto-large"
|
2
|
+
pricing:
|
3
|
+
text:
|
4
|
+
prompt: 2.00
|
5
|
+
cached_discount: 0.25
|
6
|
+
completion: 8.00
|
7
|
+
audio: null
|
8
|
+
ft_price_hike: 1.5
|
9
|
+
capabilities:
|
10
|
+
modalities: ["text", "image"]
|
11
|
+
endpoints: ["chat_completions"]
|
12
|
+
features: ["streaming", "function_calling", "structured_outputs"]
|
13
|
+
temperature_support: true
|
14
|
+
|
15
|
+
- model: "auto-small"
|
16
|
+
pricing:
|
17
|
+
text:
|
18
|
+
prompt: 0.4
|
19
|
+
cached_discount: 0.25
|
20
|
+
completion: 1.6
|
21
|
+
audio:
|
22
|
+
prompt: 0.7
|
23
|
+
cached_discount: 0.175
|
24
|
+
completion: 1000
|
25
|
+
capabilities:
|
26
|
+
modalities: ["text", "image"]
|
27
|
+
endpoints: ["chat_completions"]
|
28
|
+
features: ["streaming", "function_calling", "structured_outputs"]
|
29
|
+
temperature_support: true
|
30
|
+
|
31
|
+
- model: "auto-micro"
|
32
|
+
pricing:
|
33
|
+
text:
|
34
|
+
prompt: 0.1
|
35
|
+
cached_discount: 0.25
|
36
|
+
completion: 0.4
|
37
|
+
audio: null
|
38
|
+
ft_price_hike: 1.5
|
39
|
+
capabilities:
|
40
|
+
modalities: ["text", "image"]
|
41
|
+
endpoints: ["chat_completions"]
|
42
|
+
features: ["streaming", "function_calling", "structured_outputs"]
|
43
|
+
temperature_support: true
|