Delusion
✨ The missing conveniences in generative models ✨📦 Description
A small toolkit for generative models, with practical conveniences built in: such as caching, fast imports, syntactic sugars, opinionated architecture, curated providers, and more.
- Message classes with type-safe structured output generics, auto validation (chat)
- Modular: Easily write your implementations or modify existing ones.
- Minimal: Avoids the complexity and commitment of a full framework.
📦 Usage
Simply add the delusion PyPI package to your project and use it:
[project]
dependencies = ["delusion"]
Chat
from delusion.chat.option.ollamax import Ollama
from pydantic import BaseModel, Field
class Country(BaseModel):
name: str
capital: str
languages: set[str] = Field(
description="Officially recognized languages"
)
chat = Ollama().cache().serve()
chat.gemma4("e2b").pull()
chat.send("Tell me about Canada, its capital and spoken languages.")
# Your linter should properly point to the class
canada = chat.generate(schema=Country)
print(canada.model)
assert (canada.model.name == "Canada")
assert (canada.model.capital == "Ottawa")
assert (canada.model.languages == {"English", "French"})
Audio
Example using audio.cpp:
from delusion.audio.cpp import AudioCPP, OmniVoice
# No PyTorch or ONNX required
audio = AudioCPP(
model=OmniVoice(quant="q8_0").download()
)
# Uses NamedTemporaryFile internally
speak = audio.tts(text="お水はもう一杯もらえますか")
Path("output.wav").write_bytes(speak.wav)
📦 Standards
In an effort to minimize xkcd 927, Delusion only introduces abstractions that provide clear value or represent shared semantics across providers, proxying or extending native packages whenever available.
For example, the Options class for ollama models shall only apply to itself:
import ollama
local = Ollama(model="gemma4:e2b")
cloud = OpenAI(model="gpt-whatever")
isinstance(local.options, ollama.Options) # True
isinstance(cloud.options, ollama.Options) # False
Although both support .temperature = 0.0, the intended use is:
# Individual settings
if os.getenv("PRODUCTION", None):
chat = OpenAI(model=...)
chat.options.temperature = 0.0
else:
chat = Ollama(model=...)
chat.options.temperature = 0.0
# Shared interface
chat.send(...)
chat.generate(schema=...)
Same for models: rather than over-abstracting capabilities, quantization, names, variants, and other provider-specific details, some code duplication is natural to keep it minimal and decoupled.
Conversely, Message[T] is abstracted because it represents a common semantic across providers.
Metadata
Release files for delusion 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| delusion-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for delusion-0.4.0-py3-none-any.whl |
Release files / delusion-0.4.0-py3-none-any.whl
| Download URL | delusion-0.4.0-py3-none-any.whl |
|---|---|
| Size | 10.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5d8f2c46b7062d1c48ac05f1236fba79cb9138cb4f2d30e3a919eb318399128
|
|
BLAKE2b-256 checksum How to use checksums |
9d8bc1444e11db50a2dcef830febc2b6ec2ae4a22e0a4bad6863b247cf798c0c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for delusion 0.4.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.