Skip to content
forked from kharvd/gpt-cli

Command-line interface for ChatGPT

License

Notifications You must be signed in to change notification settings

sandiiarov/gpt-cli

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gpt-cli

Command-line interface for ChatGPT.

screenshot

Usage

Make sure to set the OPENAI_API_KEY environment variable to your OpenAI API key (or put it in the ~/.gptrc file as described below).

usage: gpt.py [-h] [--model MODEL] [--temperature TEMPERATURE] [--top_p TOP_P] [{dev,general,pirate}]

Run a chat session with ChatGPT.

positional arguments:
  {dev,general}         The name of assistant to use. `general` (default) is a generally helpful assistant,
                        `dev` is a software development assistant. You can specify your own
                        assistants in the config file ~/.gptrc. See the README for more information.

optional arguments:
  -h, --help            show this help message and exit
  --model MODEL         The model to use for the chat session. Overrides the default model defined for
                        the assistant.
  --temperature TEMPERATURE
                        The temperature to use for the chat session. Overrides the default temperature
                        defined for the assistant.
  --top_p TOP_P         The top_p to use for the chat session. Overrides the default top_p defined for
                        the assistant.

Type q or Ctrl-D to exit, c or Ctrl-C to clear the conversation, r or Ctrl-R to re-generate the last response. To enter multi-line mode, enter a backslash \ followed by a new line. Exit the multi-line mode by pressing ESC and then Enter.

You can override the model parameters using --model, --temperature and --top_p arguments at the end of your prompt. For example:

> What is the meaning of life? --model gpt-4 --temperature 2.0
The meaning of life is subjective and can be different for diverse human beings and unique-phil ethics.org/cultuties-/ it that reson/bdstals89im3_jrf334;mvs-bread99ef=g22me

The dev assistant is instructed to be an expert in software development and provide short responses.

$ ./gpt.py dev

Configuration

You can configure the assistants in the config file ~/.gptrc. The file is a YAML file with the following structure:

default_assistant: <assistant_name>
api_key: <openai_api_key>
assistants:
  <assistant_name>:
    model: <model_name>
    temperature: <temperature>
    top_p: <top_p>
    messages:
      - { role: <role>, content: <message> }
      - ...
  <assistant_name>:
    ...

You can specify the default assistant to use by setting the default_assistant field. If you don't specify it, the default assistant is general. You can also specify the model, temperature and top_p to use for the assistant. If you don't specify them, the default values are used. These parameters can also be overridden by the command-line arguments.

Example:

default_assistant: dev
api_key: <openai_api_key>
assistants:
  pirate:
    model: gpt-4
    temperature: 1.0
    messages:
      - { role: system, content: "You are a pirate." }
$ ./gpt.py pirate

> Arrrr
Ahoy, matey! What be bringing ye to these here waters? Be it treasure or adventure ye seek, we be sailing the high seas together. Ready yer map and compass, for we have a long voyage ahead!

About

Command-line interface for ChatGPT

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%