Skip to content

Commit

Permalink
Rename back to llm, refs #1
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Apr 1, 2023
1 parent 04d00d9 commit 93ebb96
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 20 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# 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

## Installation

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.

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 3 additions & 5 deletions llm_cli/cli.py → llm/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
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"

Expand Down Expand Up @@ -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")
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -26,10 +26,10 @@ def get_long_description():
},
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"]},
Expand Down
11 changes: 5 additions & 6 deletions tests/test_llm.py
Original file line number Diff line number Diff line change
@@ -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 ")

0 comments on commit 93ebb96

Please sign in to comment.