Skip to main content

CookSafe

Small Python utilities for reproducible LLM experiments and shareable TypeSafe playground links.

  • JsonCache saves function results to a JSON file and reuses them on subsequent calls.
  • make_playground_link creates a link containing your input and TypeSafe questions.

Installation

Requires Python 3.10 or newer. Install from PyPI:

pip install cooksafe

JsonCache

Decorate a synchronous function to persist its results between runs. This is useful for replaying expensive API calls while developing notebooks or experiments.

from cooksafe import JsonCache

cache = JsonCache("results.json")


@cache
def analyze(text: str) -> dict:
    print("Computing result")
    return {"characters": len(text)}  # Replace with your API call or computation.


print(analyze("hello"))  # Computes and saves {"characters": 5} on the first call.
print(analyze("hello"))  # Returns the saved result without running analyze again.

Results must be JSON-serializable. Cache keys use the function name and string representations of its arguments. Changing the function body does not invalidate existing entries: delete the cache file before starting a new run to recompute them. Use JsonCache("results.json", indent=None) for compact files.

Cached results are stored in plaintext. Do not commit cache files containing sensitive data.

Create a link that opens your input and questions in the TypeSafe playground. Inputs can be text or JSON-compatible data; questions can be typesafe-sdk objects or their dictionary forms.

from typesafe_sdk import Noul, NoulCriteria

from cooksafe import make_playground_link

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

Link generation works offline and needs no API key. The URL contains the input and questions, so anyone with the link can read them; avoid including sensitive data.

See the CookSafe cookbooks for complete examples.

Release files for cooksafe 0.2.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.2.0
File Size Uploaded
cooksafe-0.2.0.tar.gz 3.4 kB Details

Built distribution (wheel)

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

Total release size: 8.0 kB

Release files / cooksafe-0.2.0.tar.gz

Download URL cooksafe-0.2.0.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
acbb65fe2dcd8307ffd13718f13ee6e11ed0bda49a35b5af879a036e08dc9b42
BLAKE2b-256 checksum
How to use checksums
b24755901aa60aadb83ca2d94cb467c932cef7674f6fea3aad5b44de7eb40e01
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 Sep 22, 2026.

Transparency log

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

Download URL cooksafe-0.2.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ea20ac6eadc2755089b7dccbd9a069d929530c8da5dff9c43305288f675fecd
BLAKE2b-256 checksum
How to use checksums
15958daa5b1bceef9383625fb4b86cc95bb89faaa8d2387e5eae901846409f8e
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 Sep 22, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

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