An OpenAI LLM based CLI coding assistant.
Project description
llm-code
An OpenAI LLM based CLI coding assistant.
llm-code
is inspired by
Simon Wilson's
llm package. It takes a similar approach of developing
a simple tool to create an LLM based assistant that helps write code.
Installation
pipx install llm-code
Usage
llm-code --help
Usage: llm-code [OPTIONS] [INSTRUCTIONS]...
Ask for code completion from OpenAI's chat models.
Options:
-i, --inputs TEXT Glob of input files.
--help Show this message and exit.
Examples
Simple hello world.
llm-code write hello world in rust
fn main() {
println!("Hello, world!");
}
Sum of two numbers with type hints.
llm-code write a function that takes a list of numbers and returns the sum of the numbers in python. Add type hints.
from typing import List
def sum_numbers(numbers: List[int]) -> int:
return sum(numbers)
Lets assume that we stuck the output of the previous call in out.py
. We can now say:
llm-code -i out.py add appropriate docstrings
from typing import List
def sum_numbers(numbers: List[int]) -> int:
"""Return the sum of the given list of numbers."""
return sum(numbers)
Or we could write some unit tests.
llm-code -i out.py write a complete unit test file using pytest.
import pytest
from typing import List
from my_module import sum_numbers
def test_sum_numbers():
assert sum_numbers([1, 2, 3]) == 6
assert sum_numbers([-1, 0, 1]) == 0
assert sum_numbers([]) == 0
TODO
- Add a
--stats
option to output token counts. - Add a simple cache to replay the same query.
- Add logging to a local sqllite db.
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
llm_code-0.2.tar.gz
(5.4 kB
view hashes)
Built Distribution
llm_code-0.2-py3-none-any.whl
(6.9 kB
view hashes)