Rules import format to use LLMs/AI/ChatGPT with Hazel?

Talk, speculate, discuss, pontificate. As long as it pertains to Hazel.

Moderators: Mr_Noodle, Moderators

Hi all --

I'd like to use AI to help me configure new Hazel rules more quickly, as it seems like ChatGPT and the like have gotten to the point where they can do this pretty well. Is there a documented file format for creating rules outside of Hazel and then importing them?

Thanks!
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

Document format is not public and not something I would recommend writing out directly. Also, I would make sure to understand any rules that are AI generated. I have seen some gross misconceptions and inaccuracies.
Mr_Noodle
Site Admin
 
Posts: 11817
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I definitely agree that any generated rules or configurations need to be reviewed before used. But it still seems like it is worth exploring. I tried giving it a sample YAML-based format that I think is probably similar to what Hazel uses under the hood. then described one of the Hazel rules I created by hand:

Image

Here's the prompt, slightly expanded on the above:

I'd like a YAML configuration in this format to recognize and process my Wells Fargo mortgage statements and rename them to something like "2025-01-14 - Wells Fargo - Mortage Statement - XX6789 ($123,000.00).pdf". The PDF will have the text "WELLS FARGO HOME MORTGAGE" and "Property Location" on the first page. It will also have an account number in format "Account Number: 123456789", and I'd like the last 4 digits of the account number to be used in the filename. It will also have "Unpaid Principal Balance: <balance>" and I'd like that balance to be included in parentheses in the filename.

It produced this, which IMO is a pretty good start. Hazel's GUI features, including ability to preview and debug, would be ideal for reviewing and confirming this actually behaves as expected.

Code: Select all
rules:
  - name: Process Wells Fargo Mortgage Statements
    criteria:
        - extension: pdf
        - content:
            contains:
                - "WELLS FARGO HOME MORTGAGE"
                - "Property Location"
        # Extract the statement date (format: MM/DD/YY)
        - match:
            content: 'Statement date (\d{2})/(\d{2})/(\d{2})'
            as-variable: statement_date_raw
   
        # Convert statement date to YYYY-MM-DD format
        - set:
            variable: statement_date
            from-value: '20{statement_date_raw[2]}-{statement_date_raw[0]}-{statement_date_raw[1]}'
           
        # Extract the 9-digit account number
        - match:
            content: 'Account Number: (\d{9})'
            as-variable: account_number
   
        # Extract the unpaid principal balance
        - match:
            content: 'Unpaid Principal Balance: \$([\d,]+(?:\.\d{2})?)'
            as-variable: unpaid_balance
   
        # Extract last 4 digits of account number
        - set:
            variable: account_last4
            from-value: 'XX{account_number[-4:]}'
   
        # Rename and move if everything is found
        - rename:
            name: '{statement_date} - Wells Fargo - Mortgage Statement - {account_last4} (${unpaid_balance}).pdf'
            if: 'statement_date and account_number and unpaid_balance'
           
        - move:
            folder: '~/Documents/Wells Fargo/Mortgage Statements/'
            if: 'statement_date and account_number and unpaid_balance'
   
        # Move to "Needs Review" if extraction fails
        - move:
            folder: '~/Documents/Wells Fargo/Needs Review/'
            if: 'not (statement_date and account_number and unpaid_balance)'
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm

There are a lot of features in the rule schema and it would take a very good deal of work to create an alternate format just for this case, plus it would slow down addition of new features from that point onwards.
Mr_Noodle
Site Admin
 
Posts: 11817
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Understood. I hope you'll consider some way of integrating this sort of capability in Hazel in the future. FWIW it doesn't need to be via an import/export format. I imagine we will soon be at the point where you could embed a small LLM model in the app itself, very secure/privacy-constrained, to help quickly spin up new rules.
felciano
 
Posts: 30
Joined: Sat Feb 23, 2013 5:44 pm


Return to Open Discussion