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
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
inferlet-0.4.0.tar.gz
(61.1 kB
view details)
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
inferlet-0.4.0-py3-none-any.whl
(77.4 kB
view details)
File details
Details for the file inferlet-0.4.0.tar.gz.
File metadata
- Download URL: inferlet-0.4.0.tar.gz
- Upload date:
- Size: 61.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
851d4b8c5995bbf35c1cfb5b013e18a10b8b7f403f42b5ab5f6d5ddab455bab7
|
|
| MD5 |
6fb3c670390ea98202982549e89b2b22
|
|
| BLAKE2b-256 |
a09e75a1012ef0238b6e11837fa7fa93aea1f38d59f9c0320a66ad5ef587b48e
|
File details
Details for the file inferlet-0.4.0-py3-none-any.whl.
File metadata
- Download URL: inferlet-0.4.0-py3-none-any.whl
- Upload date:
- Size: 77.4 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 |
19fe0a98cf79e7e7ee5418fce2427481c283072b51837d22ec193cc8ae32c95c
|
|
| MD5 |
ddc1dc563229ae1da71676434a24687c
|
|
| BLAKE2b-256 |
0e23856ee0b5d8e260ed40928c2d76c053b483bba095809481e927cdb2927a38
|