retab 0.0.41__tar.gz → 0.0.43__tar.gz
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-0.0.43/PKG-INFO +117 -0
- retab-0.0.43/README.md +74 -0
- {retab-0.0.41 → retab-0.0.43}/retab/__init__.py +2 -1
- {retab-0.0.41 → retab-0.0.43}/retab/client.py +21 -50
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/client.py +1 -1
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/completions_stream.py +2 -2
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/responses.py +1 -1
- {retab-0.0.41 → retab-0.0.43}/retab/resources/documents/client.py +103 -76
- {retab-0.0.41 → retab-0.0.43}/retab/resources/documents/extractions.py +55 -46
- {retab-0.0.41 → retab-0.0.43}/retab/resources/evaluations/client.py +32 -19
- {retab-0.0.41 → retab-0.0.43}/retab/resources/evaluations/documents.py +12 -11
- {retab-0.0.41 → retab-0.0.43}/retab/resources/evaluations/iterations.py +48 -30
- {retab-0.0.41 → retab-0.0.43}/retab/resources/jsonlUtils.py +3 -4
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/endpoints.py +57 -43
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/links.py +54 -45
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/logs.py +2 -2
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/mailboxes.py +116 -90
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/outlook.py +126 -86
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/tests.py +7 -1
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/client.py +37 -32
- {retab-0.0.41 → retab-0.0.43}/retab/resources/usage.py +2 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/ai_models.py +1 -1
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/mailboxes.py +1 -1
- retab-0.0.41/retab/types/evals.py → retab-0.0.43/retab/types/deprecated_evals.py +7 -19
- {retab-0.0.41 → retab-0.0.43}/retab/types/documents/extractions.py +2 -2
- {retab-0.0.41 → retab-0.0.43}/retab/types/documents/parse.py +3 -1
- {retab-0.0.41 → retab-0.0.43}/retab/types/evaluations/__init__.py +5 -2
- {retab-0.0.41 → retab-0.0.43}/retab/types/evaluations/iterations.py +9 -43
- {retab-0.0.41 → retab-0.0.43}/retab/types/evaluations/model.py +20 -22
- {retab-0.0.41 → retab-0.0.43}/retab/types/extractions.py +35 -9
- {retab-0.0.41 → retab-0.0.43}/retab/types/logs.py +5 -6
- {retab-0.0.41 → retab-0.0.43}/retab/types/mime.py +1 -10
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/enhance.py +22 -5
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/evaluate.py +1 -1
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/object.py +26 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/standards.py +2 -2
- retab-0.0.43/retab/utils/__init__.py +3 -0
- retab-0.0.43/retab/utils/ai_models.py +253 -0
- retab-0.0.43/retab/utils/hashing.py +24 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/json_schema.py +1 -26
- {retab-0.0.41 → retab-0.0.43}/retab/utils/mime.py +0 -17
- retab-0.0.43/retab.egg-info/PKG-INFO +117 -0
- {retab-0.0.41 → retab-0.0.43}/retab.egg-info/SOURCES.txt +2 -2
- {retab-0.0.41 → retab-0.0.43}/setup.py +1 -1
- {retab-0.0.41 → retab-0.0.43}/tests/test_automations_mailboxes.py +1 -1
- retab-0.0.41/PKG-INFO +0 -418
- retab-0.0.41/README.md +0 -375
- retab-0.0.41/retab/resources/evals.py +0 -825
- retab-0.0.41/retab/utils/ai_models.py +0 -138
- retab-0.0.41/retab/utils/usage/__init__.py +0 -0
- retab-0.0.41/retab.egg-info/PKG-INFO +0 -418
- {retab-0.0.41 → retab-0.0.43}/pyproject.toml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/_resource.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/py.typed +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/completions.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/consensus/responses_stream.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/documents/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/evaluations/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/files.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/finetuning.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/models.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/openai_example.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/processors/automations/client.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/prompt_optimization.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/schemas.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/secrets/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/secrets/client.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/secrets/external_api_keys.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/resources/secrets/webhook.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/cron.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/endpoints.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/links.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/outlook.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/automations/webhooks.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/browser_canvas.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/chat.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/completions.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/consensus.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/db/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/db/annotations.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/db/files.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/documents/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/documents/correct_orientation.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/documents/create_messages.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/evaluations/documents.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/events.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/inference_settings.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/base.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/batch_annotation.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/evaluation.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/finetune.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/prompt_optimization.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/jobs/webcrawl.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/metrics.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/modalities.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/pagination.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/predictions.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/generate.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/layout.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/schemas/templates.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/secrets/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/types/secrets/external_api_keys.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/_model_cards/anthropic.yaml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/_model_cards/auto.yaml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/_model_cards/gemini.yaml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/_model_cards/openai.yaml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/_model_cards/xai.yaml +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/benchmarking.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/chat.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/display.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/responses.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/stream_context_managers.py +0 -0
- {retab-0.0.41/retab/utils → retab-0.0.43/retab/utils/usage}/__init__.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab/utils/usage/usage.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab.egg-info/dependency_links.txt +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab.egg-info/requires.txt +0 -0
- {retab-0.0.41 → retab-0.0.43}/retab.egg-info/top_level.txt +0 -0
- {retab-0.0.41 → retab-0.0.43}/setup.cfg +0 -0
- {retab-0.0.41 → retab-0.0.43}/tests/test_automations_links.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/tests/test_documents_api.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/tests/test_evaluations.py +0 -0
- {retab-0.0.41 → retab-0.0.43}/tests/test_preprocessor.py +0 -0
retab-0.0.43/PKG-INFO
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: retab
|
3
|
+
Version: 0.0.43
|
4
|
+
Summary: Retab official python library
|
5
|
+
Home-page: https://github.com/Retab-dev/retab
|
6
|
+
Author: Retab
|
7
|
+
Author-email: contact@retab.com
|
8
|
+
Project-URL: Team website, https://retab.com
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
11
|
+
Classifier: Operating System :: POSIX :: Linux
|
12
|
+
Classifier: Operating System :: MacOS
|
13
|
+
Classifier: Intended Audience :: Science/Research
|
14
|
+
Requires-Python: >=3.6
|
15
|
+
Description-Content-Type: text/markdown
|
16
|
+
Requires-Dist: Pillow
|
17
|
+
Requires-Dist: httpx
|
18
|
+
Requires-Dist: pydantic
|
19
|
+
Requires-Dist: pydantic_core
|
20
|
+
Requires-Dist: requests
|
21
|
+
Requires-Dist: tqdm
|
22
|
+
Requires-Dist: types-tqdm
|
23
|
+
Requires-Dist: backoff
|
24
|
+
Requires-Dist: termplotlib
|
25
|
+
Requires-Dist: Levenshtein
|
26
|
+
Requires-Dist: pandas
|
27
|
+
Requires-Dist: numpy
|
28
|
+
Requires-Dist: motor
|
29
|
+
Requires-Dist: rich
|
30
|
+
Requires-Dist: puremagic
|
31
|
+
Requires-Dist: pycountry
|
32
|
+
Requires-Dist: phonenumbers
|
33
|
+
Requires-Dist: email_validator
|
34
|
+
Requires-Dist: python-stdnum
|
35
|
+
Requires-Dist: nanoid
|
36
|
+
Requires-Dist: openai
|
37
|
+
Requires-Dist: google-genai
|
38
|
+
Requires-Dist: google-generativeai
|
39
|
+
Requires-Dist: anthropic
|
40
|
+
Requires-Dist: tiktoken
|
41
|
+
Requires-Dist: truststore
|
42
|
+
Requires-Dist: ruff
|
43
|
+
|
44
|
+
# Retab
|
45
|
+
|
46
|
+
<div align="center" style="margin-bottom: 1em;">
|
47
|
+
|
48
|
+
<img src="https://raw.githubusercontent.com/Retab-dev/retab/refs/heads/main/assets/retab-logo.png" alt="Retab Logo" width="150">
|
49
|
+
|
50
|
+
|
51
|
+
*The AI Automation Platform*
|
52
|
+
|
53
|
+
Made with love by the team at [Retab](https://retab.com) 🤍.
|
54
|
+
|
55
|
+
[Our Website](https://retab.com) | [Documentation](https://docs.retab.com/get-started/introduction) | [Discord](https://discord.com/invite/vc5tWRPqag) | [Twitter](https://x.com/retabdev)
|
56
|
+
|
57
|
+
|
58
|
+
</div>
|
59
|
+
|
60
|
+
---
|
61
|
+
|
62
|
+
### What is Retab?
|
63
|
+
|
64
|
+
Retab solves all the major challenges in document processing with Large Language Models:
|
65
|
+
|
66
|
+
1. **Universal Document Preprocessing**: Convert any file type (PDFs, Excel, emails, etc.) into LLM-ready format without writing custom parsers
|
67
|
+
2. **Structured, Schema-driven Extraction**: Get consistent, reliable outputs using schema-based prompt engineering
|
68
|
+
3. **Processors**: Publish a live, stable, shareable document processor.
|
69
|
+
4. **Automations**: Create document processing workflows that can be triggered by events (mailbox, upload link, endpoint, outlook plugin).
|
70
|
+
5. **Evaluations**: Evaluate the performance of models against annotated datasets
|
71
|
+
6. **Optimizations**: Identify the most used processors and help you finetune models to reduce costs and improve performance
|
72
|
+
|
73
|
+
We are offering you all the software-defined primitives to build your own document processing solutions. We see it as **Stripe** for document processing.
|
74
|
+
|
75
|
+
Our goal is to make the process of analyzing documents and unstructured data as **easy** and **transparent** as possible.
|
76
|
+
|
77
|
+
**A new, lighter paradigm**
|
78
|
+
Large Language Models collapse entire layers of legacy OCR pipelines into a single, elegant abstraction. When a model can read, reason, and structure text natively, we no longer need brittle heuristics, handcrafted parsers, or heavyweight ETL jobs. Instead, we can expose a small, principled API: "give me the document, tell me the schema, and get back structured truth." Complexity evaporates, reliability rises, speed follows, and costs fall—because every component you remove is one that can no longer break. LLM‑first design lets us focus less on plumbing and more on the questions we actually want answered.
|
79
|
+
|
80
|
+
Many people haven't yet realized how powerful LLMs have become at document processing tasks - we're here to help **unlock these capabilities**.
|
81
|
+
|
82
|
+
---
|
83
|
+
|
84
|
+
## Go further
|
85
|
+
|
86
|
+
* [Quickstart](/get-started/quickstart)
|
87
|
+
* [API Reference](/api-reference/introduction)
|
88
|
+
|
89
|
+
---
|
90
|
+
|
91
|
+
## Code examples
|
92
|
+
|
93
|
+
You can check our Github repository to see code examples: [python examples](https://github.com/Retab-dev/retab/tree/main/examples) and [jupyter notebooks](https://github.com/Retab-dev/retab-nodejs/tree/main/notebooks).
|
94
|
+
|
95
|
+
## Community
|
96
|
+
|
97
|
+
Let's create the future of document processing together!
|
98
|
+
|
99
|
+
Join our [discord community](https://discord.com/invite/vc5tWRPqag) to share tips, discuss best practices, and showcase what you build. Or just [tweet](https://x.com/retabdev) at us.
|
100
|
+
|
101
|
+
We can't wait to see how you'll use Retab.
|
102
|
+
|
103
|
+
* [Discord](https://discord.com/invite/vc5tWRPqag)
|
104
|
+
* [Twitter](https://x.com/retabdev)
|
105
|
+
|
106
|
+
---
|
107
|
+
|
108
|
+
## Roadmap
|
109
|
+
|
110
|
+
We share our roadmap publicly on [Github](https://github.com/Retab-dev/retab)
|
111
|
+
|
112
|
+
Among the features we're working on:
|
113
|
+
|
114
|
+
* [ ] Node.js SDK
|
115
|
+
* [ ] Schema optimization autopilot
|
116
|
+
* [ ] Sources API
|
117
|
+
|
retab-0.0.43/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Retab
|
2
|
+
|
3
|
+
<div align="center" style="margin-bottom: 1em;">
|
4
|
+
|
5
|
+
<img src="https://raw.githubusercontent.com/Retab-dev/retab/refs/heads/main/assets/retab-logo.png" alt="Retab Logo" width="150">
|
6
|
+
|
7
|
+
|
8
|
+
*The AI Automation Platform*
|
9
|
+
|
10
|
+
Made with love by the team at [Retab](https://retab.com) 🤍.
|
11
|
+
|
12
|
+
[Our Website](https://retab.com) | [Documentation](https://docs.retab.com/get-started/introduction) | [Discord](https://discord.com/invite/vc5tWRPqag) | [Twitter](https://x.com/retabdev)
|
13
|
+
|
14
|
+
|
15
|
+
</div>
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
### What is Retab?
|
20
|
+
|
21
|
+
Retab solves all the major challenges in document processing with Large Language Models:
|
22
|
+
|
23
|
+
1. **Universal Document Preprocessing**: Convert any file type (PDFs, Excel, emails, etc.) into LLM-ready format without writing custom parsers
|
24
|
+
2. **Structured, Schema-driven Extraction**: Get consistent, reliable outputs using schema-based prompt engineering
|
25
|
+
3. **Processors**: Publish a live, stable, shareable document processor.
|
26
|
+
4. **Automations**: Create document processing workflows that can be triggered by events (mailbox, upload link, endpoint, outlook plugin).
|
27
|
+
5. **Evaluations**: Evaluate the performance of models against annotated datasets
|
28
|
+
6. **Optimizations**: Identify the most used processors and help you finetune models to reduce costs and improve performance
|
29
|
+
|
30
|
+
We are offering you all the software-defined primitives to build your own document processing solutions. We see it as **Stripe** for document processing.
|
31
|
+
|
32
|
+
Our goal is to make the process of analyzing documents and unstructured data as **easy** and **transparent** as possible.
|
33
|
+
|
34
|
+
**A new, lighter paradigm**
|
35
|
+
Large Language Models collapse entire layers of legacy OCR pipelines into a single, elegant abstraction. When a model can read, reason, and structure text natively, we no longer need brittle heuristics, handcrafted parsers, or heavyweight ETL jobs. Instead, we can expose a small, principled API: "give me the document, tell me the schema, and get back structured truth." Complexity evaporates, reliability rises, speed follows, and costs fall—because every component you remove is one that can no longer break. LLM‑first design lets us focus less on plumbing and more on the questions we actually want answered.
|
36
|
+
|
37
|
+
Many people haven't yet realized how powerful LLMs have become at document processing tasks - we're here to help **unlock these capabilities**.
|
38
|
+
|
39
|
+
---
|
40
|
+
|
41
|
+
## Go further
|
42
|
+
|
43
|
+
* [Quickstart](/get-started/quickstart)
|
44
|
+
* [API Reference](/api-reference/introduction)
|
45
|
+
|
46
|
+
---
|
47
|
+
|
48
|
+
## Code examples
|
49
|
+
|
50
|
+
You can check our Github repository to see code examples: [python examples](https://github.com/Retab-dev/retab/tree/main/examples) and [jupyter notebooks](https://github.com/Retab-dev/retab-nodejs/tree/main/notebooks).
|
51
|
+
|
52
|
+
## Community
|
53
|
+
|
54
|
+
Let's create the future of document processing together!
|
55
|
+
|
56
|
+
Join our [discord community](https://discord.com/invite/vc5tWRPqag) to share tips, discuss best practices, and showcase what you build. Or just [tweet](https://x.com/retabdev) at us.
|
57
|
+
|
58
|
+
We can't wait to see how you'll use Retab.
|
59
|
+
|
60
|
+
* [Discord](https://discord.com/invite/vc5tWRPqag)
|
61
|
+
* [Twitter](https://x.com/retabdev)
|
62
|
+
|
63
|
+
---
|
64
|
+
|
65
|
+
## Roadmap
|
66
|
+
|
67
|
+
We share our roadmap publicly on [Github](https://github.com/Retab-dev/retab)
|
68
|
+
|
69
|
+
Among the features we're working on:
|
70
|
+
|
71
|
+
* [ ] Node.js SDK
|
72
|
+
* [ ] Schema optimization autopilot
|
73
|
+
* [ ] Sources API
|
74
|
+
|
@@ -7,10 +7,9 @@ import backoff
|
|
7
7
|
import backoff.types
|
8
8
|
import httpx
|
9
9
|
import truststore
|
10
|
-
from pydantic_core import PydanticUndefined
|
11
10
|
|
12
|
-
from .resources import consensus, documents,
|
13
|
-
from .types.standards import PreparedRequest
|
11
|
+
from .resources import consensus, documents, files, finetuning, models, processors, schemas, secrets, usage, evaluations
|
12
|
+
from .types.standards import PreparedRequest, FieldUnset
|
14
13
|
|
15
14
|
|
16
15
|
class MaxRetriesExceeded(Exception):
|
@@ -34,7 +33,7 @@ class BaseRetab:
|
|
34
33
|
|
35
34
|
Args:
|
36
35
|
api_key (str, optional): Retab API key. If not provided, will look for RETAB_API_KEY env variable.
|
37
|
-
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.
|
36
|
+
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.com
|
38
37
|
timeout (float): Request timeout in seconds. Defaults to 240.0
|
39
38
|
max_retries (int): Maximum number of retries for failed requests. Defaults to 3
|
40
39
|
openai_api_key (str, optional): OpenAI API key. Will look for OPENAI_API_KEY env variable if not provided
|
@@ -43,32 +42,27 @@ class BaseRetab:
|
|
43
42
|
ValueError: If no API key is provided through arguments or environment variables
|
44
43
|
"""
|
45
44
|
|
46
|
-
# claude_api_key (str, optional): Claude API key. Will look for CLAUDE_API_KEY env variable if not provided
|
47
|
-
# xai_api_key (str, optional): XAI API key. Will look for XAI_API_KEY env variable if not provided
|
48
|
-
# gemini_api_key (str, optional): Gemini API key. Will look for GEMINI_API_KEY env variable if not provided
|
49
|
-
|
50
45
|
def __init__(
|
51
46
|
self,
|
52
47
|
api_key: Optional[str] = None,
|
53
48
|
base_url: Optional[str] = None,
|
54
49
|
timeout: float = 240.0,
|
55
50
|
max_retries: int = 3,
|
56
|
-
openai_api_key: Optional[str] =
|
57
|
-
gemini_api_key: Optional[str] =
|
58
|
-
|
59
|
-
xai_api_key: Optional[str] = PydanticUndefined, # type: ignore[assignment]
|
51
|
+
openai_api_key: Optional[str] = FieldUnset,
|
52
|
+
gemini_api_key: Optional[str] = FieldUnset,
|
53
|
+
xai_api_key: Optional[str] = FieldUnset,
|
60
54
|
) -> None:
|
61
55
|
if api_key is None:
|
62
56
|
api_key = os.environ.get("RETAB_API_KEY")
|
63
57
|
|
64
58
|
if api_key is None:
|
65
59
|
raise ValueError(
|
66
|
-
"No API key provided. You can create an API key at https://retab.
|
60
|
+
"No API key provided. You can create an API key at https://retab.com\n"
|
67
61
|
"Then either pass it to the client (api_key='your-key') or set the RETAB_API_KEY environment variable"
|
68
62
|
)
|
69
63
|
|
70
64
|
if base_url is None:
|
71
|
-
base_url = os.environ.get("RETAB_API_BASE_URL", "https://api.retab.
|
65
|
+
base_url = os.environ.get("RETAB_API_BASE_URL", "https://api.retab.com")
|
72
66
|
|
73
67
|
truststore.inject_into_ssl()
|
74
68
|
self.api_key = api_key
|
@@ -80,30 +74,21 @@ class BaseRetab:
|
|
80
74
|
"Content-Type": "application/json",
|
81
75
|
}
|
82
76
|
|
83
|
-
# Only check environment variables if the value is
|
84
|
-
if openai_api_key is
|
77
|
+
# Only check environment variables if the value is FieldUnset
|
78
|
+
if openai_api_key is FieldUnset:
|
85
79
|
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
86
80
|
|
87
|
-
|
88
|
-
# claude_api_key = os.environ.get("CLAUDE_API_KEY")
|
89
|
-
|
90
|
-
# if xai_api_key is PydanticUndefined:
|
91
|
-
# xai_api_key = os.environ.get("XAI_API_KEY")
|
92
|
-
|
93
|
-
if gemini_api_key is PydanticUndefined:
|
81
|
+
if gemini_api_key is FieldUnset:
|
94
82
|
gemini_api_key = os.environ.get("GEMINI_API_KEY")
|
95
83
|
|
96
|
-
# Only add headers if the values are actual strings (not None or
|
97
|
-
if openai_api_key and openai_api_key is not
|
84
|
+
# Only add headers if the values are actual strings (not None or FieldUnset)
|
85
|
+
if openai_api_key and openai_api_key is not FieldUnset:
|
98
86
|
self.headers["OpenAI-Api-Key"] = openai_api_key
|
99
87
|
|
100
|
-
|
101
|
-
# self.headers["Anthropic-Api-Key"] = claude_api_key
|
102
|
-
|
103
|
-
if xai_api_key and xai_api_key is not PydanticUndefined:
|
88
|
+
if xai_api_key and xai_api_key is not FieldUnset:
|
104
89
|
self.headers["XAI-Api-Key"] = xai_api_key
|
105
90
|
|
106
|
-
if gemini_api_key and gemini_api_key is not
|
91
|
+
if gemini_api_key and gemini_api_key is not FieldUnset:
|
107
92
|
self.headers["Gemini-Api-Key"] = gemini_api_key
|
108
93
|
|
109
94
|
def _prepare_url(self, endpoint: str) -> str:
|
@@ -154,12 +139,10 @@ class Retab(BaseRetab):
|
|
154
139
|
|
155
140
|
Args:
|
156
141
|
api_key (str, optional): Retab API key. If not provided, will look for RETAB_API_KEY env variable.
|
157
|
-
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.
|
142
|
+
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.com
|
158
143
|
timeout (float): Request timeout in seconds. Defaults to 240.0
|
159
144
|
max_retries (int): Maximum number of retries for failed requests. Defaults to 3
|
160
145
|
openai_api_key (str, optional): OpenAI API key. Will look for OPENAI_API_KEY env variable if not provided
|
161
|
-
claude_api_key (str, optional): Claude API key. Will look for CLAUDE_API_KEY env variable if not provided
|
162
|
-
xai_api_key (str, optional): XAI API key. Will look for XAI_API_KEY env variable if not provided
|
163
146
|
gemini_api_key (str, optional): Gemini API key. Will look for GEMINI_API_KEY env variable if not provided
|
164
147
|
|
165
148
|
Attributes:
|
@@ -179,10 +162,8 @@ class Retab(BaseRetab):
|
|
179
162
|
base_url: Optional[str] = None,
|
180
163
|
timeout: float = 240.0,
|
181
164
|
max_retries: int = 3,
|
182
|
-
openai_api_key: Optional[str] =
|
183
|
-
gemini_api_key: Optional[str] =
|
184
|
-
# claude_api_key: Optional[str] = PydanticUndefined, # type: ignore[assignment]
|
185
|
-
# xai_api_key: Optional[str] = PydanticUndefined, # type: ignore[assignment]
|
165
|
+
openai_api_key: Optional[str] = FieldUnset,
|
166
|
+
gemini_api_key: Optional[str] = FieldUnset,
|
186
167
|
) -> None:
|
187
168
|
super().__init__(
|
188
169
|
api_key=api_key,
|
@@ -191,16 +172,12 @@ class Retab(BaseRetab):
|
|
191
172
|
max_retries=max_retries,
|
192
173
|
openai_api_key=openai_api_key,
|
193
174
|
gemini_api_key=gemini_api_key,
|
194
|
-
# claude_api_key=claude_api_key,
|
195
|
-
# xai_api_key=xai_api_key,
|
196
175
|
)
|
197
176
|
|
198
177
|
self.client = httpx.Client(timeout=self.timeout)
|
199
|
-
self.evals = evals.Evals(client=self)
|
200
178
|
self.evaluations = evaluations.Evaluations(client=self)
|
201
179
|
self.files = files.Files(client=self)
|
202
180
|
self.fine_tuning = finetuning.FineTuning(client=self)
|
203
|
-
# self.prompt_optimization = prompt_optimization.PromptOptimization(client=self)
|
204
181
|
self.documents = documents.Documents(client=self)
|
205
182
|
self.models = models.Models(client=self)
|
206
183
|
self.schemas = schemas.Schemas(client=self)
|
@@ -422,7 +399,7 @@ class AsyncRetab(BaseRetab):
|
|
422
399
|
|
423
400
|
Args:
|
424
401
|
api_key (str, optional): Retab API key. If not provided, will look for RETAB_API_KEY env variable.
|
425
|
-
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.
|
402
|
+
base_url (str, optional): Base URL for API requests. Defaults to https://api.retab.com
|
426
403
|
timeout (float): Request timeout in seconds. Defaults to 240.0
|
427
404
|
max_retries (int): Maximum number of retries for failed requests. Defaults to 3
|
428
405
|
openai_api_key (str, optional): OpenAI API key. Will look for OPENAI_API_KEY env variable if not provided
|
@@ -447,10 +424,8 @@ class AsyncRetab(BaseRetab):
|
|
447
424
|
base_url: Optional[str] = None,
|
448
425
|
timeout: float = 240.0,
|
449
426
|
max_retries: int = 3,
|
450
|
-
openai_api_key: Optional[str] =
|
451
|
-
gemini_api_key: Optional[str] =
|
452
|
-
# claude_api_key: Optional[str] = PydanticUndefined, # type: ignore[assignment]
|
453
|
-
# xai_api_key: Optional[str] = PydanticUndefined, # type: ignore[assignment]
|
427
|
+
openai_api_key: Optional[str] = FieldUnset,
|
428
|
+
gemini_api_key: Optional[str] = FieldUnset,
|
454
429
|
) -> None:
|
455
430
|
super().__init__(
|
456
431
|
api_key=api_key,
|
@@ -459,17 +434,13 @@ class AsyncRetab(BaseRetab):
|
|
459
434
|
max_retries=max_retries,
|
460
435
|
openai_api_key=openai_api_key,
|
461
436
|
gemini_api_key=gemini_api_key,
|
462
|
-
# claude_api_key=claude_api_key,
|
463
|
-
# xai_api_key=xai_api_key,
|
464
437
|
)
|
465
438
|
|
466
439
|
self.client = httpx.AsyncClient(timeout=self.timeout)
|
467
440
|
|
468
|
-
self.evals = evals.AsyncEvals(client=self)
|
469
441
|
self.evaluations = evaluations.AsyncEvaluations(client=self)
|
470
442
|
self.files = files.AsyncFiles(client=self)
|
471
443
|
self.fine_tuning = finetuning.AsyncFineTuning(client=self)
|
472
|
-
# self.prompt_optimization = prompt_optimization.AsyncPromptOptimization(client=self)
|
473
444
|
self.documents = documents.AsyncDocuments(client=self)
|
474
445
|
self.models = models.AsyncModels(client=self)
|
475
446
|
self.schemas = schemas.AsyncSchemas(client=self)
|
@@ -21,7 +21,7 @@ class BaseConsensusMixin:
|
|
21
21
|
mode=mode,
|
22
22
|
)
|
23
23
|
|
24
|
-
return PreparedRequest(method="POST", url="/v1/consensus/reconcile", data=request.model_dump(), idempotency_key=idempotency_key)
|
24
|
+
return PreparedRequest(method="POST", url="/v1/consensus/reconcile", data=request.model_dump(mode="json", exclude_unset=True), idempotency_key=idempotency_key)
|
25
25
|
|
26
26
|
|
27
27
|
class Consensus(SyncAPIResource, BaseConsensusMixin):
|
@@ -123,7 +123,7 @@ class Completions(SyncAPIResource, BaseCompletionsMixin):
|
|
123
123
|
|
124
124
|
Usage:
|
125
125
|
```python
|
126
|
-
with retab.
|
126
|
+
with retab.completions.stream(json_schema, messages, model, temperature, reasoning_effort) as stream:
|
127
127
|
for response in stream:
|
128
128
|
print(response)
|
129
129
|
```
|
@@ -210,7 +210,7 @@ class AsyncCompletions(AsyncAPIResource, BaseCompletionsMixin):
|
|
210
210
|
|
211
211
|
Usage:
|
212
212
|
```python
|
213
|
-
async with retab.
|
213
|
+
async with retab.completions.stream(json_schema, messages, model, temperature, reasoning_effort, n_consensus) as stream:
|
214
214
|
async for response in stream:
|
215
215
|
print(response)
|
216
216
|
```
|
@@ -55,7 +55,7 @@ class BaseResponsesMixin:
|
|
55
55
|
instructions=instructions,
|
56
56
|
)
|
57
57
|
|
58
|
-
return PreparedRequest(method="POST", url="/v1/responses", data=request.model_dump(), idempotency_key=idempotency_key)
|
58
|
+
return PreparedRequest(method="POST", url="/v1/responses", data=request.model_dump(mode="json", exclude_unset=True), idempotency_key=idempotency_key)
|
59
59
|
|
60
60
|
def prepare_parse(
|
61
61
|
self,
|