Skip to main content

Composable helpers for OpenAI SDK agents, prompts, and storage

Project description

openai-sdk-helpers

Shared primitives for composing OpenAI agent workflows: structures, response handling, prompt rendering, and reusable agent factories.

Overview

openai-sdk-helpers packages the common building blocks required to assemble agent-driven applications. The library intentionally focuses on reusable primitives—data structures, configuration helpers, and orchestration utilities—while leaving application-specific prompts and tools to the consuming project.

Features

  • Agent wrappers for OpenAI Agents SDK with synchronous and asynchronous entry points.
  • Prompt rendering powered by Jinja for dynamic agent instructions.
  • Typed structures for prompts, responses, and search workflows to ensure predictable inputs and outputs.
  • Vector and web search flows that coordinate planning, execution, and reporting.
  • Reusable text agents for summarization and translation tasks.

Installation

Install the package directly from PyPI to reuse it across projects:

pip install openai-sdk-helpers

Type information ships with the published wheel via py.typed, so external projects can rely on the bundled annotations without adding custom stubs.

For local development, install with editable sources and the optional dev dependencies:

pip install -e .
pip install -e . --group dev

Quickstart

Create a basic vector search workflow by wiring your own prompt templates and preferred model configuration:

from pathlib import Path

from openai_sdk_helpers.agent.vector_search import VectorSearch


prompts = Path("./prompts")
vector_search = VectorSearch(prompt_dir=prompts, default_model="gpt-4o-mini")

report = vector_search.run_agent_sync("Explain quantum entanglement for beginners")
print(report.report)

Text utilities

Use the built-in text helpers when you need lightweight single-step agents.

from openai_sdk_helpers.agent import (
    SummarizerAgent,
    TranslatorAgent,
    ValidatorAgent,
)


summarizer = SummarizerAgent(default_model="gpt-4o-mini")
translator = TranslatorAgent(default_model="gpt-4o-mini")
validator = ValidatorAgent(default_model="gpt-4o-mini")

summary = summarizer.run_sync("Long-form content to condense")
translation = translator.run_sync("Bonjour", target_language="English")
guardrails = validator.run_sync(
    "Share meeting notes with names removed", agent_output=summary.text
)

Prompt templates are optional for the built-in text helpers. They already ship with defaults under src/openai_sdk_helpers/prompt, so you do not need to create placeholder files when installing from PyPI. Only pass a prompt_dir when you have real replacements you want to load.

The vector search workflow expects real prompts for each agent (for example, vector_planner.jinja, vector_search.jinja, and vector_writer.jinja). If you point prompt_dir at a folder that does not contain those files, agent construction fails with a FileNotFoundError. Skip prompt_dir entirely unless you have working templates ready.

Centralized OpenAI configuration

openai-sdk-helpers ships with a lightweight OpenAISettings helper so projects can share consistent authentication, routing, and model defaults when using the OpenAI SDK:

from openai_sdk_helpers import OpenAISettings


# Load from environment variables or a local .env file
settings = OpenAISettings.from_env()
client = settings.create_client()

# Reuse the default model across agents
vector_search = VectorSearch(
    prompt_dir=prompts, default_model=settings.default_model or "gpt-4o-mini"
)

The helper reads OPENAI_API_KEY, OPENAI_ORG_ID, OPENAI_PROJECT_ID, OPENAI_BASE_URL, OPENAI_MODEL, OPENAI_TIMEOUT, and OPENAI_MAX_RETRIES by default but supports overrides for custom deployments. Pass uncommon OpenAI client keyword arguments (such as default_headers, http_client, or base_url proxies) through extra_client_kwargs when instantiating OpenAISettings.

Development

The repository is configured for a lightweight Python development workflow. Before opening a pull request, format and validate your changes locally:

# Style and formatting
pydocstyle src
black --check .

# Static type checking
pyright src

# Unit tests with coverage
pytest -q --cov=src --cov-report=term-missing --cov-fail-under=70

Project Structure

  • src/openai_sdk_helpers/agent: Agent factories, orchestration helpers, and search workflows.
  • src/openai_sdk_helpers/prompt: Prompt rendering utilities backed by Jinja.
  • src/openai_sdk_helpers/response: Response parsing and transformation helpers.
  • src/openai_sdk_helpers/structure: Typed data structures shared across workflows.
  • src/openai_sdk_helpers/vector_storage: Minimal vector store abstraction.
  • tests/: Unit tests covering core modules and structures.

Key modules

The package centers around a handful of cohesive building blocks:

  • openai_sdk_helpers.agent.project_manager.ProjectManager coordinates prompt creation, plan building, task execution, and summarization while persisting intermediate artifacts to disk.
  • openai_sdk_helpers.agent.vector_search.VectorSearch bundles the planners, executors, and summarizers required to run a multi-turn vector search flow from a single entry point.
  • openai_sdk_helpers.agent.summarizer.SummarizerAgent, agent.translator.TranslatorAgent, and agent.validator.ValidatorAgent expose streamlined text-processing utilities that reuse shared prompt templates.
  • openai_sdk_helpers.response contains the response runners and helpers used to normalize outputs from agents, including streaming responses.
  • openai_sdk_helpers.utils holds JSON serialization helpers, logging utilities, and common validation helpers used across modules.

Contributing

Contributions are welcome! Please accompany functional changes with relevant tests and ensure all quality gates pass. Follow the NumPy-style docstring conventions outlined in AGENTS.md to keep the codebase consistent.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openai_sdk_helpers-0.0.7.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openai_sdk_helpers-0.0.7-py3-none-any.whl (67.5 kB view details)

Uploaded Python 3

File details

Details for the file openai_sdk_helpers-0.0.7.tar.gz.

File metadata

  • Download URL: openai_sdk_helpers-0.0.7.tar.gz
  • Upload date:
  • Size: 47.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for openai_sdk_helpers-0.0.7.tar.gz
Algorithm Hash digest
SHA256 34992baa2a189f0a42aebd8fad29faa0297f35cf5327083f41337e79a1c679bf
MD5 a17ad4d8b7915efebb4a6975d9918fdd
BLAKE2b-256 077c7e14b844c7157e7ae8f92dd958f8c88980b85f6bafc3ddb0f0b3257e9267

See more details on using hashes here.

File details

Details for the file openai_sdk_helpers-0.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for openai_sdk_helpers-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 bf8f31f6b01bf31bf418733dda1f1e55ab60979d04c8a10b51f1413916fba4a8
MD5 5c99c7dc18cef48ac15504743eb8ad83
BLAKE2b-256 b466d7e4b305c5cb8fdea7c66e6db73f42c8d15c1f307a3377b73538640136a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page