Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ notebooks/*.cataclysm

# we don't want completions regardless of name
datafiles/plunkylib/completions/**
datafiles/chatsnack/completions/**

# not code generations (not yet anyway)
datafiles/cataclysm/code*/**
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cataclysm init
```

### Configure API keys
Our demise is powered by OpenAI GPT4, so you'll need an API key from them.
Our demise is powered by OpenAI through chatsnack, so you'll need an API key.

Use `init` or copy `env.template.cataclysm` to `.env` in your working/app directory and add your API keys there:
```
Expand Down Expand Up @@ -81,13 +81,13 @@ If you fear a `cataclysm`, your impending doom can be generated and previewed vi
```

### **Chosen Doom** (Frozen Mode)
If you've chosen your own `doom`, you can impending doom can be generated and previewed via `doom.impending`.
If you've chosen your own `doom`, cached doom can be executed via `doom.chosen` without generating fresh code.

```python
>>> from cataclysm import doom
>>> dump_unexecuted_code_str = doom.impending.say_stuff("YOU ARE DOOMED")
>>> print(dump_unexecuted_code_str)
[... code dump ...]
>>> result = doom.chosen.say_stuff("YOU ARE DOOMED")
>>> print(result)
[... cached result ...]
```

## Useful Resources and Examples
Expand Down Expand Up @@ -120,11 +120,11 @@ If you've chosen your own `doom`, you can impending doom can be generated and p

### What forces are at work to bring about `cataclysm`?

> 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.
> The devastation is powered by OpenAI's API through `chatsnack`, so you need an OpenAI API key. Include your own API key in your `.env` file, using `.env.template` as a reference.

### Can I experiment with a weaker `cataclysm` using `gpt-3.5-turbo`?
### Can I experiment with a weaker `cataclysm` using a cheaper model?

> 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.
> To do so, edit `datafiles/chatsnack/CataclysmQuery.yml` and set the `params.model` value to a faster or less expensive model. Your doom will be less impressive, but faster and less expensive.

### What if I don't have an OpenAI account or API key?

Expand Down Expand Up @@ -160,7 +160,7 @@ If you've chosen your own `doom`, you can impending doom can be generated and p

### What prompts are you using? Can I change the prompts used?

> 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.
> The prompt is in `datafiles/chatsnack/CataclysmQuery.yml` after `cataclysm init`, with the packaged default in `cataclysm/default_files/datafiles/chatsnack/`. 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.

### Can you help my company use generative AI for our software development?

Expand Down
23 changes: 12 additions & 11 deletions cataclysm/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from loguru import logger
import logging
import os
from plunkylib import PLUNKYLIB_BASE_DIR

CHATSNACK_BASE_DIR = os.getenv("CHATSNACK_BASE_DIR", "./datafiles/chatsnack").rstrip("/\\")

# if there's no "CATACLYSM_BASE_DIR" env variable, set it to './datafiles/cataclysm'
# this is the default directory for all cataclysm datafiles
Expand All @@ -24,15 +25,17 @@
# Add the file sink to Loguru's sinks
logger.add(**file_sink)

# disable debug logging for the plunkylib module
logger.disable("plunkylib")
# disable debug logging for the chatsnack module
logger.disable("chatsnack")
# disable warning logging for the datafiles module
logger.disable("datafiles")

logging.getLogger("datafiles").setLevel(logging.ERROR)


def initialize_datafiles(base_dir = "."):
chatsnack_base_dir = os.getenv("CHATSNACK_BASE_DIR", "./datafiles/chatsnack").rstrip("/\\")

# Replace this with the name of your package
def get_top_level_package_name():
return __name__.split('.')[0]
Expand All @@ -41,19 +44,15 @@ def get_top_level_package_name():
print("package_name: " + package_name)

minimum_file_suffixes = [
f"datafiles/plunkylib/petition/CataclysmQuery.yml",
f"datafiles/plunkylib/prompts/CataclysmPrompt.yml",
f"datafiles/plunkylib/params/CataclysmLLMParams.yml",
f"datafiles/plunkylib/params/CataclysmLLMParams_3-5.yml",
f".env.template.cataclysm"
f"datafiles/chatsnack/CataclysmQuery.yml",
f"env.template.cataclysm"
]

from pkg_resources import resource_filename
import shutil
def copy_files_to_destination(package_name, file_suffixes, destination):
for file_suffix in file_suffixes:
# replace 'datafiles/plunkylib' in the suffix with PLUNKYLIB_BASE_DIR
dest_file_suffix = file_suffix.replace("datafiles/plunkylib", PLUNKYLIB_BASE_DIR)
dest_file_suffix = file_suffix.replace("datafiles/chatsnack", chatsnack_base_dir)
dest_filename = os.path.join(destination, dest_file_suffix)
if not os.path.exists(dest_filename):
print("Copying default datafiles to " + dest_filename)
Expand All @@ -66,7 +65,9 @@ def copy_files_to_destination(package_name, file_suffixes, destination):
print("destination_file: " + destination_file)

# Create any necessary directories in the destination path
os.makedirs(os.path.dirname(destination_file), exist_ok=True)
destination_dir = os.path.dirname(destination_file)
if destination_dir:
os.makedirs(destination_dir, exist_ok=True)

# Copy the file
shutil.copy2(source_file, destination_file)
Expand Down
23 changes: 12 additions & 11 deletions cataclysm/__main__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from loguru import logger
import logging
import os
from plunkylib import PLUNKYLIB_BASE_DIR

CHATSNACK_BASE_DIR = os.getenv("CHATSNACK_BASE_DIR", "./datafiles/chatsnack").rstrip("/\\")

# if there's no "CATACLYSM_BASE_DIR" env variable, set it to './datafiles/cataclysm'
# this is the default directory for all cataclysm datafiles
Expand All @@ -24,8 +25,8 @@
# Add the file sink to Loguru's sinks
logger.add(**file_sink)

# disable debug logging for the plunkylib module
logger.disable("plunkylib")
# disable debug logging for the chatsnack module
logger.disable("chatsnack")
# disable warning logging for the datafiles module
logger.disable("datafiles")

Expand All @@ -34,26 +35,24 @@

def initialize_datafiles(base_dir = "."):
print("cataclysm - initializing datafiles in directory: " + base_dir)
chatsnack_base_dir = os.getenv("CHATSNACK_BASE_DIR", "./datafiles/chatsnack").rstrip("/\\")

# Replace this with the name of your package
def get_top_level_package_name():
return __name__.split('.')[0]

package_name = get_top_level_package_name()

minimum_file_suffixes = [
f"datafiles/plunkylib/petition/CataclysmQuery.yml",
f"datafiles/plunkylib/prompts/CataclysmPrompt.yml",
f"datafiles/plunkylib/params/CataclysmLLMParams.yml",
f"datafiles/plunkylib/params/CataclysmLLMParams_3-5.yml",
f"datafiles/chatsnack/CataclysmQuery.yml",
f"env.template.cataclysm"
]

from pkg_resources import resource_filename
import shutil
def copy_files_to_destination(package_name, file_suffixes, destination):
for file_suffix in file_suffixes:
# replace 'datafiles/plunkylib' in the suffix with PLUNKYLIB_BASE_DIR
dest_file_suffix = file_suffix.replace("datafiles/plunkylib", PLUNKYLIB_BASE_DIR)
dest_file_suffix = file_suffix.replace("datafiles/chatsnack", chatsnack_base_dir)
dest_filename = os.path.join(destination, dest_file_suffix)
if not os.path.exists(dest_filename):
print(" Copying default file to " + dest_filename)
Expand All @@ -66,7 +65,9 @@ def copy_files_to_destination(package_name, file_suffixes, destination):
print(" destination_file: " + destination_file)

# Create any necessary directories in the destination path
os.makedirs(os.path.dirname(destination_file), exist_ok=True)
destination_dir = os.path.dirname(destination_file)
if destination_dir:
os.makedirs(destination_dir, exist_ok=True)

# Copy the file
shutil.copy2(source_file, destination_file)
Expand Down Expand Up @@ -109,4 +110,4 @@ def main():


if __name__ == "__main__":
main()
main()
Loading