Home Blog CV Projects Patterns Notes Book Colophon Search

LLM Tree and Cat for Prompt Editing

25 Jun, 2024

When working with LLMs like ChatGPT 4, 4o etc I regularly find myself editing the first prompt, copying my code and asking a question. Then I revise my code and repeat the process. That way the LLM never gets confused by previous dead-ends or wooly thinking on my part.

This script is a handy way to print everything I need from a git repo so I can copy and paste it in one chunk into my prompt. It ignores files not tracked by git. It is also a handy way of preparing a blog post :)

#!/bin/bash

# Generate the directory tree for files tracked by git, including the current directory
echo "Directory tree:"
echo
echo '````'
tree --gitignore .
echo '````'

# Iterate through each file tracked by git and print its name and contents in markdown format
git -C "$PWD" ls-files -z | while IFS= read -r -d '' file; do
  echo
  echo "File \`$file\`:"
  echo
  echo '````'
  cat "$file"
  echo '````'
  echo
done

Then use like this:

% ./tree-and-cat.sh

While I'm talking about LLMs, this is my favourite summary of the space so far from Hamel Husain:

LLM bullshit knife, to cut through bs

RAG ->              Provide relevant context
Agentic ->          Function calls that work
CoT ->              Prompt model to think/plan
FewShot ->          Add examples
PromptEng ->        Someone w/good written comm skills.
Prompt Optimizer -> For loop to find best examples.

It really summarises everything you can really do today to get good outputs. I find it hard to think in terms of the descriptions on the left, but very easy to apply the concepts on the right.

People I talk to are still massively underestimating what the latest LLMs can do (certainly once you think about LLMs checking the output from other LLMs to get a good overall output) while at the same time getting drawn into the hype and expecting them to be better-than-human at everything already, which is a shame because there is a lot of potential with where we are already.

Also, a lot of people I talk to don't realise that you can run them on your own laptop without an internet connection - yes, you can get an entire internet's worth of knowledge compressed into a file you can download and run locally.

I haven't used Google for a while, but now I don't really use any search engines either. ChatGPT gives better answers which I can then lookup to check if I want to.

Comments

Be the first to comment.

Add Comment





Copyright James Gardner 1996-2020 All Rights Reserved. Admin.