Skip to main content

cooksafe

Two helpers the TypeSafe cookbooks share.

pip install 'cooksafe>=0.3.0,<0.4.0'

JsonCache

File-backed memoization for the model calls in a notebook, so a re-run replays what the first run recorded instead of paying for it again.

from pathlib import Path
from cooksafe import JsonCache

cache = JsonCache(Path("json_cache.json"))

@cache
def ask(text: str, questions_json: str) -> dict:
    ...  # a real API call happens once per distinct argument set

Results must be JSON-serializable. Keys are the function name plus its arguments; long ones (a whole input text, say) are stored as a digest so the file stays readable. SDK question objects are keyed by their API JSON, so the key does not depend on the object's repr. Delete the file to re-sample everything live.

Turns a state and a set of questions into a link that opens them in the TypeSafe playground, for readers who want to try a cookbook's questions against their own text.

from cooksafe import make_playground_link
from typesafe_sdk import Noul, NoulCriteria

questions = {
    "is_greeting": Noul(
        instructions="Is this a greeting?",
        criteria=NoulCriteria(true="it greets the reader", false="it does not"),
    )
}
print(make_playground_link({"text": "hello there"}, questions))

The link carries the state and questions in its fragment, so it is generated offline and nothing is uploaded to build it.

Metadata

Release files for cooksafe 0.3.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 cooksafe 0.3.0
File Size Uploaded Provenance Actions
cooksafe-0.3.0.tar.gz 3.8 kB With provenance Details for cooksafe-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 8.9 kB

Release files / cooksafe-0.3.0.tar.gz

Download URL cooksafe-0.3.0.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f5633098631cf6a8aab1460465c99b184194451a1d6a61d35f5a3aadffaaff5f
BLAKE2b-256 checksum
How to use checksums
5f042edaccaff117fe2e6e3404b3990412a2115a6d7e56a9cd961b5f92b5789a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / cooksafe-0.3.0-py3-none-any.whl

Download URL cooksafe-0.3.0-py3-none-any.whl
Size 5.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b25422e5229380038775a06f965dbd273cc05185c32207fa4b76eddd574fdadc
BLAKE2b-256 checksum
How to use checksums
00d8c062add0ac668ce9324a0bd52ef822377ceba6ebac5a05f71c871fedbf54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for cooksafe 0.3.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for cooksafe-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

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.3.0 This release

2 release files Full 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