Name | llm-jq JSON |
Version |
0.1.1
JSON |
| download |
home_page | None |
Summary | Write and execute jq programs with the help of LLM |
upload_time | 2024-10-27 04:38:53 |
maintainer | None |
docs_url | None |
author | Simon Willison |
requires_python | >=3.9 |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# llm-jq
[![PyPI](https://img.shields.io/pypi/v/llm-jq.svg)](https://pypi.org/project/llm-jq/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm-jq?include_prereleases&label=changelog)](https://github.com/simonw/llm-jq/releases)
[![Tests](https://github.com/simonw/llm-jq/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/llm-jq/actions/workflows/test.yml)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-jq/blob/main/LICENSE)
Write and execute jq programs with the help of LLM
See [Run a prompt to generate and execute jq programs using llm-jq](https://simonwillison.net/2024/Oct/27/llm-jq/) for background on this project.
## Installation
Install this plugin in the same environment as [LLM](https://llm.datasette.io/).
```bash
llm install llm-jq
```
## Usage
Pipe JSON directly into `llm jq` and describe the result you would like:
```bash
curl -s https://api.github.com/repos/simonw/datasette/issues | \
llm jq 'count by user.login, top 3'
```
Output:
```json
[
{
"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:
```bash
cd llm-jq
python -m venv venv
source venv/bin/activate
```
Now install the dependencies and test dependencies:
```bash
llm install -e '.[test]'
```
To run the tests:
```bash
python -m pytest
```
Raw data
{
"_id": null,
"home_page": null,
"name": "llm-jq",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": null,
"author": "Simon Willison",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/70/0c/ba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b/llm_jq-0.1.1.tar.gz",
"platform": null,
"description": "# llm-jq\n\n[![PyPI](https://img.shields.io/pypi/v/llm-jq.svg)](https://pypi.org/project/llm-jq/)\n[![Changelog](https://img.shields.io/github/v/release/simonw/llm-jq?include_prereleases&label=changelog)](https://github.com/simonw/llm-jq/releases)\n[![Tests](https://github.com/simonw/llm-jq/actions/workflows/test.yml/badge.svg)](https://github.com/simonw/llm-jq/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-jq/blob/main/LICENSE)\n\nWrite and execute jq programs with the help of LLM\n\nSee [Run a prompt to generate and execute jq programs using llm-jq](https://simonwillison.net/2024/Oct/27/llm-jq/) for background on this project.\n\n## Installation\n\nInstall this plugin in the same environment as [LLM](https://llm.datasette.io/).\n```bash\nllm install llm-jq\n```\n## Usage\n\nPipe JSON directly into `llm jq` and describe the result you would like:\n\n```bash\ncurl -s https://api.github.com/repos/simonw/datasette/issues | \\\n llm jq 'count by user.login, top 3'\n```\nOutput:\n```json\n[\n {\n \"login\": \"simonw\",\n \"count\": 11\n },\n {\n \"login\": \"king7532\",\n \"count\": 5\n },\n {\n \"login\": \"dependabot[bot]\",\n \"count\": 2\n }\n]\n```\n```\ngroup_by(.user.login) | map({login: .[0].user.login, count: length}) | sort_by(-.count) | .[0:3]\n```\nThe JSON is printed to standard output, the jq program is printed to standard error.\n\nOptions:\n\n- `-s/--silent`: Do not print the jq program to standard error\n- `-o/--output`: Output just the jq program, do not run it\n- `-v/--verbose`: Show the prompt sent to the model and the response\n- `-m/--model X`: Use a model other than the configured LLM default model\n- `-/--length X`: Use a length of the input other than 1024 as the example\n\nBy 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.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n```bash\ncd llm-jq\npython -m venv venv\nsource venv/bin/activate\n```\nNow install the dependencies and test dependencies:\n```bash\nllm install -e '.[test]'\n```\nTo run the tests:\n```bash\npython -m pytest\n```\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Write and execute jq programs with the help of LLM",
"version": "0.1.1",
"project_urls": {
"CI": "https://github.com/simonw/llm-jq/actions",
"Changelog": "https://github.com/simonw/llm-jq/releases",
"Homepage": "https://github.com/simonw/llm-jq",
"Issues": "https://github.com/simonw/llm-jq/issues"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "358ce681accf36bbbd53ac429013103bf572838bb509686d64f8420cb5b6eb94",
"md5": "6178125d504fca27d232f53696662e5e",
"sha256": "6b3f0a87784c29fcce079cd2c5c07aa2e2cb53a178a2ad3c951fc399f3375a78"
},
"downloads": -1,
"filename": "llm_jq-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6178125d504fca27d232f53696662e5e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 8102,
"upload_time": "2024-10-27T04:38:52",
"upload_time_iso_8601": "2024-10-27T04:38:52.594070Z",
"url": "https://files.pythonhosted.org/packages/35/8c/e681accf36bbbd53ac429013103bf572838bb509686d64f8420cb5b6eb94/llm_jq-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "700cba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b",
"md5": "7c8e9aed5b66eada17a034681ad79558",
"sha256": "db25d6fddedf70e2d71617aac2093ebf68f650406bfb2b743b465dfa1b147ee2"
},
"downloads": -1,
"filename": "llm_jq-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "7c8e9aed5b66eada17a034681ad79558",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 8213,
"upload_time": "2024-10-27T04:38:53",
"upload_time_iso_8601": "2024-10-27T04:38:53.889016Z",
"url": "https://files.pythonhosted.org/packages/70/0c/ba6423f81724ee2dfba1c3d26a487857d0ed9c9b898d58222497937bae9b/llm_jq-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-27 04:38:53",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "simonw",
"github_project": "llm-jq",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "llm-jq"
}