openai-sdk-helpers 0.4.2__tar.gz → 0.5.0__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.
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/PKG-INFO +25 -11
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/README.md +21 -10
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/pyproject.toml +6 -2
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/__init__.py +45 -41
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/__init__.py +4 -6
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/base.py +110 -191
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/agent/config.py → openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/agent/configuration.py +24 -32
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/agent/coordination.py → openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/agent/coordinator.py +22 -23
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/runner.py +3 -45
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/search/base.py +54 -76
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/search/vector.py +92 -108
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/search/web.py +104 -82
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/summarizer.py +22 -28
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/translator.py +22 -24
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/agent/validation.py → openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/agent/validator.py +19 -23
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/cli.py +8 -22
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/environment.py +8 -13
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/errors.py +9 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/extract/__init__.py +23 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/extract/extractor.py +157 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/extract/generator.py +476 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/extractor_config_agent_instructions.jinja +6 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/extractor_config_generator.jinja +37 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/extractor_config_generator_instructions.jinja +9 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/extractor_prompt_optimizer_agent_instructions.jinja +4 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/extractor_prompt_optimizer_request.jinja +11 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/vector_planner.jinja +7 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/vector_search.jinja +6 -0
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/prompt/vector_writer.jinja +7 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/__init__.py +3 -7
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/base.py +89 -98
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/response/config.py → openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/response/configuration.py +45 -20
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/files.py +2 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/planner.py +1 -1
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/prompter.py +1 -1
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/runner.py +1 -48
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/response/tool_call.py +93 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/vector_store.py +8 -5
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/streamlit_app/__init__.py +1 -1
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/streamlit_app/app.py +17 -18
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/streamlit_app/config.py → openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/streamlit_app/configuration.py +13 -13
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/__init__.py +16 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/base.py +239 -278
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/structure/extraction.py +1228 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/plan.py +0 -20
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/task.py +0 -33
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/prompt.py +16 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/responses.py +2 -2
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/web_search.py +0 -10
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/tools.py +569 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/types.py +3 -3
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/__init__.py +9 -6
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/utils/json/base_model.py +464 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/json/data_class.py +1 -1
- openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/utils/langextract.py +194 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/registry.py +19 -15
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/vector_storage/storage.py +1 -1
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/agent/prompt_utils.py +0 -15
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/context_manager.py +0 -241
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/deprecation.py +0 -167
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/response/tool_call.py +0 -234
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/retry.py +0 -175
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/streamlit_app/streamlit_web_search.py +0 -75
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/tools.py +0 -322
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/utils/deprecation.py +0 -167
- openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/utils/json/base_model.py +0 -181
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/.gitignore +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/LICENSE +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/search/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/utils.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/enums/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/enums/base.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/files_api.py +0 -0
- /openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/logging_config.py → /openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/logging.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/prompt/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/prompt/base.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/prompt/summarizer.jinja +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/prompt/translator.jinja +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/prompt/validator.jinja +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/py.typed +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/response/messages.py +0 -0
- /openai_sdk_helpers-0.4.2/src/openai_sdk_helpers/config.py → /openai_sdk_helpers-0.5.0/src/openai_sdk_helpers/settings.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/agent_blueprint.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/enum.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/helpers.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/plan/types.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/summary.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/translation.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/validation.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/structure/vector_search.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/async_utils.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/coercion.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/encoding.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/instructions.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/json/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/json/ref.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/json/utils.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/output_validation.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/path_utils.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/utils/validation.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/vector_storage/__init__.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/vector_storage/cleanup.py +0 -0
- {openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/vector_storage/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: openai-sdk-helpers
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.5.0
|
|
4
4
|
Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
|
|
5
5
|
Author: openai-sdk-helpers maintainers
|
|
6
6
|
License: MIT
|
|
@@ -17,6 +17,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
|
17
17
|
Classifier: Typing :: Typed
|
|
18
18
|
Requires-Python: >=3.10
|
|
19
19
|
Requires-Dist: jinja2
|
|
20
|
+
Requires-Dist: langextract
|
|
20
21
|
Requires-Dist: openai-agents<1.0.0,>=0.6.4
|
|
21
22
|
Requires-Dist: openai<3.0.0,>=2.14.0
|
|
22
23
|
Requires-Dist: pydantic<3,>=2.7
|
|
@@ -31,6 +32,8 @@ Requires-Dist: pyright; extra == 'dev'
|
|
|
31
32
|
Requires-Dist: pytest; extra == 'dev'
|
|
32
33
|
Requires-Dist: pytest-asyncio; extra == 'dev'
|
|
33
34
|
Requires-Dist: pytest-cov; extra == 'dev'
|
|
35
|
+
Provides-Extra: extract
|
|
36
|
+
Requires-Dist: langextract; extra == 'extract'
|
|
34
37
|
Description-Content-Type: text/markdown
|
|
35
38
|
|
|
36
39
|
<div align="center">
|
|
@@ -78,7 +81,7 @@ structures, configuration helpers, and orchestration utilities—while leaving
|
|
|
78
81
|
application-specific prompts and tools to the consuming project.
|
|
79
82
|
|
|
80
83
|
**Important**: This library integrates with **two distinct OpenAI SDKs**:
|
|
81
|
-
- **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling
|
|
84
|
+
- **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling
|
|
82
85
|
- **`openai`** - Used by the `response` module for direct API interactions with fine-grained control over responses
|
|
83
86
|
|
|
84
87
|
The `agent` module provides a higher-level abstraction for building agents, while the `response` module offers lower-level control for custom response handling workflows.
|
|
@@ -193,10 +196,11 @@ report = vector_search.run_agent_sync("Explain quantum entanglement for beginner
|
|
|
193
196
|
print(report.report)
|
|
194
197
|
```
|
|
195
198
|
|
|
196
|
-
**Note**: The vector search workflow
|
|
197
|
-
(`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`).
|
|
198
|
-
|
|
199
|
-
|
|
199
|
+
**Note**: The vector search workflow ships with default prompt templates
|
|
200
|
+
(`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`).
|
|
201
|
+
You only need to pass a `prompt_dir` when you want to override them; if the
|
|
202
|
+
directory you supply is missing any of the templates, agent construction will
|
|
203
|
+
fail with a `FileNotFoundError`.
|
|
200
204
|
|
|
201
205
|
### Text utilities
|
|
202
206
|
|
|
@@ -301,7 +305,7 @@ response.close()
|
|
|
301
305
|
```
|
|
302
306
|
|
|
303
307
|
**Key Differences:**
|
|
304
|
-
- **Agent Module**: Higher-level abstraction with
|
|
308
|
+
- **Agent Module**: Higher-level abstraction with automatic tool handling and agent-specific workflows
|
|
305
309
|
- **Response Module**: Lower-level control with manual message management, custom tool handlers, and direct API access
|
|
306
310
|
|
|
307
311
|
## Advanced Usage
|
|
@@ -510,7 +514,7 @@ src/openai_sdk_helpers/
|
|
|
510
514
|
│ ├── summary.py # Summary output structures
|
|
511
515
|
│ └── validation.py # Validation result structures
|
|
512
516
|
├── vector_storage/ # Vector store abstraction layer
|
|
513
|
-
├──
|
|
517
|
+
├── configuration.py # OpenAI settings and configuration
|
|
514
518
|
└── utils/ # JSON serialization, logging, and helpers
|
|
515
519
|
|
|
516
520
|
tests/ # Comprehensive unit test suite
|
|
@@ -522,7 +526,7 @@ The package is organized around cohesive, reusable building blocks:
|
|
|
522
526
|
|
|
523
527
|
### Agent Modules (Built on `openai-agents` SDK)
|
|
524
528
|
|
|
525
|
-
These modules use the `openai-agents` SDK for high-level agent workflows with automatic
|
|
529
|
+
These modules use the `openai-agents` SDK for high-level agent workflows with automatic tool handling and conversation management.
|
|
526
530
|
|
|
527
531
|
- **`openai_sdk_helpers.agent.base.AgentBase`**
|
|
528
532
|
Base class for all agents with synchronous and asynchronous execution support.
|
|
@@ -562,7 +566,7 @@ These modules use the standard `openai` SDK for direct API interactions with fin
|
|
|
562
566
|
|
|
563
567
|
### Configuration and Data Structures (Shared)
|
|
564
568
|
|
|
565
|
-
- **`openai_sdk_helpers.
|
|
569
|
+
- **`openai_sdk_helpers.settings.OpenAISettings`**
|
|
566
570
|
Centralizes OpenAI API configuration with environment variable support.
|
|
567
571
|
Creates configured OpenAI clients with consistent settings.
|
|
568
572
|
|
|
@@ -584,6 +588,17 @@ These modules use the standard `openai` SDK for direct API interactions with fin
|
|
|
584
588
|
- **`openai_sdk_helpers.utils`**
|
|
585
589
|
JSON serialization helpers, logging utilities, and common validation functions.
|
|
586
590
|
|
|
591
|
+
- **`openai_sdk_helpers.utils.langextract`**
|
|
592
|
+
Adapter helpers for running LangExtract-style extractors and validating the
|
|
593
|
+
results into Pydantic models.
|
|
594
|
+
|
|
595
|
+
## Related Projects
|
|
596
|
+
|
|
597
|
+
- **[LangExtract](https://github.com/google/langextract)**
|
|
598
|
+
Google-maintained toolkit for extracting structured data from language model
|
|
599
|
+
outputs, which can complement the validation and response utilities in
|
|
600
|
+
`openai-sdk-helpers`.
|
|
601
|
+
|
|
587
602
|
## Contributing
|
|
588
603
|
|
|
589
604
|
Contributions are welcome! We appreciate functional changes accompanied by
|
|
@@ -696,4 +711,3 @@ recognizing types:
|
|
|
696
711
|
- Check the [Key Modules](#key-modules) section for API documentation
|
|
697
712
|
- Review examples in the [Quickstart](#quickstart) and [Advanced Usage](#advanced-usage) sections
|
|
698
713
|
- Open an issue on GitHub for bugs or feature requests
|
|
699
|
-
|
|
@@ -43,7 +43,7 @@ structures, configuration helpers, and orchestration utilities—while leaving
|
|
|
43
43
|
application-specific prompts and tools to the consuming project.
|
|
44
44
|
|
|
45
45
|
**Important**: This library integrates with **two distinct OpenAI SDKs**:
|
|
46
|
-
- **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling
|
|
46
|
+
- **`openai-agents`** - Used by the `agent` module for high-level agent workflows with automatic tool handling
|
|
47
47
|
- **`openai`** - Used by the `response` module for direct API interactions with fine-grained control over responses
|
|
48
48
|
|
|
49
49
|
The `agent` module provides a higher-level abstraction for building agents, while the `response` module offers lower-level control for custom response handling workflows.
|
|
@@ -158,10 +158,11 @@ report = vector_search.run_agent_sync("Explain quantum entanglement for beginner
|
|
|
158
158
|
print(report.report)
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
**Note**: The vector search workflow
|
|
162
|
-
(`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`).
|
|
163
|
-
|
|
164
|
-
|
|
161
|
+
**Note**: The vector search workflow ships with default prompt templates
|
|
162
|
+
(`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`).
|
|
163
|
+
You only need to pass a `prompt_dir` when you want to override them; if the
|
|
164
|
+
directory you supply is missing any of the templates, agent construction will
|
|
165
|
+
fail with a `FileNotFoundError`.
|
|
165
166
|
|
|
166
167
|
### Text utilities
|
|
167
168
|
|
|
@@ -266,7 +267,7 @@ response.close()
|
|
|
266
267
|
```
|
|
267
268
|
|
|
268
269
|
**Key Differences:**
|
|
269
|
-
- **Agent Module**: Higher-level abstraction with
|
|
270
|
+
- **Agent Module**: Higher-level abstraction with automatic tool handling and agent-specific workflows
|
|
270
271
|
- **Response Module**: Lower-level control with manual message management, custom tool handlers, and direct API access
|
|
271
272
|
|
|
272
273
|
## Advanced Usage
|
|
@@ -475,7 +476,7 @@ src/openai_sdk_helpers/
|
|
|
475
476
|
│ ├── summary.py # Summary output structures
|
|
476
477
|
│ └── validation.py # Validation result structures
|
|
477
478
|
├── vector_storage/ # Vector store abstraction layer
|
|
478
|
-
├──
|
|
479
|
+
├── configuration.py # OpenAI settings and configuration
|
|
479
480
|
└── utils/ # JSON serialization, logging, and helpers
|
|
480
481
|
|
|
481
482
|
tests/ # Comprehensive unit test suite
|
|
@@ -487,7 +488,7 @@ The package is organized around cohesive, reusable building blocks:
|
|
|
487
488
|
|
|
488
489
|
### Agent Modules (Built on `openai-agents` SDK)
|
|
489
490
|
|
|
490
|
-
These modules use the `openai-agents` SDK for high-level agent workflows with automatic
|
|
491
|
+
These modules use the `openai-agents` SDK for high-level agent workflows with automatic tool handling and conversation management.
|
|
491
492
|
|
|
492
493
|
- **`openai_sdk_helpers.agent.base.AgentBase`**
|
|
493
494
|
Base class for all agents with synchronous and asynchronous execution support.
|
|
@@ -527,7 +528,7 @@ These modules use the standard `openai` SDK for direct API interactions with fin
|
|
|
527
528
|
|
|
528
529
|
### Configuration and Data Structures (Shared)
|
|
529
530
|
|
|
530
|
-
- **`openai_sdk_helpers.
|
|
531
|
+
- **`openai_sdk_helpers.settings.OpenAISettings`**
|
|
531
532
|
Centralizes OpenAI API configuration with environment variable support.
|
|
532
533
|
Creates configured OpenAI clients with consistent settings.
|
|
533
534
|
|
|
@@ -549,6 +550,17 @@ These modules use the standard `openai` SDK for direct API interactions with fin
|
|
|
549
550
|
- **`openai_sdk_helpers.utils`**
|
|
550
551
|
JSON serialization helpers, logging utilities, and common validation functions.
|
|
551
552
|
|
|
553
|
+
- **`openai_sdk_helpers.utils.langextract`**
|
|
554
|
+
Adapter helpers for running LangExtract-style extractors and validating the
|
|
555
|
+
results into Pydantic models.
|
|
556
|
+
|
|
557
|
+
## Related Projects
|
|
558
|
+
|
|
559
|
+
- **[LangExtract](https://github.com/google/langextract)**
|
|
560
|
+
Google-maintained toolkit for extracting structured data from language model
|
|
561
|
+
outputs, which can complement the validation and response utilities in
|
|
562
|
+
`openai-sdk-helpers`.
|
|
563
|
+
|
|
552
564
|
## Contributing
|
|
553
565
|
|
|
554
566
|
Contributions are welcome! We appreciate functional changes accompanied by
|
|
@@ -661,4 +673,3 @@ recognizing types:
|
|
|
661
673
|
- Check the [Key Modules](#key-modules) section for API documentation
|
|
662
674
|
- Review examples in the [Quickstart](#quickstart) and [Advanced Usage](#advanced-usage) sections
|
|
663
675
|
- Open an issue on GitHub for bugs or feature requests
|
|
664
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "openai-sdk-helpers"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.5.0"
|
|
4
4
|
requires-python = ">=3.10"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
description = "Composable helpers for OpenAI SDK agents, prompts, and storage"
|
|
@@ -36,7 +36,8 @@ dependencies = [
|
|
|
36
36
|
# OpenAI functionality (tested with openai==2.14.0, openai-agents==0.6.4)
|
|
37
37
|
"openai>=2.14.0,<3.0.0",
|
|
38
38
|
"openai-agents>=0.6.4,<1.0.0",
|
|
39
|
-
|
|
39
|
+
# Language extraction
|
|
40
|
+
"langextract",
|
|
40
41
|
|
|
41
42
|
# Web UI
|
|
42
43
|
"streamlit",
|
|
@@ -57,6 +58,9 @@ dev = [
|
|
|
57
58
|
"pytest",
|
|
58
59
|
"pytest-asyncio",
|
|
59
60
|
]
|
|
61
|
+
extract = [
|
|
62
|
+
"langextract",
|
|
63
|
+
]
|
|
60
64
|
|
|
61
65
|
[build-system]
|
|
62
66
|
requires = ["hatchling"]
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from .environment import get_data_path
|
|
5
|
+
from .environment import get_data_path
|
|
6
6
|
from .utils.async_utils import run_coroutine_thread_safe, run_coroutine_with_fallback
|
|
7
|
-
|
|
8
|
-
AsyncManagedResource,
|
|
9
|
-
ManagedResource,
|
|
10
|
-
async_context,
|
|
11
|
-
ensure_closed,
|
|
12
|
-
ensure_closed_async,
|
|
13
|
-
)
|
|
7
|
+
|
|
14
8
|
from .errors import (
|
|
15
9
|
OpenAISDKError,
|
|
16
10
|
ConfigurationError,
|
|
@@ -22,8 +16,9 @@ from .errors import (
|
|
|
22
16
|
InputValidationError,
|
|
23
17
|
AsyncExecutionError,
|
|
24
18
|
ResourceCleanupError,
|
|
19
|
+
ExtractionError,
|
|
25
20
|
)
|
|
26
|
-
|
|
21
|
+
|
|
27
22
|
from .utils.validation import (
|
|
28
23
|
validate_choice,
|
|
29
24
|
validate_dict_mapping,
|
|
@@ -46,12 +41,17 @@ from .structure import (
|
|
|
46
41
|
ExtendedSummaryStructure,
|
|
47
42
|
ValidationResultStructure,
|
|
48
43
|
AgentBlueprint,
|
|
44
|
+
AnnotatedDocumentStructure,
|
|
45
|
+
AttributeStructure,
|
|
46
|
+
DocumentStructure,
|
|
47
|
+
ExampleDataStructure,
|
|
48
|
+
ExtractionStructure,
|
|
49
49
|
create_plan,
|
|
50
50
|
execute_task,
|
|
51
51
|
execute_plan,
|
|
52
52
|
)
|
|
53
53
|
from .prompt import PromptRenderer
|
|
54
|
-
from .
|
|
54
|
+
from .settings import OpenAISettings
|
|
55
55
|
from .files_api import FilesAPIManager, FilePurpose
|
|
56
56
|
from .vector_storage import VectorStorage, VectorStorageFileInfo, VectorStorageFileStats
|
|
57
57
|
from .agent import (
|
|
@@ -73,22 +73,17 @@ from .response import (
|
|
|
73
73
|
ResponseConfiguration,
|
|
74
74
|
ResponseRegistry,
|
|
75
75
|
get_default_registry,
|
|
76
|
-
parse_tool_arguments,
|
|
77
76
|
attach_vector_store,
|
|
78
77
|
)
|
|
79
78
|
from .tools import (
|
|
80
|
-
serialize_tool_result,
|
|
81
79
|
tool_handler_factory,
|
|
82
80
|
StructureType,
|
|
81
|
+
ToolHandler,
|
|
82
|
+
ToolHandlerRegistration,
|
|
83
83
|
ToolSpec,
|
|
84
|
-
|
|
85
|
-
)
|
|
86
|
-
from .config import build_openai_settings
|
|
87
|
-
from .utils.deprecation import (
|
|
88
|
-
deprecated,
|
|
89
|
-
warn_deprecated,
|
|
90
|
-
DeprecationHelper,
|
|
84
|
+
build_tool_definition_list,
|
|
91
85
|
)
|
|
86
|
+
from .settings import build_openai_settings
|
|
92
87
|
from .utils.output_validation import (
|
|
93
88
|
ValidationResult,
|
|
94
89
|
ValidationRule,
|
|
@@ -98,15 +93,21 @@ from .utils.output_validation import (
|
|
|
98
93
|
OutputValidator,
|
|
99
94
|
validate_output,
|
|
100
95
|
)
|
|
101
|
-
from .
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
from .utils.langextract import LangExtractAdapter, build_langextract_adapter
|
|
97
|
+
from .extract import (
|
|
98
|
+
DocumentExtractor,
|
|
99
|
+
EXTRACTOR_CONFIG_AGENT_INSTRUCTIONS,
|
|
100
|
+
EXTRACTOR_CONFIG_GENERATOR,
|
|
101
|
+
PROMPT_OPTIMIZER_AGENT_INSTRUCTIONS,
|
|
102
|
+
generate_document_extractor_config,
|
|
103
|
+
generate_document_extractor_config_with_agent,
|
|
104
|
+
optimize_extractor_prompt,
|
|
105
|
+
optimize_extractor_prompt_with_agent,
|
|
104
106
|
)
|
|
105
107
|
|
|
106
108
|
__all__ = [
|
|
107
109
|
# Environment utilities
|
|
108
110
|
"get_data_path",
|
|
109
|
-
"get_model",
|
|
110
111
|
# Async utilities
|
|
111
112
|
"run_coroutine_thread_safe",
|
|
112
113
|
"run_coroutine_with_fallback",
|
|
@@ -121,14 +122,7 @@ __all__ = [
|
|
|
121
122
|
"InputValidationError",
|
|
122
123
|
"AsyncExecutionError",
|
|
123
124
|
"ResourceCleanupError",
|
|
124
|
-
|
|
125
|
-
"with_exponential_backoff",
|
|
126
|
-
# Context managers
|
|
127
|
-
"ManagedResource",
|
|
128
|
-
"AsyncManagedResource",
|
|
129
|
-
"ensure_closed",
|
|
130
|
-
"ensure_closed_async",
|
|
131
|
-
"async_context",
|
|
125
|
+
"ExtractionError",
|
|
132
126
|
# Validation
|
|
133
127
|
"validate_non_empty_string",
|
|
134
128
|
"validate_max_length",
|
|
@@ -166,6 +160,11 @@ __all__ = [
|
|
|
166
160
|
"WebSearchStructure",
|
|
167
161
|
"VectorSearchStructure",
|
|
168
162
|
"ValidationResultStructure",
|
|
163
|
+
"AnnotatedDocumentStructure",
|
|
164
|
+
"AttributeStructure",
|
|
165
|
+
"DocumentStructure",
|
|
166
|
+
"ExampleDataStructure",
|
|
167
|
+
"ExtractionStructure",
|
|
169
168
|
"ResponseBase",
|
|
170
169
|
"ResponseMessage",
|
|
171
170
|
"ResponseMessages",
|
|
@@ -173,24 +172,17 @@ __all__ = [
|
|
|
173
172
|
"ResponseConfiguration",
|
|
174
173
|
"ResponseRegistry",
|
|
175
174
|
"get_default_registry",
|
|
176
|
-
"parse_tool_arguments",
|
|
177
175
|
"attach_vector_store",
|
|
178
|
-
"serialize_tool_result",
|
|
179
176
|
"tool_handler_factory",
|
|
180
177
|
"StructureType",
|
|
178
|
+
"ToolHandler",
|
|
179
|
+
"ToolHandlerRegistration",
|
|
181
180
|
"ToolSpec",
|
|
182
|
-
"
|
|
181
|
+
"build_tool_definition_list",
|
|
183
182
|
"build_openai_settings",
|
|
184
183
|
"create_plan",
|
|
185
184
|
"execute_task",
|
|
186
185
|
"execute_plan",
|
|
187
|
-
# Type definitions
|
|
188
|
-
"SupportsOpenAIClient",
|
|
189
|
-
"OpenAIClient",
|
|
190
|
-
# Deprecation utilities
|
|
191
|
-
"deprecated",
|
|
192
|
-
"warn_deprecated",
|
|
193
|
-
"DeprecationHelper",
|
|
194
186
|
# Output validation
|
|
195
187
|
"ValidationResult",
|
|
196
188
|
"ValidationRule",
|
|
@@ -199,4 +191,16 @@ __all__ = [
|
|
|
199
191
|
"LengthValidator",
|
|
200
192
|
"OutputValidator",
|
|
201
193
|
"validate_output",
|
|
194
|
+
# LangExtract
|
|
195
|
+
"LangExtractAdapter",
|
|
196
|
+
"build_langextract_adapter",
|
|
197
|
+
# Extraction helpers
|
|
198
|
+
"DocumentExtractor",
|
|
199
|
+
"EXTRACTOR_CONFIG_AGENT_INSTRUCTIONS",
|
|
200
|
+
"EXTRACTOR_CONFIG_GENERATOR",
|
|
201
|
+
"PROMPT_OPTIMIZER_AGENT_INSTRUCTIONS",
|
|
202
|
+
"generate_document_extractor_config",
|
|
203
|
+
"generate_document_extractor_config_with_agent",
|
|
204
|
+
"optimize_extractor_prompt",
|
|
205
|
+
"optimize_extractor_prompt_with_agent",
|
|
202
206
|
]
|
{openai_sdk_helpers-0.4.2 → openai_sdk_helpers-0.5.0}/src/openai_sdk_helpers/agent/__init__.py
RENAMED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"""Shared agent helpers built on the OpenAI Agents SDK."""
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
|
-
|
|
5
4
|
from .base import AgentBase
|
|
6
|
-
from .
|
|
5
|
+
from .configuration import AgentConfiguration, AgentRegistry, get_default_registry
|
|
7
6
|
from ..structure.plan.enum import AgentEnum
|
|
8
|
-
from .
|
|
9
|
-
from .runner import run_sync, run_async
|
|
7
|
+
from .coordinator import CoordinatorAgent
|
|
8
|
+
from .runner import run_sync, run_async
|
|
10
9
|
from .search.base import SearchPlanner, SearchToolAgent, SearchWriter
|
|
11
10
|
from .summarizer import SummarizerAgent
|
|
12
11
|
from .translator import TranslatorAgent
|
|
13
|
-
from .
|
|
12
|
+
from .validator import ValidatorAgent
|
|
14
13
|
from .utils import run_coroutine_agent_sync
|
|
15
14
|
from .search.vector import VectorAgentSearch
|
|
16
15
|
from .search.web import WebAgentSearch
|
|
@@ -24,7 +23,6 @@ __all__ = [
|
|
|
24
23
|
"CoordinatorAgent",
|
|
25
24
|
"run_sync",
|
|
26
25
|
"run_async",
|
|
27
|
-
"run_streamed",
|
|
28
26
|
"run_coroutine_agent_sync",
|
|
29
27
|
"SearchPlanner",
|
|
30
28
|
"SearchToolAgent",
|