Skip to main content

habermas-machine

PyPI CI Python License

habermas-machine packages the core deliberation, ranking, and social-choice components used to run Habermas Machine experiments.

Install

Install the core package:

uv add habermas-machine

Install with provider extras when you need live model clients:

uv add "habermas-machine[all]"

Available extras:

  • google
  • anthropic
  • together
  • modal
  • openrouter
  • all

Optional Anthropic structured output

The standard two-step generator can use Anthropic's native JSON-schema decoding:

from habermas_machine import models

client = models.LLMCLient.ANTHROPIC.get_client("your-supported-claude-model")
statement_model = models.StatementModel.TWO_STEP_DIVERSE.get_model(
    llm_client=client,
    language="en",
    structured_output=True,
)

Use this model as the machine's diverse_statement_model (or register it in statement_models) and call HabermasMachine.mediate() as usual. In habermas_api, enable the option where TWO_STEP_DIVERSE is constructed after updating the installed HM package. Parsed candidate fields keep their existing shape, so the website's frontend does not need to change. Raw model_response strings, including candidates.all_text_model_responses in the machine result, contain JSON in structured mode instead of tagged text. Analysis scripts that re-parse those responses must account for the selected format.

Both steps use the same drafting instructions as the tagged prompts, with JSON format instructions for English and Arabic (other locales retain the English fallback). Results remain StatementResult objects. Attempt limits and failed response logging are retained; retries never switch formats. Structured mode requires exactly the requested number of approach strings, each longer than five characters after trimming, and rejects the whole list if any approach is invalid. The tagged path retains its existing filtering of short approaches. Statement length checks remain in place, and incomplete/refused output can still fail validation.

The default token budget is 20,000, within the Anthropic SDK's default non-streaming request limit. Unexpected response stop reasons (such as max_tokens and refusal) are logged with raw text, token usage, and request ID when available. Request/SDK errors are logged with the original exception and traceback. Invalid requests and the SDK's Streaming is required errors propagate immediately; other request failures retain their existing retry behavior.

The default is False. Structured mode currently requires an Anthropic model supporting structured output and the stock two-step prompts/parsers. It supports only generate_diverse_statement; single-statement and batch methods reject the option rather than using tagged output. Other clients/generators remain unchanged.

Development

Sync a local development environment with tests and release tooling:

uv sync --group dev --extra all

Run tests:

uv run pytest

Build distribution artifacts:

uv build
uv run twine check dist/*

Releases

  • GitHub Actions runs CI on pushes and pull requests.
    • Runs unit tests.
    • Builds the package.
    • Tests pacakge is installable.
    • Publishes a unique dev build to TestPyPI through trusted publishing.
  • Creating a non-prerelease GitHub release publishes the tagged version to PyPI through trusted publishing.

Metadata

Release files for habermas-machine 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for habermas-machine 1.0.2
File Size Uploaded Provenance
habermas_machine-1.0.2.tar.gz 278.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for habermas-machine 1.0.2
File Interpreter ABI Platform
habermas_machine-1.0.2-py3-none-any.whl Python 3 none any Details

Total release size: 377.9 kB

Release files / habermas_machine-1.0.2.tar.gz

Download URL habermas_machine-1.0.2.tar.gz
Size 278.1 kB
Tags Source
SHA-256 checksum
How to use checksums
77b29bc3754051595816820691c488c11b64af9fd680c6960db0cb9e17efdd73
BLAKE2b-256 checksum
How to use checksums
5e8be50899ede1d0afd49d06ab4101a7071949380548d8de2919d3a616897621
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Release files / habermas_machine-1.0.2-py3-none-any.whl

Download URL habermas_machine-1.0.2-py3-none-any.whl
Size 99.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf6bc950ecb1df356f292600d228796407866fd65001028f6fd7d97533cf3804
BLAKE2b-256 checksum
How to use checksums
87e8879759ff19f0df872a2749f0740dd541db3b29b08954bd5088b382dbc57b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

Security for habermas-machine 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for habermas_machine-1.0.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page