Skip to main content

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+
  • uv for 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 adapter
  • llmframe.adapters.output.llm.providers.openai - OpenAI provider adapter, client builder, transport, DTOs, and parsing helpers
  • llmframe.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.

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


Download files

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

Source Distribution

llmframe-2.3.0.tar.gz (137.9 kB view details)

Uploaded Source

Built Distribution

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

llmframe-2.3.0-py3-none-any.whl (32.5 kB view details)

Uploaded Python 3

File details

Details for the file llmframe-2.3.0.tar.gz.

File metadata

  • Download URL: llmframe-2.3.0.tar.gz
  • Upload date:
  • Size: 137.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmframe-2.3.0.tar.gz
Algorithm Hash digest
SHA256 d653069d4c8babeb379f02b845c1dcb3761fc3f5a92005e62a8dab03decaef01
MD5 e3d33edb8d0c0a41549d54cd84272c9d
BLAKE2b-256 d41c48efdde668971d5ad4b0478197362ee2c84d9cd212e4eb4e29c02935d7a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmframe-2.3.0.tar.gz:

Publisher: ci_cd.yaml on Nexus-Thread/py-llmframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llmframe-2.3.0-py3-none-any.whl.

File metadata

  • Download URL: llmframe-2.3.0-py3-none-any.whl
  • Upload date:
  • Size: 32.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for llmframe-2.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87aa4f5981f5c204ceb7897e29d038080d8c8e8ceb214c94dd527d104334f25e
MD5 a6cdd92ae8dd845a252821e2f5b34df4
BLAKE2b-256 5608198b8c5537985a116991c18343510755bca0e139f916f97ea03dc2a6718c

See more details on using hashes here.

Provenance

The following attestation bundles were made for llmframe-2.3.0-py3-none-any.whl:

Publisher: ci_cd.yaml on Nexus-Thread/py-llmframe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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