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.1

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.1
File Size Uploaded Provenance Actions
nativecluster-0.1.1.tar.gz 49.8 kB Without provenance Details for nativecluster-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 104.8 kB

Release files / nativecluster-0.1.1.tar.gz

Download URL nativecluster-0.1.1.tar.gz
Size 49.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d619a66dda00a3913f379c05d60d2979ec7b06b2dd809718f9043a165a71ae36
BLAKE2b-256 checksum
How to use checksums
9f00b49c807fc634b11a74c8b220062a4f0dd11bc779226f3402035042b7c236
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

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

Download URL nativecluster-0.1.1-py3-none-any.whl
Size 55.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e68866aac34379f7ed7f9f09d70b2e9dccb1919a0e5090f349cfbab94448149c
BLAKE2b-256 checksum
How to use checksums
5af1ababdedb728bb9a91b13ab59b03887754b8984369e11b2e6e4617d86d582
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.6

Security for nativecluster 0.1.1

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.1 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