OpenAI-first hexagonal Python application scaffold for llmframe.
Project description
llmframe
OpenAI-first Python hexagonal application scaffold for the llmframe repository.
Requirements
- Python 3.11+
uvfor environment and dependency management
Setup
Install the project and development dependencies:
uv sync --all-extras
LLM adapters
The repository includes reusable LLM output adapters under llmframe.adapters.output.llm.
Today this package is intentionally OpenAI-first: OpenAI is the only implemented provider integration, while the surrounding structure is being kept hexagonal so additional providers can be added later without leaking provider-specific concerns into the shared/application layers.
Key package areas:
llmframe.adapters.output.llm.llm_adapter- provider-neutral high-level structured JSON and text generation adapterllmframe.adapters.output.llm.providers.openai- OpenAI provider adapter, client builder, transport, DTOs, and parsing helpersllmframe.adapters.output.llm.usage_tracker- aggregated token/cost tracking utilities
Example imports:
from llmframe import OpenAIClientSettings, build_openai_llm_adapter
from llmframe.adapters.output.llm.usage_tracker import LlmUsageTrackerConfig, OpenAILlmUsageTracker
Recommended construction for third-party code:
from llmframe import OpenAIClientSettings, build_openai_llm_adapter
adapter = build_openai_llm_adapter(
settings=OpenAIClientSettings(
base_url="https://api.openai.com/v1",
api_key="...",
),
model="gpt-4.1-mini",
debug_json_enabled=True,
)
This keeps third-party callers on a stable, provider-neutral LlmAdapter API while hiding the internal provider assembly details.
OpenAI Responses Batch API
The shared LlmAdapter also supports OpenAI's asynchronous Batch API for the Responses endpoint. This preserves the current synchronous generate_text() and extract_json() methods while adding separate batch submission and retrieval methods for lower-cost bulk execution.
Example plain-text batch submission:
from llmframe import LlmBatchTextRequest, OpenAIClientSettings, build_openai_llm_adapter
adapter = build_openai_llm_adapter(
settings=OpenAIClientSettings(
base_url="https://api.openai.com/v1",
api_key="...",
),
model="gpt-4.1-mini",
)
submission = adapter.submit_text_batch(
requests=[
LlmBatchTextRequest(
custom_id="item-1",
developer_prompt="You are a concise assistant.",
user_prompt="Summarize this document.",
)
]
)
status = adapter.get_batch_status(batch_id=submission.batch_id)
Once the batch is complete, callers can retrieve parsed plain-text or structured results with get_text_batch_result() or get_structured_batch_result(). Batch execution is asynchronous and OpenAI-specific under the hood, but remains exposed through the same shared adapter package.
When debug_json_enabled=True, the factory automatically creates a JsonFileWriterAdapter and writes formatted request/response snapshots to artifacts/llm-debug.
To override the output location:
from pathlib import Path
from llmframe import OpenAIClientSettings, build_openai_llm_adapter
adapter = build_openai_llm_adapter(
settings=OpenAIClientSettings(
base_url="https://api.openai.com/v1",
api_key="...",
),
model="gpt-4.1-mini",
debug_json_enabled=True,
debug_json_output_dir=Path("custom/debug-dir"),
)
The shared LLM adapter depends on the application-layer JsonArtifactWriterPort, while the factory wires in the filesystem-backed JsonFileWriterAdapter by default for this convenience path.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llmframe-2.4.0.tar.gz.
File metadata
- Download URL: llmframe-2.4.0.tar.gz
- Upload date:
- Size: 145.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
582d24c5015b4e7d0bb4d0a8ab1e73773a9935c2e9010e3e1223ea644a525be9
|
|
| MD5 |
7fe50c382916cb8a569218c7d368c3de
|
|
| BLAKE2b-256 |
9b5a6edf9d20e8a6d8c34d053729706b22c636c491d3816f3613690251ed75dd
|
Provenance
The following attestation bundles were made for llmframe-2.4.0.tar.gz:
Publisher:
ci_cd.yaml on Nexus-Thread/py-llmframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmframe-2.4.0.tar.gz -
Subject digest:
582d24c5015b4e7d0bb4d0a8ab1e73773a9935c2e9010e3e1223ea644a525be9 - Sigstore transparency entry: 1252571251
- Sigstore integration time:
-
Permalink:
Nexus-Thread/py-llmframe@3f76219a2c0b5b1b00a293e6748de89f6bd0607b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Nexus-Thread
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci_cd.yaml@3f76219a2c0b5b1b00a293e6748de89f6bd0607b -
Trigger Event:
push
-
Statement type:
File details
Details for the file llmframe-2.4.0-py3-none-any.whl.
File metadata
- Download URL: llmframe-2.4.0-py3-none-any.whl
- Upload date:
- Size: 42.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59c9dc87a95fad059f181a7ef233d72054dceecbd9e63f868e57be652175a1ae
|
|
| MD5 |
7108f052a15452dc1a6319bcef3ce4c8
|
|
| BLAKE2b-256 |
5268d67999f9a90dc92bb4cec04fb0842d0b722aec0f1b2d466ac0e69322ccf9
|
Provenance
The following attestation bundles were made for llmframe-2.4.0-py3-none-any.whl:
Publisher:
ci_cd.yaml on Nexus-Thread/py-llmframe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llmframe-2.4.0-py3-none-any.whl -
Subject digest:
59c9dc87a95fad059f181a7ef233d72054dceecbd9e63f868e57be652175a1ae - Sigstore transparency entry: 1252571281
- Sigstore integration time:
-
Permalink:
Nexus-Thread/py-llmframe@3f76219a2c0b5b1b00a293e6748de89f6bd0607b -
Branch / Tag:
refs/heads/master - Owner: https://github.com/Nexus-Thread
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci_cd.yaml@3f76219a2c0b5b1b00a293e6748de89f6bd0607b -
Trigger Event:
push
-
Statement type: