Repolode
Mattie

Mattie/cataclysm

A Python library that generates function implementations with an LLM at runtime, based on function names, arguments, and context, powered by OpenAI.

Stars
409
Forks
43
Open issues
11
Last commit
14 days ago

What is it?

Cataclysm lets Python code call functions that have no implementation yet. When an unrecognized function is called, it sends the function name, arguments, keyword names, docstrings, comments, and call stack context to an OpenAI model, executes the generated code, and returns the result. Generated code is cached per function signature in local files, so later calls reuse it.

The library offers several modes. `consume(globals())` enables generation for any unrecognized function in the current namespace, which suits notebooks and experiments. The `doom` module is the recommended entry point for libraries and apps. `doom.impending` previews generated code without running it, and `doom.chosen` runs only cached code and raises NameError when nothing is cached, so released code never calls the model.

Setup requires Python 3.11 or newer, an OpenAI API key placed in a `.env` file, and `cataclysm init` to copy default prompt and data files. Generation is powered through the chatsnack library, and the prompt file can be edited to change behavior or swap in a cheaper model.

Key features

  • 01Generates missing function implementations from names, arguments, and context.
  • 02Caches generated code locally per function signature for reuse.
  • 03Provides a recommended `doom` module for use in libraries and apps.
  • 04Offers a preview mode (`doom.impending`) to inspect code before execution.
  • 05Offers a frozen mode (`doom.chosen`) that runs only cached code.

Use cases

  • Quickly prototyping functions in Jupyter notebooks or interactive sessions.
  • Exploring how an LLM would implement a utility function from its signature.
  • Shipping an application with pre-generated code that never calls the model at runtime.

Quick start

  1. 1

    Install the package from PyPI

    pip install cataclysm
  2. 2

    In your project directory, copy the default datafiles

    cataclysm init
  3. 3

    Add your OpenAI API key to the .env file

Things to know

  • Requires an OpenAI API key and calls OpenAI's paid API.
  • Requires Python 3.11 or newer.
  • Generated code is unverified and the README warns it can be unsafe; it is experimental.

Topics

FAQ

What is cataclysm?
A Python library that generates function implementations with an LLM at runtime, based on function names, arguments, and context, powered by OpenAI. Cataclysm lets Python code call functions that have no implementation yet. When an unrecognized function is called, it sends the function name, arguments, keyword names, docstrings, comments, and call stack context to an OpenAI model, executes the generated code, and returns the result. Generated code is cached per function signature in local files, so later calls reuse it.
Is cataclysm free to use? What license does it have?
cataclysm is open source under the MIT license. Check the license terms before using it in commercial products.
Is cataclysm still maintained?
Actively maintained. The last commit to cataclysm was on Oct 24, 2026.
What can I use cataclysm for?
Quickly prototyping functions in Jupyter notebooks or interactive sessions. Exploring how an LLM would implement a utility function from its signature. Shipping an application with pre-generated code that never calls the model at runtime.
How do I install cataclysm?
Install the package from PyPI: pip install cataclysm In your project directory, copy the default datafiles: cataclysm init Add your OpenAI API key to the .env file
Where can I get cataclysm?
The source code and installation instructions are on GitHub: https://github.com/Mattie/cataclysm

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects