openai-sdk-helpers 0.0.8__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.0.8/.gitignore +210 -0
- openai_sdk_helpers-0.0.8/LICENSE +21 -0
- openai_sdk_helpers-0.0.8/PKG-INFO +194 -0
- openai_sdk_helpers-0.0.8/README.md +177 -0
- openai_sdk_helpers-0.0.8/pyproject.toml +69 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/__init__.py +73 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/__init__.py +31 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/base.py +330 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/config.py +66 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/project_manager.py +511 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/prompt_utils.py +9 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/runner.py +215 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/summarizer.py +85 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/translator.py +139 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/utils.py +47 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/validation.py +97 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/vector_search.py +462 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/agent/web_search.py +403 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/config.py +199 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/enums/__init__.py +7 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/enums/base.py +29 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/environment.py +27 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/prompt/__init__.py +77 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/prompt/summarizer.jinja +7 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/prompt/translator.jinja +7 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/prompt/validator.jinja +7 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/py.typed +0 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/__init__.py +20 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/base.py +590 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/messages.py +259 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/runner.py +104 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/tool_call.py +109 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/response/vector_store.py +84 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/streamlit_app/__init__.py +13 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/streamlit_app/app.py +270 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/streamlit_app/configuration.py +324 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/streamlit_app/streamlit_web_search.py +69 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/__init__.py +43 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/agent_blueprint.py +224 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/base.py +752 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/plan/__init__.py +13 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/plan/enum.py +64 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/plan/plan.py +253 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/plan/task.py +122 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/prompt.py +24 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/responses.py +132 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/summary.py +65 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/validation.py +47 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/vector_search.py +86 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/structure/web_search.py +50 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/utils/__init__.py +27 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/utils/core.py +334 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/vector_storage/__init__.py +15 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/vector_storage/cleanup.py +91 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/vector_storage/storage.py +563 -0
- openai_sdk_helpers-0.0.8/src/openai_sdk_helpers/vector_storage/types.py +58 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
.python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
|
|
209
|
+
scratch/**
|
|
210
|
+
data/**
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 fatmambo33
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: openai-sdk-helpers
|
|
3
|
+
Version: 0.0.8
|
|
4
|
+
Summary: Composable helpers for OpenAI SDK agents, prompts, and storage
|
|
5
|
+
Author: openai-sdk-helpers maintainers
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.10
|
|
9
|
+
Requires-Dist: jinja2
|
|
10
|
+
Requires-Dist: openai
|
|
11
|
+
Requires-Dist: openai-agents
|
|
12
|
+
Requires-Dist: pydantic<3,>=2.7
|
|
13
|
+
Requires-Dist: python-dotenv
|
|
14
|
+
Requires-Dist: streamlit
|
|
15
|
+
Requires-Dist: typing-extensions<5,>=4.15.0
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
<div align="center">
|
|
19
|
+
|
|
20
|
+
# openai-sdk-helpers
|
|
21
|
+
|
|
22
|
+
Shared primitives for composing OpenAI agent workflows: structures, response
|
|
23
|
+
handling, prompt rendering, and reusable agent factories.
|
|
24
|
+
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
## Overview
|
|
28
|
+
|
|
29
|
+
`openai-sdk-helpers` packages the common building blocks required to assemble agent-driven
|
|
30
|
+
applications. The library intentionally focuses on reusable primitives—data
|
|
31
|
+
structures, configuration helpers, and orchestration utilities—while leaving
|
|
32
|
+
application-specific prompts and tools to the consuming project.
|
|
33
|
+
|
|
34
|
+
### Features
|
|
35
|
+
|
|
36
|
+
- **Agent wrappers** for OpenAI Agents SDK with synchronous and asynchronous
|
|
37
|
+
entry points.
|
|
38
|
+
- **Prompt rendering** powered by Jinja for dynamic agent instructions.
|
|
39
|
+
- **Typed structures** for prompts, responses, and search workflows to ensure
|
|
40
|
+
predictable inputs and outputs.
|
|
41
|
+
- **Vector and web search flows** that coordinate planning, execution, and
|
|
42
|
+
reporting.
|
|
43
|
+
- **Reusable text agents** for summarization and translation tasks.
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
Install the package directly from PyPI to reuse it across projects:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pip install openai-sdk-helpers
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Type information ships with the published wheel via `py.typed`, so external
|
|
54
|
+
projects can rely on the bundled annotations without adding custom stubs.
|
|
55
|
+
|
|
56
|
+
For local development, install with editable sources and the optional dev
|
|
57
|
+
dependencies:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pip install -e .
|
|
61
|
+
pip install -e . --group dev
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quickstart
|
|
65
|
+
|
|
66
|
+
Create a basic vector search workflow by wiring your own prompt templates and
|
|
67
|
+
preferred model configuration:
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from pathlib import Path
|
|
71
|
+
|
|
72
|
+
from openai_sdk_helpers.agent.vector_search import VectorSearch
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
prompts = Path("./prompts")
|
|
76
|
+
vector_search = VectorSearch(prompt_dir=prompts, default_model="gpt-4o-mini")
|
|
77
|
+
|
|
78
|
+
report = vector_search.run_agent_sync("Explain quantum entanglement for beginners")
|
|
79
|
+
print(report.report)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Text utilities
|
|
83
|
+
|
|
84
|
+
Use the built-in text helpers when you need lightweight single-step agents.
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from openai_sdk_helpers.agent import (
|
|
88
|
+
SummarizerAgent,
|
|
89
|
+
TranslatorAgent,
|
|
90
|
+
ValidatorAgent,
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
summarizer = SummarizerAgent(default_model="gpt-4o-mini")
|
|
95
|
+
translator = TranslatorAgent(default_model="gpt-4o-mini")
|
|
96
|
+
validator = ValidatorAgent(default_model="gpt-4o-mini")
|
|
97
|
+
|
|
98
|
+
summary = summarizer.run_sync("Long-form content to condense")
|
|
99
|
+
translation = translator.run_sync("Bonjour", target_language="English")
|
|
100
|
+
guardrails = validator.run_sync(
|
|
101
|
+
"Share meeting notes with names removed", agent_output=summary.text
|
|
102
|
+
)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
Prompt templates are optional for the built-in text helpers. They already ship
|
|
106
|
+
with defaults under `src/openai_sdk_helpers/prompt`, so you do **not** need to
|
|
107
|
+
create placeholder files when installing from PyPI. Only pass a `prompt_dir`
|
|
108
|
+
when you have real replacements you want to load.
|
|
109
|
+
|
|
110
|
+
The vector search workflow expects real prompts for each agent (for example,
|
|
111
|
+
`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`). If
|
|
112
|
+
you point `prompt_dir` at a folder that does not contain those files, agent
|
|
113
|
+
construction fails with a `FileNotFoundError`. Skip `prompt_dir` entirely unless
|
|
114
|
+
you have working templates ready.
|
|
115
|
+
|
|
116
|
+
### Centralized OpenAI configuration
|
|
117
|
+
|
|
118
|
+
`openai-sdk-helpers` ships with a lightweight `OpenAISettings` helper so projects can share
|
|
119
|
+
consistent authentication, routing, and model defaults when using the OpenAI
|
|
120
|
+
SDK:
|
|
121
|
+
|
|
122
|
+
```python
|
|
123
|
+
from openai_sdk_helpers import OpenAISettings
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
# Load from environment variables or a local .env file
|
|
127
|
+
settings = OpenAISettings.from_env()
|
|
128
|
+
client = settings.create_client()
|
|
129
|
+
|
|
130
|
+
# Reuse the default model across agents
|
|
131
|
+
vector_search = VectorSearch(
|
|
132
|
+
prompt_dir=prompts, default_model=settings.default_model or "gpt-4o-mini"
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
The helper reads `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`,
|
|
137
|
+
`OPENAI_BASE_URL`, `OPENAI_MODEL`, `OPENAI_TIMEOUT`, and `OPENAI_MAX_RETRIES` by
|
|
138
|
+
default but supports overrides for custom deployments. Pass uncommon OpenAI
|
|
139
|
+
client keyword arguments (such as `default_headers`, `http_client`, or
|
|
140
|
+
`base_url` proxies) through `extra_client_kwargs` when instantiating
|
|
141
|
+
`OpenAISettings`.
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
The repository is configured for a lightweight Python development workflow.
|
|
146
|
+
Before opening a pull request, format and validate your changes locally:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
# Style and formatting
|
|
150
|
+
pydocstyle src
|
|
151
|
+
black --check .
|
|
152
|
+
|
|
153
|
+
# Static type checking
|
|
154
|
+
pyright src
|
|
155
|
+
|
|
156
|
+
# Unit tests with coverage
|
|
157
|
+
pytest -q --cov=src --cov-report=term-missing --cov-fail-under=70
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Project Structure
|
|
161
|
+
|
|
162
|
+
- `src/openai_sdk_helpers/agent`: Agent factories, orchestration helpers, and search
|
|
163
|
+
workflows.
|
|
164
|
+
- `src/openai_sdk_helpers/prompt`: Prompt rendering utilities backed by Jinja.
|
|
165
|
+
- `src/openai_sdk_helpers/response`: Response parsing and transformation helpers.
|
|
166
|
+
- `src/openai_sdk_helpers/structure`: Typed data structures shared across workflows.
|
|
167
|
+
- `src/openai_sdk_helpers/vector_storage`: Minimal vector store abstraction.
|
|
168
|
+
- `tests/`: Unit tests covering core modules and structures.
|
|
169
|
+
|
|
170
|
+
## Key modules
|
|
171
|
+
|
|
172
|
+
The package centers around a handful of cohesive building blocks:
|
|
173
|
+
|
|
174
|
+
- `openai_sdk_helpers.agent.project_manager.ProjectManager` coordinates prompt
|
|
175
|
+
creation, plan building, task execution, and summarization while persisting
|
|
176
|
+
intermediate artifacts to disk.
|
|
177
|
+
- `openai_sdk_helpers.agent.vector_search.VectorSearch` bundles the planners,
|
|
178
|
+
executors, and summarizers required to run a multi-turn vector search flow
|
|
179
|
+
from a single entry point.
|
|
180
|
+
- `openai_sdk_helpers.agent.summarizer.SummarizerAgent`,
|
|
181
|
+
`agent.translator.TranslatorAgent`, and `agent.validator.ValidatorAgent`
|
|
182
|
+
expose streamlined text-processing utilities that reuse shared prompt
|
|
183
|
+
templates.
|
|
184
|
+
- `openai_sdk_helpers.response` contains the response runners and helpers used
|
|
185
|
+
to normalize outputs from agents, including streaming responses.
|
|
186
|
+
- `openai_sdk_helpers.utils` holds JSON serialization helpers, logging
|
|
187
|
+
utilities, and common validation helpers used across modules.
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
Contributions are welcome! Please accompany functional changes with relevant
|
|
192
|
+
tests and ensure all quality gates pass. Follow the NumPy-style docstring
|
|
193
|
+
conventions outlined in `AGENTS.md` to keep the codebase consistent.
|
|
194
|
+
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# openai-sdk-helpers
|
|
4
|
+
|
|
5
|
+
Shared primitives for composing OpenAI agent workflows: structures, response
|
|
6
|
+
handling, prompt rendering, and reusable agent factories.
|
|
7
|
+
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
## Overview
|
|
11
|
+
|
|
12
|
+
`openai-sdk-helpers` packages the common building blocks required to assemble agent-driven
|
|
13
|
+
applications. The library intentionally focuses on reusable primitives—data
|
|
14
|
+
structures, configuration helpers, and orchestration utilities—while leaving
|
|
15
|
+
application-specific prompts and tools to the consuming project.
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
- **Agent wrappers** for OpenAI Agents SDK with synchronous and asynchronous
|
|
20
|
+
entry points.
|
|
21
|
+
- **Prompt rendering** powered by Jinja for dynamic agent instructions.
|
|
22
|
+
- **Typed structures** for prompts, responses, and search workflows to ensure
|
|
23
|
+
predictable inputs and outputs.
|
|
24
|
+
- **Vector and web search flows** that coordinate planning, execution, and
|
|
25
|
+
reporting.
|
|
26
|
+
- **Reusable text agents** for summarization and translation tasks.
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
Install the package directly from PyPI to reuse it across projects:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install openai-sdk-helpers
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Type information ships with the published wheel via `py.typed`, so external
|
|
37
|
+
projects can rely on the bundled annotations without adding custom stubs.
|
|
38
|
+
|
|
39
|
+
For local development, install with editable sources and the optional dev
|
|
40
|
+
dependencies:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e .
|
|
44
|
+
pip install -e . --group dev
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Quickstart
|
|
48
|
+
|
|
49
|
+
Create a basic vector search workflow by wiring your own prompt templates and
|
|
50
|
+
preferred model configuration:
|
|
51
|
+
|
|
52
|
+
```python
|
|
53
|
+
from pathlib import Path
|
|
54
|
+
|
|
55
|
+
from openai_sdk_helpers.agent.vector_search import VectorSearch
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
prompts = Path("./prompts")
|
|
59
|
+
vector_search = VectorSearch(prompt_dir=prompts, default_model="gpt-4o-mini")
|
|
60
|
+
|
|
61
|
+
report = vector_search.run_agent_sync("Explain quantum entanglement for beginners")
|
|
62
|
+
print(report.report)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Text utilities
|
|
66
|
+
|
|
67
|
+
Use the built-in text helpers when you need lightweight single-step agents.
|
|
68
|
+
|
|
69
|
+
```python
|
|
70
|
+
from openai_sdk_helpers.agent import (
|
|
71
|
+
SummarizerAgent,
|
|
72
|
+
TranslatorAgent,
|
|
73
|
+
ValidatorAgent,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
summarizer = SummarizerAgent(default_model="gpt-4o-mini")
|
|
78
|
+
translator = TranslatorAgent(default_model="gpt-4o-mini")
|
|
79
|
+
validator = ValidatorAgent(default_model="gpt-4o-mini")
|
|
80
|
+
|
|
81
|
+
summary = summarizer.run_sync("Long-form content to condense")
|
|
82
|
+
translation = translator.run_sync("Bonjour", target_language="English")
|
|
83
|
+
guardrails = validator.run_sync(
|
|
84
|
+
"Share meeting notes with names removed", agent_output=summary.text
|
|
85
|
+
)
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Prompt templates are optional for the built-in text helpers. They already ship
|
|
89
|
+
with defaults under `src/openai_sdk_helpers/prompt`, so you do **not** need to
|
|
90
|
+
create placeholder files when installing from PyPI. Only pass a `prompt_dir`
|
|
91
|
+
when you have real replacements you want to load.
|
|
92
|
+
|
|
93
|
+
The vector search workflow expects real prompts for each agent (for example,
|
|
94
|
+
`vector_planner.jinja`, `vector_search.jinja`, and `vector_writer.jinja`). If
|
|
95
|
+
you point `prompt_dir` at a folder that does not contain those files, agent
|
|
96
|
+
construction fails with a `FileNotFoundError`. Skip `prompt_dir` entirely unless
|
|
97
|
+
you have working templates ready.
|
|
98
|
+
|
|
99
|
+
### Centralized OpenAI configuration
|
|
100
|
+
|
|
101
|
+
`openai-sdk-helpers` ships with a lightweight `OpenAISettings` helper so projects can share
|
|
102
|
+
consistent authentication, routing, and model defaults when using the OpenAI
|
|
103
|
+
SDK:
|
|
104
|
+
|
|
105
|
+
```python
|
|
106
|
+
from openai_sdk_helpers import OpenAISettings
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
# Load from environment variables or a local .env file
|
|
110
|
+
settings = OpenAISettings.from_env()
|
|
111
|
+
client = settings.create_client()
|
|
112
|
+
|
|
113
|
+
# Reuse the default model across agents
|
|
114
|
+
vector_search = VectorSearch(
|
|
115
|
+
prompt_dir=prompts, default_model=settings.default_model or "gpt-4o-mini"
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
The helper reads `OPENAI_API_KEY`, `OPENAI_ORG_ID`, `OPENAI_PROJECT_ID`,
|
|
120
|
+
`OPENAI_BASE_URL`, `OPENAI_MODEL`, `OPENAI_TIMEOUT`, and `OPENAI_MAX_RETRIES` by
|
|
121
|
+
default but supports overrides for custom deployments. Pass uncommon OpenAI
|
|
122
|
+
client keyword arguments (such as `default_headers`, `http_client`, or
|
|
123
|
+
`base_url` proxies) through `extra_client_kwargs` when instantiating
|
|
124
|
+
`OpenAISettings`.
|
|
125
|
+
|
|
126
|
+
## Development
|
|
127
|
+
|
|
128
|
+
The repository is configured for a lightweight Python development workflow.
|
|
129
|
+
Before opening a pull request, format and validate your changes locally:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Style and formatting
|
|
133
|
+
pydocstyle src
|
|
134
|
+
black --check .
|
|
135
|
+
|
|
136
|
+
# Static type checking
|
|
137
|
+
pyright src
|
|
138
|
+
|
|
139
|
+
# Unit tests with coverage
|
|
140
|
+
pytest -q --cov=src --cov-report=term-missing --cov-fail-under=70
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Project Structure
|
|
144
|
+
|
|
145
|
+
- `src/openai_sdk_helpers/agent`: Agent factories, orchestration helpers, and search
|
|
146
|
+
workflows.
|
|
147
|
+
- `src/openai_sdk_helpers/prompt`: Prompt rendering utilities backed by Jinja.
|
|
148
|
+
- `src/openai_sdk_helpers/response`: Response parsing and transformation helpers.
|
|
149
|
+
- `src/openai_sdk_helpers/structure`: Typed data structures shared across workflows.
|
|
150
|
+
- `src/openai_sdk_helpers/vector_storage`: Minimal vector store abstraction.
|
|
151
|
+
- `tests/`: Unit tests covering core modules and structures.
|
|
152
|
+
|
|
153
|
+
## Key modules
|
|
154
|
+
|
|
155
|
+
The package centers around a handful of cohesive building blocks:
|
|
156
|
+
|
|
157
|
+
- `openai_sdk_helpers.agent.project_manager.ProjectManager` coordinates prompt
|
|
158
|
+
creation, plan building, task execution, and summarization while persisting
|
|
159
|
+
intermediate artifacts to disk.
|
|
160
|
+
- `openai_sdk_helpers.agent.vector_search.VectorSearch` bundles the planners,
|
|
161
|
+
executors, and summarizers required to run a multi-turn vector search flow
|
|
162
|
+
from a single entry point.
|
|
163
|
+
- `openai_sdk_helpers.agent.summarizer.SummarizerAgent`,
|
|
164
|
+
`agent.translator.TranslatorAgent`, and `agent.validator.ValidatorAgent`
|
|
165
|
+
expose streamlined text-processing utilities that reuse shared prompt
|
|
166
|
+
templates.
|
|
167
|
+
- `openai_sdk_helpers.response` contains the response runners and helpers used
|
|
168
|
+
to normalize outputs from agents, including streaming responses.
|
|
169
|
+
- `openai_sdk_helpers.utils` holds JSON serialization helpers, logging
|
|
170
|
+
utilities, and common validation helpers used across modules.
|
|
171
|
+
|
|
172
|
+
## Contributing
|
|
173
|
+
|
|
174
|
+
Contributions are welcome! Please accompany functional changes with relevant
|
|
175
|
+
tests and ensure all quality gates pass. Follow the NumPy-style docstring
|
|
176
|
+
conventions outlined in `AGENTS.md` to keep the codebase consistent.
|
|
177
|
+
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "openai-sdk-helpers"
|
|
3
|
+
version = "0.0.8"
|
|
4
|
+
requires-python = ">=3.10"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
description = "Composable helpers for OpenAI SDK agents, prompts, and storage"
|
|
7
|
+
license = {text = "MIT"}
|
|
8
|
+
authors = [{name = "openai-sdk-helpers maintainers"}]
|
|
9
|
+
dependencies = [
|
|
10
|
+
|
|
11
|
+
# Template rendering
|
|
12
|
+
"jinja2",
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
# Data modeling
|
|
16
|
+
"pydantic>=2.7,<3",
|
|
17
|
+
"typing_extensions>=4.15.0,<5",
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
# Environment variable management
|
|
21
|
+
"python-dotenv",
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# OpenAI functionality
|
|
25
|
+
"openai",
|
|
26
|
+
"openai-agents",
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
# Web UI
|
|
30
|
+
"streamlit",
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[dependency-groups]
|
|
34
|
+
dev = [
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
# Linting and docstring style checks
|
|
38
|
+
"pydocstyle",
|
|
39
|
+
"pyright",
|
|
40
|
+
|
|
41
|
+
# Formatting
|
|
42
|
+
"black",
|
|
43
|
+
"black[jupyter]",
|
|
44
|
+
|
|
45
|
+
# Testing
|
|
46
|
+
"pytest-cov",
|
|
47
|
+
"pytest",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[build-system]
|
|
51
|
+
requires = ["hatchling"]
|
|
52
|
+
build-backend = "hatchling.build"
|
|
53
|
+
|
|
54
|
+
[tool.hatch.build]
|
|
55
|
+
# Ship the entire package tree so Python modules are included alongside the
|
|
56
|
+
# bundled prompt templates.
|
|
57
|
+
include = ["src/openai_sdk_helpers"]
|
|
58
|
+
|
|
59
|
+
[tool.hatch.build.targets.wheel]
|
|
60
|
+
packages = ["src/openai_sdk_helpers"]
|
|
61
|
+
|
|
62
|
+
[tool.hatch.build.targets.sdist]
|
|
63
|
+
include = ["src/openai_sdk_helpers"]
|
|
64
|
+
|
|
65
|
+
[tool.pyright]
|
|
66
|
+
extraPaths = ["src"]
|
|
67
|
+
|
|
68
|
+
[tool.pydocstyle]
|
|
69
|
+
convention = "numpy"
|