Write and execute jq programs with the help of LLM
Project description
llm-jq
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | db25d6fddedf70e2d71617aac2093ebf68f650406bfb2b743b465dfa1b147ee2 |
|
MD5 | 7c8e9aed5b66eada17a034681ad79558 |
|
BLAKE2b-256 | 700cba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b3f0a87784c29fcce079cd2c5c07aa2e2cb53a178a2ad3c951fc399f3375a78 |
|
MD5 | 6178125d504fca27d232f53696662e5e |
|
BLAKE2b-256 | 358ce681accf36bbbd53ac429013103bf572838bb509686d64f8420cb5b6eb94 |