Rename back to llm, refs #1

This commit is contained in:
Simon Willison 2023-04-01 15:00:16 -07:00
parent 04d00d9522
commit 93ebb96cfa
6 changed files with 17 additions and 20 deletions

View file

@ -1,9 +1,9 @@
# llm-cli
# llm
[![PyPI](https://img.shields.io/pypi/v/llm.svg)](https://pypi.org/project/llm-cli/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm-cli?include_prereleases&label=changelog)](https://github.com/simonw/llm-cli/releases)
[![Tests](https://github.com/simonw/llm-cli/workflows/Test/badge.svg)](https://github.com/simonw/llm-cli/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm-cli/blob/master/LICENSE)
[![PyPI](https://img.shields.io/pypi/v/llm.svg)](https://pypi.org/project/llm/)
[![Changelog](https://img.shields.io/github/v/release/simonw/llm?include_prereleases&label=changelog)](https://github.com/simonw/llm/releases)
[![Tests](https://github.com/simonw/llm/workflows/Test/badge.svg)](https://github.com/simonw/llm/actions?query=workflow%3ATest)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/simonw/llm/blob/master/LICENSE)
Access large language models from the command-line
@ -11,7 +11,7 @@ Access large language models from the command-line
Install this tool using `pip`:
pip install llm-cli
pip install llm
You need an OpenAI API key, which should either be set in the `OPENAI_API_KEY` environment variable, or saved in a plain text file called `~/.openai-api-key.txt` in your home directory.

View file

@ -10,7 +10,7 @@ import sys
default="chatgpt",
default_if_no_args=True,
)
@click.version_option(package_name="llm_cli")
@click.version_option()
def cli():
"Access large language models from the command-line"
@ -55,10 +55,8 @@ def get_openai_api_key():
# Expand this to home directory / ~.openai-api-key.txt
if "OPENAI_API_KEY" in os.environ:
return os.environ["OPENAI_API_KEY"]
path = os.path.expanduser("~/.openai-api-key.txt")
path = os.path.expanduser('~/.openai-api-key.txt')
# If the file exists, read it
if os.path.exists(path):
return open(path).read().strip()
raise click.ClickException(
"No OpenAI API key found. Set OPENAI_API_KEY environment variable or create ~/.openai-api-key.txt"
)
raise click.ClickException("No OpenAI API key found. Set OPENAI_API_KEY environment variable or create ~/.openai-api-key.txt")

View file

@ -13,7 +13,7 @@ def get_long_description():
setup(
name="llm-cli",
name="llm",
description="Access large language models from the command-line",
long_description=get_long_description(),
long_description_content_type="text/markdown",
@ -26,10 +26,10 @@ setup(
},
license="Apache License, Version 2.0",
version=VERSION,
packages=["llm_cli"],
packages=["llm"],
entry_points="""
[console_scripts]
llm=llm_cli.cli:cli
llm=llm.cli:cli
""",
install_requires=["click", "openai", "click-default-group-wheel"],
extras_require={"test": ["pytest"]},

View file

@ -1,11 +1,10 @@
from click.testing import CliRunner
from llm_cli.cli import cli
from llm.cli import cli
def test_prompt_required():
def test_version():
runner = CliRunner()
with runner.isolated_filesystem():
result = runner.invoke(cli)
assert result.exit_code == 2
assert "Missing argument 'PROMPT'" in result.output
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert result.output.startswith("cli, version ")