Skip to content

Commit

Permalink
Replace requirements.txt with a pyproject.toml file (kharvd#46)
Browse files Browse the repository at this point in the history
This makes it possible to install the tool with `pip`
  • Loading branch information
kharvd committed Jul 9, 2023
1 parent ee5fad7 commit 131a22b
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
#- name: Lint with flake8
#run: |
# stop the build if there are Python syntax errors or undefined names
Expand Down
26 changes: 8 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ Command-line interface for ChatGPT Claude and Bard.

## Installation

At present, the simplest way is to clone the repository to your machine and then install the tool as described below.

This install assumes a Linux/OSX machine with python and pip available.
This install assumes a Linux/OSX machine with Git, Python and pip available.
```bash
pip install git+https://github.com/kharvd/gpt-cli.git
```

Or install by cloning the repository manually:
```bash
git clone https://github.com/kharvd/gpt-cli
git clone https://github.com/kharvd/gpt-cli.git
cd gpt-cli
pip install -r requirements.txt
pip install .
```

Add the OpenAI API key to your `.bashrc` file (in the root of your home folder).
Expand All @@ -41,19 +43,7 @@ export OPENAI_API_KEY=<your_key_here>
Run the tool

```
./gpt.py
```

If you want to start the program from anywhere, you might want to create an alias in your `.bashrc`.

```
alias gpt="/path/to/gpt-cli/gpt.py"
```

Alternatively, you can create a symbolic link to the executable in a directory that is in your path, like in the following example.

```
ln -s /path/to/gpt-cli/gpt.py /usr/bin/gpt
gpt
```

You can also use a `gpt.yml` file for configuration. See the [Configuration](README.md#Configuration) section below.
Expand Down
File renamed without changes.
14 changes: 13 additions & 1 deletion gptcli/llama.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import os
import sys
from typing import Iterator, List, Optional, TypedDict, cast
from llama_cpp import Completion, CompletionChunk, Llama

try:
from llama_cpp import Completion, CompletionChunk, Llama

LLAMA_AVAILABLE = True
except ImportError:
LLAMA_AVAILABLE = False

from gptcli.completion import CompletionProvider, Message

Expand All @@ -16,6 +22,12 @@ class LLaMAModelConfig(TypedDict):


def init_llama_models(models: dict[str, LLaMAModelConfig]):
if not LLAMA_AVAILABLE:
print(
"Error: To use llama, you need to install cli-gpt with the llama optional dependency: pip install cli-gpt[llama]."
)
sys.exit(1)

for name, model_config in models.items():
if not os.path.isfile(model_config["path"]):
print(f"LLaMA model {name} not found at {model_config['path']}.")
Expand Down
47 changes: 47 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
[project]
name = "cli-gpt"
version = "0.1.0"
description = "Command-line interface for ChatGPT, Claude and Bard"
authors = [{name = "Val Kharitonov", email = "val@kharvd.com"}]
readme = "README.md"
license = {file = "LICENSE"}
requires-python = ">=3.9"
keywords = ["cli", "command-line", "assistant", "openai", "claude", "bard", "gpt-3", "gpt-4", "llm", "chatgpt", "gpt-cli", "google-bard", "anthropic", "gpt-client", "anthropic-claude", "palm2"]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering :: Artificial Intelligence",
]
dependencies = [
"anthropic==0.2.8",
"black==23.1.0",
"google-generativeai==0.1.0",
"openai==0.27.8",
"prompt-toolkit==3.0.38",
"pytest==7.3.1",
"PyYAML==6.0",
"rich==13.3.2",
"tiktoken==0.3.3",
"tokenizers==0.13.3",
"typing_extensions==4.5.0",
]

[project.optional-dependencies]
llama = [
"llama-cpp-python==0.1.57",
]

[project.urls]
"Homepage" = "https://github.com/kharvd/gpt-cli"

[project.scripts]
gpt = "gptcli.gpt:main"

[build-system]
requires = ["pip>=23.0.0", "setuptools>=58.0.0", "wheel"]
build-backend = "setuptools.build_meta"

12 changes: 0 additions & 12 deletions requirements.txt

This file was deleted.

0 comments on commit 131a22b

Please sign in to comment.