Skip to main content

llm-jq

PyPI Changelog Tests License

Write and execute jq programs with the help of LLM

See Run a prompt to generate and execute jq programs using llm-jq for background on this project.

Installation

Install this plugin in the same environment as LLM.

llm install llm-jq

Usage

Pipe JSON directly into llm jq and describe the result you would like:

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

Output:

[
  {
    "login": "simonw",
    "count": 11
  },
  {
    "login": "king7532",
    "count": 5
  },
  {
    "login": "dependabot[bot]",
    "count": 2
  }
]
group_by(.user.login) | map({login: .[0].user.login, count: length}) | sort_by(-.count) | .[0:3]

The JSON is printed to standard output, the jq program is printed to standard error.

Options:

  • -s/--silent: Do not print the jq program to standard error
  • -o/--output: Output just the jq program, do not run it
  • -v/--verbose: Show the prompt sent to the model and the response
  • -m/--model X: Use a model other than the configured LLM default model
  • -/--length X: Use a length of the input other than 1024 as the example

By default, the first 1024 bytes of JSON will be sent to the model as an example along with your description. You can use -l to send more or less example data.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd llm-jq
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

llm install -e '.[test]'

To run the tests:

python -m pytest

Release files for llm-jq 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-jq 0.1.1
File Size Uploaded
llm_jq-0.1.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-jq 0.1.1
File Interpreter ABI Platform
llm_jq-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.3 kB

Release files / llm_jq-0.1.1.tar.gz

Download URL llm_jq-0.1.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
db25d6fddedf70e2d71617aac2093ebf68f650406bfb2b743b465dfa1b147ee2
BLAKE2b-256 checksum
How to use checksums
700cba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / llm_jq-0.1.1-py3-none-any.whl

Download URL llm_jq-0.1.1-py3-none-any.whl
Size 8.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6b3f0a87784c29fcce079cd2c5c07aa2e2cb53a178a2ad3c951fc399f3375a78
BLAKE2b-256 checksum
How to use checksums
358ce681accf36bbbd53ac429013103bf572838bb509686d64f8420cb5b6eb94
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page