Skip to main content

Write and execute jq programs with the help of LLM

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llm_jq-0.1.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

llm_jq-0.1.1-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file llm_jq-0.1.1.tar.gz.

File metadata

  • Download URL: llm_jq-0.1.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for llm_jq-0.1.1.tar.gz
Algorithm Hash digest
SHA256 db25d6fddedf70e2d71617aac2093ebf68f650406bfb2b743b465dfa1b147ee2
MD5 7c8e9aed5b66eada17a034681ad79558
BLAKE2b-256 700cba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b

See more details on using hashes here.

File details

Details for the file llm_jq-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: llm_jq-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for llm_jq-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b3f0a87784c29fcce079cd2c5c07aa2e2cb53a178a2ad3c951fc399f3375a78
MD5 6178125d504fca27d232f53696662e5e
BLAKE2b-256 358ce681accf36bbbd53ac429013103bf572838bb509686d64f8420cb5b6eb94

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page