Python SDK for writing Pie inferlets
Project description
inferlet Python SDK
Python API for writing Pie inferlets.
from inferlet import Context, Model, Sampler, runtime
async def main(input: dict) -> str:
model = Model.load(runtime.models()[0])
ctx = Context(model)
ctx.system("You are helpful.").user(input["prompt"])
return await ctx.generate(
Sampler.top_p(0.6, 0.95),
max_tokens=256,
).collect_text()
Main pieces
Context: owns KV-cache state and chat/raw token buffers.Forward: runs one explicit forward pass with samplers, probes, masks, and manual page control.Generator: multi-step generation loop with stop conditions, constraints, speculation, adapters, and JSON collection.chat,reasoning,tools: optional decoders and helpers for model-native formats.runtime,session,messaging,mcp: host services exposed to inferlets.
Build notes
Python inferlets are packaged as Wasm components. Pure-Python dependencies can
be bundled; native extensions such as numpy, orjson, msgspec, or
pydantic_core cannot be loaded in the Wasm runtime.
Build through Bakery:
pie build ./my-python-inferlet -o out.wasm
For constrained decoding details, see
sdk/CONSTRAINED_DECODING.md.
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 inferlet-0.3.0.tar.gz.
File metadata
- Download URL: inferlet-0.3.0.tar.gz
- Upload date:
- Size: 60.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a606661880f1daa2d60abdea2cc8ca8d0b93dff05613108f28353cf06f32c75
|
|
| MD5 |
74bd47dc5eae6f936f90b6e1998f4922
|
|
| BLAKE2b-256 |
e19346ab0a13e2e6ec4b162475e2455e01255ccff71b83ff413a267116273071
|
File details
Details for the file inferlet-0.3.0-py3-none-any.whl.
File metadata
- Download URL: inferlet-0.3.0-py3-none-any.whl
- Upload date:
- Size: 77.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd095cbf918795a82c6c673b0637408c9e36cc0610c4b33b54191ba80f2b9357
|
|
| MD5 |
537b74b74eb8d5aa5e79dde756cd7f43
|
|
| BLAKE2b-256 |
2f0062dc9561e1db0399a918bce39d2b284f08fc102dbb2f3ca98bf06aa3f6a2
|