Skip to main content

nativecluster

The Python kit for building NativeCluster apps.

NativeCluster is a free Mac app that runs open AI models on a group's own Macs. An app made for it is a program NativeCluster installs and runs for the group's people: it serves its pages behind NativeCluster's sign-in, and every model call it makes waits its turn in the cluster's one line and runs on one of the group's own Macs. This kit is the app's side of that:

  • Serving: a WSGI app (Flask, Django, a plain function) or an ASGI one (FastAPI, Starlette) runs behind NativeCluster with one line, run_wsgi or run_asgi, which checks NativeCluster's signed ticket on every request.
  • People: person_of(request) is the person NativeCluster signed in, read from that ticket and nothing else.
  • Models: models().chat(<task>, messages) asks the group's models through the line. Or keep OpenAI's Python library and hand it transport.http_client().
  • Schedules and background work: host() sets the app's schedules, events and loops, and run_firing does the work when one comes due.
  • Data: data_dir() is the app's own folder.

You don't need this kit to call a cluster's models from a script or tool. Any OpenAI-compatible client works with NativeCluster's local address, http://localhost:8487/v1: see the API docs.

Install

pip install nativecluster
pip install "nativecluster[openai]"   # for nativecluster.transport, with OpenAI's library

Python 3.9 or newer. The kit itself needs nothing else.

ncdev, NativeCluster's tool for building apps, comes with NativeCluster. ncdev new <dir> -lang python writes a whole example app with this kit inside it, and ncdev check holds an app to NativeCluster's rules before it is installed. An app's package carries its own Python and every dependency, so install the kit into the Python the app ships with.

A small app

import nativecluster as nc

def app(environ, start_response):
    person = nc.person_of(environ)
    answer = nc.models().chat("summarize", [
        {"role": "user", "content": "Summarize: NativeCluster runs AI on our own Macs."},
    ])
    start_response("200 OK", [("Content-Type", "text/plain; charset=utf-8")])
    return [f"{person}: {answer.text} ({answer.model})".encode()]

if __name__ == "__main__":
    nc.run_wsgi("nc-app.json", app)

summarize is one of the tasks the app's manifest (nc-app.json) names. NativeCluster decides which of the group's models may do it. The program runs only under NativeCluster (ncdev run while you build it); started any other way, it says so and stops.

With OpenAI's library, a call's model names one of the app's tasks:

from openai import OpenAI
from nativecluster import transport

client = OpenAI(base_url=transport.BASE_URL, api_key="nativecluster",
                http_client=transport.http_client())
client.chat.completions.create(model="summarize", messages=[...])

Learn more

License

This kit is licensed under the Apache License, Version 2.0. NativeCluster itself is proprietary.

Metadata

Release files for nativecluster 0.1.0

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

Source distribution (sdist)

Source distribution for nativecluster 0.1.0
File Size Uploaded Provenance Actions
nativecluster-0.1.0.tar.gz 43.7 kB Without provenance Details for nativecluster-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nativecluster 0.1.0
File Interpreter ABI Platform Actions
nativecluster-0.1.0-py3-none-any.whl Python 3 none any Details for nativecluster-0.1.0-py3-none-any.whl

Total release size: 91.9 kB

Release files / nativecluster-0.1.0.tar.gz

Download URL nativecluster-0.1.0.tar.gz
Size 43.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bd2cdd14ff34c78294ade3ba706eeeee8c3fd15cb0f938a87d7dc19d7359d033
BLAKE2b-256 checksum
How to use checksums
053cf5ac3db6fbc76f65d1ed04c550560655d1f9f22a59c9c8d1dfcd70f13e6e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / nativecluster-0.1.0-py3-none-any.whl

Download URL nativecluster-0.1.0-py3-none-any.whl
Size 48.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c4bd0c0b9ac0792b20f9700a1998dce776d9c7c81f1318fb9235b485b290f13d
BLAKE2b-256 checksum
How to use checksums
772c28dca351392c1fadad7694d12f5116cfd4cdaaaabcdac96f5dc84a1261ec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.21 {"installer":{"name":"uv","version":"0.12.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for nativecluster 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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