{"id":13545201,"url":"https://github.com/Mattie/cataclysm","last_synced_at":"2025-04-02T15:31:00.030Z","repository":{"id":149599368,"uuid":"617583647","full_name":"Mattie/cataclysm","owner":"Mattie","description":"Cataclysm - Code generation library for the end game","archived":false,"fork":false,"pushed_at":"2023-10-18T00:16:37.000Z","size":182,"stargazers_count":406,"open_issues_count":13,"forks_count":44,"subscribers_count":15,"default_branch":"master","last_synced_at":"2024-11-03T12:32:08.717Z","etag":null,"topics":["chatgpt","gpt4","openai","plunkylib","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mattie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-22T17:30:33.000Z","updated_at":"2024-10-02T06:28:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1984838-dd83-4503-9fa8-51106a001a85","html_url":"https://github.com/Mattie/cataclysm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattie%2Fcataclysm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattie%2Fcataclysm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattie%2Fcataclysm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mattie%2Fcataclysm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mattie","download_url":"https://codeload.github.com/Mattie/cataclysm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246841614,"owners_count":20842621,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chatgpt","gpt4","openai","plunkylib","python"],"created_at":"2024-08-01T11:00:58.988Z","updated_at":"2025-04-02T15:31:00.024Z","avatar_url":"https://github.com/Mattie.png","language":"Python","readme":"# Cataclysm - End Game for Developers\n\n##  Embrace the End\n`cataclysm` is the end of mortal coding. Let inhuman intelligence write your code based on context.\n\n```python\n\u003e\u003e\u003e from cataclysm import consume\n\u003e\u003e\u003e consume(globals())\n\n\u003e\u003e\u003e x = get_italicized_phrases_wikipedia(page=\"Global catastrophic risk\", only_lowercase_words=True, min_length=6)\n\u003e\u003e\u003e print(x[:5])\n['existential risks', 'existential catastrophe[16]', 'global', 'terminal', 'permanent,']\n```\n\n## Installation\n```bash\npip install cataclysm\n\n# in your project directory, copy the default datafiles\ncataclysm init\n```\n\n### Configure API keys\nOur demise is powered by OpenAI GPT4, so you'll need an API key from them.\n\nUse `init` or copy `env.template.cataclysm` to `.env` in your working/app directory and add your API keys there:\n```\nOPENAI_API_KEY = \"ADD_YOUR_OPENAI_KEY\"\n```\n\n## Usage (Modes)\n### Global Cataclysm\nWith a global cataclysm, fresh code will be generated for any unrecognized function anywhere. You just need a descriptive function name, arguments, and maybe some comments for context. The rest is up to Them.\n\n```python\n\u003e\u003e\u003e from cataclysm import consume\n\u003e\u003e\u003e consume(globals())\n\u003e\u003e\u003e s = \"May the gods have mercy on us all\"\n\u003e\u003e\u003e corrupted = convert_some_words_to_disturbing_unicode_text(s, \"mercy on us\")\n\u003e\u003e\u003e print_surrounded_by_ascii_art_of_an_old_scroll(corrupted, use_wcwidth_for_padding=True)\n _________________________\n| May the gods have m̜ͯ̂e͂ͦͥr̻̭͗c̳͖̍y̹̋̑  |\n| o̵̰͒n̘͋͟ u̜͊ͤs̍͒͑ all                |\n ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯\n```\nOr maybe you wish to channel the energies to solve harder problems...\n```python\ngraph = {\n    \"A\": {\"B\": 10, \"C\": 4},\n    \"B\": {\"A\": 1, \"C\": 2, \"D\": 5},\n    \"C\": {\"A\": 4, \"B\": 2, \"D\": 9},\n    \"D\": {\"B\": 5, \"C\": 1},\n}\n\n# Why google it when you can throw yourself headlong into eternity?\nshortest_path = find_shortest_path_dijkstra(graph, \"A\", \"D\")\nprint(f\"Shortest path: {shortest_path}\")\n```\n\u003e `Shortest path: ['A', 'C', 'B', 'D']`\n\nWhile `consume()` can be used for experimental purposes in notebooks and in interactive modes, it's not designed to be used in libraries or apps. If you'd like to experiment, consume() is great, but you'll need the `doom` module to make an app cataclysmic.\n\n### **Doom** (Recommended)\nMortals unwilling to face a global cataclysm can face their `doom` instead. Recommended if you wish to use these powers in libraries or apps.\n\n```python\n\u003e\u003e\u003e from cataclysm import doom\n\u003e\u003e\u003e uhoh = doom.first_prime_with_3_digits()\n\u003e\u003e\u003e print(uhoh)\n101\n```\n\n### **Impending Doom** (Preview Mode)\nIf you fear a `cataclysm`, your impending doom can be generated and previewed via `doom.impending`.\n\n```python\n\u003e\u003e\u003e from cataclysm import doom\n\u003e\u003e\u003e dump_unexecuted_code_str = doom.impending.say_stuff(\"YOU ARE DOOMED\")\n\u003e\u003e\u003e print(dump_unexecuted_code_str)\n[... code dump ...]\n```\n\n### **Chosen Doom** (Frozen Mode)\nIf you've chosen your own `doom`, you can  impending doom can be generated and previewed via `doom.impending`.\n\n```python\n\u003e\u003e\u003e from cataclysm import doom\n\u003e\u003e\u003e dump_unexecuted_code_str = doom.impending.say_stuff(\"YOU ARE DOOMED\")\n\u003e\u003e\u003e print(dump_unexecuted_code_str)\n[... code dump ...]\n```\n\n## Useful Resources and Examples\n\n* [Youtube Overview](https://youtu.be/ZK8fUuQDgZ4)\n* [Notebook - Getting Started With The End](notebooks/GettingStartedWithTheEnd-cataclysm.ipynb)\n* [Example Apps](examples/)\n* [Tests](tests/)\n\n\n## Frequently Asked Questions (FAQ)\n\n### Is `cataclysm` safe?\n\n\u003e That's not the word I would use. The library name should give you a hint, but to be explicit:\n\n**WARNING: The `cataclysm` could destroy you and everything you hold dear. If you proceed, you face your `doom` alone-- no one else can be blamed for your folly.**\n\n### Sounds scary, but isn't `cataclysm` the future of coding?\n\n\u003e While GPT4 has never done anything wrong to me (as reckless as I am trusting its code), this is a dangerous and mysterious power that only the maddest of mortals should wield. There are great, dark powers beyond our comprehension at work. Alien minds are not to be trifled with.\n\u003e \n\u003e The prompt(s) used for `doom` intentionally discourage the LLM from using any local I/O except where it is explicitly sought. Yet it could be tricked, confused, misled, or gain an unexpected hunger for destruction. You have been warned.\n\u003e \n\u003e *I personally see AI-generated code a lot like how GPS was initially-- following it blindly will sometimes lead you to drive into a lake. Yet, over the years, many of us depend on GPS every day and wouldn't drive anywhere without it. I put Codex and GPT 3.5 (original ChatGPT) in the former camp. GPT4+ is really impressive thus far, but not without dangerous quirks.*\n\n### How do I access the `cataclysm`?\n\n\u003e You'll need the `cataclysm` from PyPI-- install it via `pip install cataclysm`.\n\n### What forces are at work to bring about `cataclysm`?\n\n\u003e  The devastation is powered by OpenAI's ChatGPT API for the `gpt-4` large language model (LLM). It also works with  `gpt-3.5-turbo`, but GPT4+ is highly recommended. The API is called via `plunkylib` (a yaml-friendly layer not totally unlike `langchain`), so you need an OpenAI API key. Include your own API key in your `.env` file, using `.env.template` as a reference.\n\n### Can I experiment with a weaker `cataclysm` using `gpt-3.5-turbo`?\n\n\u003e  To do so, edit `datafiles/plunkylib/petitions/CataclysmQuery.yml` to reference `CataclysmLLMParams_3-5` instead of `CataclysmLLMParams`. Your doom will be less impressive, but faster and less expensive.\n\n### What if I don't have an OpenAI account or API key?\n\n\u003e I'm considering ways to grow the `cataclysm` to enhance code generation via a more powerful hosted API. Reach out if you would be interested in this.\n\n### Does it call OpenAI constantly? That seems excessive.\n\n\u003e Those dark powers are tempting to use, but `cataclysm` locally caches code created for each function signature. The second+ time it is called, the cached code is used-- so it'll be a lot faster. It's recommended that if you are insane enough to ship code using `cataclysm` that you ship the code files. If you wish to `doom` generation, you can use `doom.chosen` to ensure the released code never tries to generate any code. If you want to look at the code for a generation, they typically live in `./datafiles/cataclysm/code/\u003cfunctionname\u003e.yml` or can be previewed with `doom.impending`.\n\u003e \n\u003e Note that when code is first generated and exec'd, if there is an error raised, it will re-generate the code one more time and try again. If it fails then, you've stumped the AI and you may need to provide more guidance (or install more modules).\n\n### What fate awaits me if I choose `cataclysm`+`consume()` over `doom`?\n\n\u003e Embracing `cataclysm` consumes globals(), letting any unrecognized function unleash AI-generated code. `doom`, however, demands explicit invocation, granting you some illusion of control of your fate.\n\n### Can `cataclysm`/`doom` really code anything?\n\n\u003e It's pretty good at doing simple things and surprisingly decent at doing complex things. You will have to explore the `cataclysm` to understand its limitations. You can see some working examples in the `notebooks` folder, `examples` folder and some tests in the `tests` folder.\n\u003e I'm experimenting with a mode that allows `cataclysm` to recursively use itself to generate code. This path is a scary one, but may be even more impressive.\n\n### How do I peer into the impending `doom` without unleashing it?\n\n\u003e With `doom.impending`, you can glimpse into the abyss without invoking the new code. This is ideal for those who want to learn how it behaves in response to changes in comments, keyword arguments, docstrings, modules, and function signatures.\n\n### What does `cataclysm` inspect to make its decisions on what to code?\n\n\u003e As of now it looks at your function signatures, call stacks, keyword argument names, docstrings, and even comments to mold the code to serve your mortal wishes. See the notebooks, examples, and tests for reference.\n\n### Can we predict the `cataclysm`? Is the code-generation deterministic / repeatable?\n\n\u003e Once code has been generated for a given function and arguments, it will default to using the generated code every time. So it'll run predictably. You can guarantee that using `doom.chosen`, if you'd like. \n\u003e When it comes to code generation, in theory, `cataclysm` can regenerate the same code, but only if the callstack is the same, as well as the function name, arguments, installed modules, etc. (basically if it's the same exact function call + context). In practice, you will find it difficult to get the exact same code twice, so it's best to use the cached code (or `.chosen`) if you want to be sure.\n\n### What prompts are you using? Can I change the prompts used? \n\n\u003e The prompts are in `default_files/datafiles/plunkylib/prompts/`. These will be changing a lot in the early days of the `cataclysm`, but you are free to experiment on your own. All I ask is that you consider sharing your coolest findings back to the project.\n\n### Can you help my company use generative AI for our software development?\n\n\u003e If you're seeking less cataclysmic ways to wield these dark powers, reach out to Mattie (email format: `username@username.ai`). I'm happy to explore options for helping your company's developers embrace the new reality.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMattie%2Fcataclysm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMattie%2Fcataclysm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMattie%2Fcataclysm/lists"}