Email or username:

Password:

Forgot your password?
Simon Willison

I built a new plugin for LLM called llm-jq, which lets you pipe JSON into the tool and provide a short description of what you want, then it uses an LLM to generate a jq program and executes that against the JSON for you simonwillison.net/2024/Oct/27/

Example usage:

llm install llm-jq
curl -s 'http''s://api.github.com/repos/simonw/datasette/issues' | \
llm jq 'count by user login, top 3'

$ curl -s https://api.github.com/repos/simonw/datasette/issues | \
  llm jq 'count by user.login, top 3'
[
  {
    "key": "simonw",
    "value": 11
  },
  {
    "key": "king7532",
    "value": 5
  },
  {
    "key": "nicfab",
    "value": 2
  }
]
group_by(.user.login) | map({key: .[0].user.login, value: length}) | sort_by(.value) | reverse | .[0:3]

Also shows the system prompt that was used.
4 comments
Michael Hunger

@simon neat. While simple jq programs are easy, i always struggle to make complex ones work quickly so wasting a lot of time. Will try. Thank you!

Michael Hunger

@simon do you pass all or parts of the json to the llm? Or json schema with the instructions? How does it work with large json data? Use a sample?

gavcloud

@simon as someone who wrestled with jq quite a bit, this looks fascinating. thanks for sharing it.

Go Up