# Cataclysm

Cataclysm is a Python library that generates and executes code at runtime for any undefined function call, inferring an implementation from the function's name, arguments and surrounding context through an LLM.

Cataclysm lets Python code call functions that were never defined: it infers an implementation from the function's name, its arguments and any nearby comments, generates code for it using an LLM, and runs the result. A global consume() mode generates fresh code for any unrecognized function anywhere in scope, useful for quick experimentation in notebooks or interactive sessions.

For use inside libraries or applications, a separate doom module generates and executes a single function at a time rather than acting globally, and preview modes let a developer inspect the code Cataclysm would generate, either once (impending) or as a fixed, reusable version (chosen doom), before it runs. It requires an OpenAI API key, since generation is powered by GPT-4, and installs via pip with an init command that copies default configuration files into a project.

Website: https://github.com/Mattie/cataclysm
