chatgpt-cli-md


Namechatgpt-cli-md JSON
Version 0.1.13 PyPI version JSON
download
home_page
SummaryA markdown-supported command-line interface tool that connects to ChatGPT using OpenAI's API key.
upload_time2023-05-18 05:04:45
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2023 Jerry Yang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords chatbot chatgpt chatgpt-cli openai markdown cli command-line
VCS
bugtrack_url
requirements aiohttp aiosignal async-timeout attrs black certifi charset-normalizer click frozenlist idna markdown-it-py mdformat mdformat-gfm mdformat-frontmatter mdformat-footnote mdurl multidict mypy-extensions openai packaging pathspec platformdirs pyreadline3 Pygments PyYAML requests rich tomli tqdm urllib3 yarl
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ChatGPT CLI

[![PyPI](https://img.shields.io/pypi/v/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)
[![PyPI - License](https://img.shields.io/pypi/l/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)
[![Stars](https://img.shields.io/github/stars/efJerryYang/chatgpt-cli)](https://github.com/efJerryYang/chatgpt-cli/stargazers)

[中文](README_zh.md)

## Introduction

ChatGPT CLI is a command-line interface tool that connects to the ChatGPT language model
using OpenAI's official API key. It features markdown support, allowing you to structure
your inputs in a readable and well-organized format for easier reference. The tool also
saves conversations in `JSON` format, you can load them with `!load` command. Commands
provided enable you to use this tool much like you would use the official web client. For
more command usage, you can type `!help` or see more in the [Commands](#commands) section.

Here is a simple demonstration of how to use it:

![demo](docs/demo/ezgif.com-optimize.gif)

<!-- For more detailed information, please check out the `<link_to_docs>`. -->

## Prequisites

To run the ChatGPT CLI tool, you'll need to have Python version 3.8 or higher installed on
your machine. You can check your Python version by typing `python -V` in your terminal. We
require version at least `3.8` because the feature of `importlib.metadata` is only
available from this version. You'll also need an OpenAI API key, which you can easily
[get here](https://platform.openai.com/account/api-keys).

The required Python packages can be installed with `pip install -r requirements.txt`,
which includes the following:

- `openai >= 0.27.0`
- `pyyaml >= 6.0`
- `rich >= 13.3.1`

## Installation

You can install ChatGPT CLI by downloading the package from the
[latest release](https://github.com/efJerryYang/chatgpt-cli/releases) and running either
of the following commands. Note that you will need to replace `<version>` with the version
number of the package you downloaded (e.g. `0.1.0`).

You can also install the package from PyPI by running `pip install chatgpt-cli-md`.

```sh
pip install chatgpt-cli-md-<version>.tar.gz
```

```sh
pip install chatgpt_cli_md-<version>-py3-none-any.whl
```

This will automatically install all the required dependencies. You can also build the
project and get the binary file to install by cloning the repository from GitHub and
running the following commands:

```sh
git clone https://github.com/efJerryYang/chatgpt-cli.git
```

Install necessary dependencies:

```sh
pip install -r requirements.txt
```

Build the project into package:

```sh
python -m build
```

Once built, you can follow the instructions above to install the package. The built
package will be located in `dist` directory.

We highly recommend that you use the latest version of ChatGPT CLI and install it using
the recommended methods for optimal performance and stability.

## Getting Started

After installation, you can start the ChatGPT CLI tool by typing `chatgpt-cli` in your
terminal.

```sh
chatgpt-cli
```

If you are running the tool for the first time, you will be prompted to configure your
`config.yaml` file, and you can also import the `data` directory from your previous script
version. If you do not have a configuration file in the path
`${HOME}/.config/chatgpt-cli/config.yaml`, you can create a new one with the interactive
setup procedure provided by the tool, or you can import the one you have already used in
your previous version. If choose to create a new one, You will need to input your OpenAI
API key and proxy settings (if any). You can also get an OpenAI API key
[here](https://platform.openai.com/account/api-keys) if you do not have one.

After configuring your settings, a welcome panel with help information will be displayed,
and you can start chatting with ChatGPT using a variety of commands.

A template of `config.yaml` is shown below:

```yaml
# ChatGPT CLI Configuration File
openai:
  api_key: <YOUR_API_KEY>
  default_prompt:
    - role: system
      content: You are ChatGPT, a language model trained by OpenAI. Now you are responsible for answering any questions the user asks.
proxy:
  http_proxy: http://127.0.0.1:7890
  https_proxy: http://127.0.0.1:7890
```

You can remove the `proxy` section or leave its value empty if you do not need to use a
proxy.

## Commands

We've provided several commands to help you use this tool more conveniently. You don't
need to remember all of them at once, as you can type `!help` whenever you want to have a
look. The following is a list a available commands:

- `!help` or `!h`: shows the help message
- `!show`: displays the current conversation messages
- `!save`: saves the current conversation to a `JSON` file
- `!load`: loads a conversation from a `JSON` file
- `!new` or `!reset`: starts a new conversation
- `!editor` or `!e`: use your default editor (e.g. vim) to submit a message
- `!regen`: regenerates the last response
- `!resend`: resends your last prompt to generate response
- `!edit`: selects messages for editing
- `!drop`: selects messages for deletion
- `!exit` or `!quit` or `!q`: exits the program

Features (under development):

- `!tmpl` or `!tmpl load`: select a template to use
- `!tmpl show`: show all templates with complete information
- `!tmpl create`: create a new template
- `!tmpl edit`: edit an existing template (not implemented yet)
- `!tmpl drop`: drop an existing template (not implemented yet)

These commands are designed to enable you to use this tool much like you would use the
official web client. If you find that you need additional command support, feel free to
open an issue.

## Todos

We have some todos for future improvements, such as:

- [x] Detect `[Ctrl]+[C]` hotkey and prompt to confirm exiting
- [ ] `!token`: Count tokens in conversation and display the total number
- [ ] `!sum`: Generate a summary of the conversation to reduce token usage
- [x] `!tmpl`: Choose system prompt templates
- [ ] `!conv`: Show conversation list, Delete and Rename saved conversations
- [ ] `!sys <command>`: Enable you to run system command

## Contributing

If you'd like to contribute to ChatGPT CLI, please feel free to submit a pull request or
open an issue!

## References

- The idea of using the `rich.panel` package comes from
  [mbroton's chatgpt-api](https://github.com/mbroton/chatgpt-api).
- The `!sum` command for generating a summary of the current conversation to guide the
  user in continuing the conversation is inspired by 沙漏/u202e.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for
details.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "chatgpt-cli-md",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "chatbot,chatgpt,chatgpt-cli,openai,markdown,cli,command-line",
    "author": "",
    "author_email": "Jerry Yang <efjerryyang@outlook.com>",
    "download_url": "https://files.pythonhosted.org/packages/5c/d4/c47c3e4754d21ce47b8e11a714fbdcc7e73605fc18ef586636c941eb4e69/chatgpt-cli-md-0.1.13.tar.gz",
    "platform": null,
    "description": "# ChatGPT CLI\n\n[![PyPI](https://img.shields.io/pypi/v/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)\n[![PyPI - License](https://img.shields.io/pypi/l/chatgpt-cli-md)](https://pypi.org/project/chatgpt-cli-md/)\n[![Stars](https://img.shields.io/github/stars/efJerryYang/chatgpt-cli)](https://github.com/efJerryYang/chatgpt-cli/stargazers)\n\n[\u4e2d\u6587](README_zh.md)\n\n## Introduction\n\nChatGPT CLI is a command-line interface tool that connects to the ChatGPT language model\nusing OpenAI's official API key. It features markdown support, allowing you to structure\nyour inputs in a readable and well-organized format for easier reference. The tool also\nsaves conversations in `JSON` format, you can load them with `!load` command. Commands\nprovided enable you to use this tool much like you would use the official web client. For\nmore command usage, you can type `!help` or see more in the [Commands](#commands) section.\n\nHere is a simple demonstration of how to use it:\n\n![demo](docs/demo/ezgif.com-optimize.gif)\n\n<!-- For more detailed information, please check out the `<link_to_docs>`. -->\n\n## Prequisites\n\nTo run the ChatGPT CLI tool, you'll need to have Python version 3.8 or higher installed on\nyour machine. You can check your Python version by typing `python -V` in your terminal. We\nrequire version at least `3.8` because the feature of `importlib.metadata` is only\navailable from this version. You'll also need an OpenAI API key, which you can easily\n[get here](https://platform.openai.com/account/api-keys).\n\nThe required Python packages can be installed with `pip install -r requirements.txt`,\nwhich includes the following:\n\n- `openai >= 0.27.0`\n- `pyyaml >= 6.0`\n- `rich >= 13.3.1`\n\n## Installation\n\nYou can install ChatGPT CLI by downloading the package from the\n[latest release](https://github.com/efJerryYang/chatgpt-cli/releases) and running either\nof the following commands. Note that you will need to replace `<version>` with the version\nnumber of the package you downloaded (e.g. `0.1.0`).\n\nYou can also install the package from PyPI by running `pip install chatgpt-cli-md`.\n\n```sh\npip install chatgpt-cli-md-<version>.tar.gz\n```\n\n```sh\npip install chatgpt_cli_md-<version>-py3-none-any.whl\n```\n\nThis will automatically install all the required dependencies. You can also build the\nproject and get the binary file to install by cloning the repository from GitHub and\nrunning the following commands:\n\n```sh\ngit clone https://github.com/efJerryYang/chatgpt-cli.git\n```\n\nInstall necessary dependencies:\n\n```sh\npip install -r requirements.txt\n```\n\nBuild the project into package:\n\n```sh\npython -m build\n```\n\nOnce built, you can follow the instructions above to install the package. The built\npackage will be located in `dist` directory.\n\nWe highly recommend that you use the latest version of ChatGPT CLI and install it using\nthe recommended methods for optimal performance and stability.\n\n## Getting Started\n\nAfter installation, you can start the ChatGPT CLI tool by typing `chatgpt-cli` in your\nterminal.\n\n```sh\nchatgpt-cli\n```\n\nIf you are running the tool for the first time, you will be prompted to configure your\n`config.yaml` file, and you can also import the `data` directory from your previous script\nversion. If you do not have a configuration file in the path\n`${HOME}/.config/chatgpt-cli/config.yaml`, you can create a new one with the interactive\nsetup procedure provided by the tool, or you can import the one you have already used in\nyour previous version. If choose to create a new one, You will need to input your OpenAI\nAPI key and proxy settings (if any). You can also get an OpenAI API key\n[here](https://platform.openai.com/account/api-keys) if you do not have one.\n\nAfter configuring your settings, a welcome panel with help information will be displayed,\nand you can start chatting with ChatGPT using a variety of commands.\n\nA template of `config.yaml` is shown below:\n\n```yaml\n# ChatGPT CLI Configuration File\nopenai:\n  api_key: <YOUR_API_KEY>\n  default_prompt:\n    - role: system\n      content: You are ChatGPT, a language model trained by OpenAI. Now you are responsible for answering any questions the user asks.\nproxy:\n  http_proxy: http://127.0.0.1:7890\n  https_proxy: http://127.0.0.1:7890\n```\n\nYou can remove the `proxy` section or leave its value empty if you do not need to use a\nproxy.\n\n## Commands\n\nWe've provided several commands to help you use this tool more conveniently. You don't\nneed to remember all of them at once, as you can type `!help` whenever you want to have a\nlook. The following is a list a available commands:\n\n- `!help` or `!h`: shows the help message\n- `!show`: displays the current conversation messages\n- `!save`: saves the current conversation to a `JSON` file\n- `!load`: loads a conversation from a `JSON` file\n- `!new` or `!reset`: starts a new conversation\n- `!editor` or `!e`: use your default editor (e.g. vim) to submit a message\n- `!regen`: regenerates the last response\n- `!resend`: resends your last prompt to generate response\n- `!edit`: selects messages for editing\n- `!drop`: selects messages for deletion\n- `!exit` or `!quit` or `!q`: exits the program\n\nFeatures (under development):\n\n- `!tmpl` or `!tmpl load`: select a template to use\n- `!tmpl show`: show all templates with complete information\n- `!tmpl create`: create a new template\n- `!tmpl edit`: edit an existing template (not implemented yet)\n- `!tmpl drop`: drop an existing template (not implemented yet)\n\nThese commands are designed to enable you to use this tool much like you would use the\nofficial web client. If you find that you need additional command support, feel free to\nopen an issue.\n\n## Todos\n\nWe have some todos for future improvements, such as:\n\n- [x] Detect `[Ctrl]+[C]` hotkey and prompt to confirm exiting\n- [ ] `!token`: Count tokens in conversation and display the total number\n- [ ] `!sum`: Generate a summary of the conversation to reduce token usage\n- [x] `!tmpl`: Choose system prompt templates\n- [ ] `!conv`: Show conversation list, Delete and Rename saved conversations\n- [ ] `!sys <command>`: Enable you to run system command\n\n## Contributing\n\nIf you'd like to contribute to ChatGPT CLI, please feel free to submit a pull request or\nopen an issue!\n\n## References\n\n- The idea of using the `rich.panel` package comes from\n  [mbroton's chatgpt-api](https://github.com/mbroton/chatgpt-api).\n- The `!sum` command for generating a summary of the current conversation to guide the\n  user in continuing the conversation is inspired by \u6c99\u6f0f/u202e.\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for\ndetails.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Jerry Yang  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A markdown-supported command-line interface tool that connects to ChatGPT using OpenAI's API key.",
    "version": "0.1.13",
    "project_urls": {
        "Bug Tracker": "https://github.com/efJerryYang/chatgpt-cli/issues",
        "Homepage": "https://github.com/efJerryYang/chatgpt-cli",
        "Repository": "https://github.com/efJerryYang/chatgpt-cli.git"
    },
    "split_keywords": [
        "chatbot",
        "chatgpt",
        "chatgpt-cli",
        "openai",
        "markdown",
        "cli",
        "command-line"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7ab0e681447000b6b30713de2c997a3bee775784a9f1eeea8cc087a6eb9959d",
                "md5": "b06bd17fca990e605fc8334f7e554270",
                "sha256": "c70a540572c8efc0708aa00032a9ee5d76e41404a24e5002be2a1bfdbbec8682"
            },
            "downloads": -1,
            "filename": "chatgpt_cli_md-0.1.13-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b06bd17fca990e605fc8334f7e554270",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 17325,
            "upload_time": "2023-05-18T05:04:41",
            "upload_time_iso_8601": "2023-05-18T05:04:41.732744Z",
            "url": "https://files.pythonhosted.org/packages/e7/ab/0e681447000b6b30713de2c997a3bee775784a9f1eeea8cc087a6eb9959d/chatgpt_cli_md-0.1.13-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5cd4c47c3e4754d21ce47b8e11a714fbdcc7e73605fc18ef586636c941eb4e69",
                "md5": "f3a2bc42bcbedef79bd6b12d183dd22d",
                "sha256": "b18dac0346235d2a968cfbc901c5d86297d1bc567566084a9de113a3534119ce"
            },
            "downloads": -1,
            "filename": "chatgpt-cli-md-0.1.13.tar.gz",
            "has_sig": false,
            "md5_digest": "f3a2bc42bcbedef79bd6b12d183dd22d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 2743998,
            "upload_time": "2023-05-18T05:04:45",
            "upload_time_iso_8601": "2023-05-18T05:04:45.990443Z",
            "url": "https://files.pythonhosted.org/packages/5c/d4/c47c3e4754d21ce47b8e11a714fbdcc7e73605fc18ef586636c941eb4e69/chatgpt-cli-md-0.1.13.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-18 05:04:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "efJerryYang",
    "github_project": "chatgpt-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": [
                [
                    "==",
                    "3.8.4"
                ]
            ]
        },
        {
            "name": "aiosignal",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "async-timeout",
            "specs": [
                [
                    "==",
                    "4.0.2"
                ]
            ]
        },
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "22.2.0"
                ]
            ]
        },
        {
            "name": "black",
            "specs": [
                [
                    "==",
                    "23.1.0"
                ]
            ]
        },
        {
            "name": "certifi",
            "specs": [
                [
                    "==",
                    "2022.12.7"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.1.0"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.3"
                ]
            ]
        },
        {
            "name": "frozenlist",
            "specs": [
                [
                    "==",
                    "1.3.3"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.4"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "2.2.0"
                ]
            ]
        },
        {
            "name": "mdformat",
            "specs": [
                [
                    "==",
                    "0.7.16"
                ]
            ]
        },
        {
            "name": "mdformat-gfm",
            "specs": [
                [
                    "==",
                    "0.3.5"
                ]
            ]
        },
        {
            "name": "mdformat-frontmatter",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "mdformat-footnote",
            "specs": [
                [
                    "==",
                    "0.1.1"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "multidict",
            "specs": [
                [
                    "==",
                    "6.0.4"
                ]
            ]
        },
        {
            "name": "mypy-extensions",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "openai",
            "specs": [
                [
                    "==",
                    "0.27.2"
                ]
            ]
        },
        {
            "name": "packaging",
            "specs": [
                [
                    "==",
                    "23.0"
                ]
            ]
        },
        {
            "name": "pathspec",
            "specs": [
                [
                    "==",
                    "0.11.1"
                ]
            ]
        },
        {
            "name": "platformdirs",
            "specs": [
                [
                    "==",
                    "3.2.0"
                ]
            ]
        },
        {
            "name": "pyreadline3",
            "specs": [
                [
                    "==",
                    "3.4.1"
                ]
            ]
        },
        {
            "name": "Pygments",
            "specs": [
                [
                    "==",
                    "2.14.0"
                ]
            ]
        },
        {
            "name": "PyYAML",
            "specs": [
                [
                    "==",
                    "6.0"
                ]
            ]
        },
        {
            "name": "requests",
            "specs": [
                [
                    "==",
                    "2.28.2"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "13.3.2"
                ]
            ]
        },
        {
            "name": "tomli",
            "specs": [
                [
                    "==",
                    "2.0.1"
                ]
            ]
        },
        {
            "name": "tqdm",
            "specs": [
                [
                    "==",
                    "4.65.0"
                ]
            ]
        },
        {
            "name": "urllib3",
            "specs": [
                [
                    "==",
                    "1.26.15"
                ]
            ]
        },
        {
            "name": "yarl",
            "specs": [
                [
                    "==",
                    "1.8.2"
                ]
            ]
        }
    ],
    "lcname": "chatgpt-cli-md"
}
        
Elapsed time: 0.07545s