openai-assistants-cli


Nameopenai-assistants-cli JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryCommand-line interface for ChatGPT Assistants: https://platform.openai.com/docs/assistants/overview
upload_time2023-12-27 20:57:33
maintainer
docs_urlNone
author
requires_python>=3.9
licenseCopyright (c) 2023 by Val Kharitonov 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 cli command-line assistant openai gpt-3 gpt-4 llm chatgpt openai-assistants-cli gpt-client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # openai-assistants-cli

Command-line interface for ChatGPT Assistants: https://platform.openai.com/docs/assistants/overview.


## Features

- **Command-Line Interface**: Interact with ChatGPT or Claude directly from your terminal.
- **Multiple Assistants**: Easily switch between different assistants defined in the config file.
- **Keyboard Shortcuts**: Use Ctrl-C, Ctrl-D, and Ctrl-R shortcuts for easier conversation management and input control.
- **Multi-Line Input**: Enter multi-line mode for more complex queries or conversations.
- **Markdown Support**: Enable or disable markdown formatting for chat sessions to tailor the output to your preferences.
- **Logging**: Log your conversations to disk or stdout

### Coming Soon
- **Usage tracking**: Track your API usage with token count and price information.

## Installation

This install assumes a Linux/OSX machine with Python and pip available.
```bash
pip install openai-assistants-cli
```

Install latest version from source:
```bash
pip install git+https://github.com/grid-link-inc/gpt-cli
```

Or install by cloning the repository manually:
```bash
git clone https://github.com/grid-link-inc/gpt-cli
cd gpt-cli
pip install .
```

Add the OpenAI API key to your `.bashrc` file (in the root of your home folder).
In this example we use nano, you can use any text editor.

```
nano ~/.bashrc
export OPENAI_API_KEY=<your_key_here>
```

Run the tool

```
openai-assistants-cli
```

You can also use a `gpt.yml` file for configuration. See the [Configuration](README.md#Configuration) section below.

## Usage

Make sure to set the `OPENAI_API_KEY` environment variable to your OpenAI API key (or put it in the `~/.config/gpt-cli/gpt.yml` file as described below).

Add your assistant to the config file. See `Configuration` below. (TODO Add assistant-id arg and use this in Usage/quickstart)

```
usage: openai-assistants-cli [-h] [--no_markdown] 
              [--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
              [--no_stream]
              [{assistant-name}]

Run a chat session with ChatGPT. See https://github.com/grid-link-inc/gpt-cli for more information.

optional arguments:
  -h, --help            show this help message and exit
  --no_markdown         Disable markdown formatting in the chat session.
  --log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
                        The log level to use
  --no_stream           If specified, will not stream the response to standard output. This is
                        useful if you want to use the response in a script. Ignored when the
                        --prompt option is not specified.
  --no_price            Disable price logging.
```

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.


## Configuration

You can configure the assistants in the config file `~/.config/gpt-cli/gpt.yml`. The file is a YAML file with the following structure (see also [config.py](./gptcli/config.py))

```yaml
default_assistant: <assistant_name>
markdown: False
openai_api_key: <openai_api_key>
anthropic_api_key: <anthropic_api_key>
log_file: <path>
log_level: <DEBUG|INFO|WARNING|ERROR|CRITICAL>
assistants:
  <assistant_name>:
    id: <assistant id string>
  <assistant_name>:
    ...
```

You can override the parameters for the pre-defined assistants as well.

You can specify the default assistant to use by setting the `default_assistant` field. 

Example:

```yaml
default_assistant: my_assistant
markdown: True
openai_api_key: <openai_api_key>
assistants:
  my_assistant:
    id: asst_abcdabcdabcd
  my_other_assistant:
    id: asst_123412341234
```

```
$ openai-assistants-cli my_other_assistant

> 
```


## Testing

```
pytest tests
```


# TODO for v1.0

- [ ] Implement PriceChatListener for Assistants
- [ ] Add configurable instructions for each assistant to be passed to runs.create()
- [ ] Accept an assistant ID as a cli arg
- [ ] Make file names clickable in citations (that were created by add_citations_to_messages()) 
- [ ] Cache File retrievals
- [ ] Consolidate the two log file / persistance implementations

# Publishing

```
## Build
pip install build
python -m build

## Test it
pip install twine
twine upload --repository testpypi dist/* --username __token__ # Use your API token as the password when promtped
pip install --index-url https://test.pypi.org/simple/ openai-assistants-cli

## Publish
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "openai-assistants-cli",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "cli,command-line,assistant,openai,gpt-3,gpt-4,llm,chatgpt,openai-assistants-cli,gpt-client",
    "author": "",
    "author_email": "Lyon Lay <lay.lyon@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f7/51/e94599a36be0cbd45ee1465d0ee46e67ef68542727ce45f7ee0a00a890cd/openai-assistants-cli-0.1.1.tar.gz",
    "platform": null,
    "description": "# openai-assistants-cli\n\nCommand-line interface for ChatGPT Assistants: https://platform.openai.com/docs/assistants/overview.\n\n\n## Features\n\n- **Command-Line Interface**: Interact with ChatGPT or Claude directly from your terminal.\n- **Multiple Assistants**: Easily switch between different assistants defined in the config file.\n- **Keyboard Shortcuts**: Use Ctrl-C, Ctrl-D, and Ctrl-R shortcuts for easier conversation management and input control.\n- **Multi-Line Input**: Enter multi-line mode for more complex queries or conversations.\n- **Markdown Support**: Enable or disable markdown formatting for chat sessions to tailor the output to your preferences.\n- **Logging**: Log your conversations to disk or stdout\n\n### Coming Soon\n- **Usage tracking**: Track your API usage with token count and price information.\n\n## Installation\n\nThis install assumes a Linux/OSX machine with Python and pip available.\n```bash\npip install openai-assistants-cli\n```\n\nInstall latest version from source:\n```bash\npip install git+https://github.com/grid-link-inc/gpt-cli\n```\n\nOr install by cloning the repository manually:\n```bash\ngit clone https://github.com/grid-link-inc/gpt-cli\ncd gpt-cli\npip install .\n```\n\nAdd the OpenAI API key to your `.bashrc` file (in the root of your home folder).\nIn this example we use nano, you can use any text editor.\n\n```\nnano ~/.bashrc\nexport OPENAI_API_KEY=<your_key_here>\n```\n\nRun the tool\n\n```\nopenai-assistants-cli\n```\n\nYou can also use a `gpt.yml` file for configuration. See the [Configuration](README.md#Configuration) section below.\n\n## Usage\n\nMake sure to set the `OPENAI_API_KEY` environment variable to your OpenAI API key (or put it in the `~/.config/gpt-cli/gpt.yml` file as described below).\n\nAdd your assistant to the config file. See `Configuration` below. (TODO Add assistant-id arg and use this in Usage/quickstart)\n\n```\nusage: openai-assistants-cli [-h] [--no_markdown] \n              [--log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]\n              [--no_stream]\n              [{assistant-name}]\n\nRun a chat session with ChatGPT. See https://github.com/grid-link-inc/gpt-cli for more information.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --no_markdown         Disable markdown formatting in the chat session.\n  --log_level {DEBUG,INFO,WARNING,ERROR,CRITICAL}\n                        The log level to use\n  --no_stream           If specified, will not stream the response to standard output. This is\n                        useful if you want to use the response in a script. Ignored when the\n                        --prompt option is not specified.\n  --no_price            Disable price logging.\n```\n\nType `:q` or Ctrl-D to exit, `:c` or Ctrl-C to clear the conversation, `:r` or Ctrl-R to re-generate the last response.\nTo enter multi-line mode, enter a backslash `\\` followed by a new line. Exit the multi-line mode by pressing ESC and then Enter.\n\n\n## Configuration\n\nYou can configure the assistants in the config file `~/.config/gpt-cli/gpt.yml`. The file is a YAML file with the following structure (see also [config.py](./gptcli/config.py))\n\n```yaml\ndefault_assistant: <assistant_name>\nmarkdown: False\nopenai_api_key: <openai_api_key>\nanthropic_api_key: <anthropic_api_key>\nlog_file: <path>\nlog_level: <DEBUG|INFO|WARNING|ERROR|CRITICAL>\nassistants:\n  <assistant_name>:\n    id: <assistant id string>\n  <assistant_name>:\n    ...\n```\n\nYou can override the parameters for the pre-defined assistants as well.\n\nYou can specify the default assistant to use by setting the `default_assistant` field. \n\nExample:\n\n```yaml\ndefault_assistant: my_assistant\nmarkdown: True\nopenai_api_key: <openai_api_key>\nassistants:\n  my_assistant:\n    id: asst_abcdabcdabcd\n  my_other_assistant:\n    id: asst_123412341234\n```\n\n```\n$ openai-assistants-cli my_other_assistant\n\n> \n```\n\n\n## Testing\n\n```\npytest tests\n```\n\n\n# TODO for v1.0\n\n- [ ] Implement PriceChatListener for Assistants\n- [ ] Add configurable instructions for each assistant to be passed to runs.create()\n- [ ] Accept an assistant ID as a cli arg\n- [ ] Make file names clickable in citations (that were created by add_citations_to_messages()) \n- [ ] Cache File retrievals\n- [ ] Consolidate the two log file / persistance implementations\n\n# Publishing\n\n```\n## Build\npip install build\npython -m build\n\n## Test it\npip install twine\ntwine upload --repository testpypi dist/* --username __token__ # Use your API token as the password when promtped\npip install --index-url https://test.pypi.org/simple/ openai-assistants-cli\n\n## Publish\n```\n",
    "bugtrack_url": null,
    "license": "Copyright (c) 2023 by Val Kharitonov  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), 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 \u201cAS IS\u201d, 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": "Command-line interface for ChatGPT Assistants: https://platform.openai.com/docs/assistants/overview",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/grid-link-inc/gpt-cli"
    },
    "split_keywords": [
        "cli",
        "command-line",
        "assistant",
        "openai",
        "gpt-3",
        "gpt-4",
        "llm",
        "chatgpt",
        "openai-assistants-cli",
        "gpt-client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f751e94599a36be0cbd45ee1465d0ee46e67ef68542727ce45f7ee0a00a890cd",
                "md5": "026a2752bf23dc7ce8c4d0c3f8aed316",
                "sha256": "59032cf3546bed3e18ea9dde5f36617b0c550bb925ec842ca2d5ea6aa88bd4e8"
            },
            "downloads": -1,
            "filename": "openai-assistants-cli-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "026a2752bf23dc7ce8c4d0c3f8aed316",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 18150,
            "upload_time": "2023-12-27T20:57:33",
            "upload_time_iso_8601": "2023-12-27T20:57:33.358321Z",
            "url": "https://files.pythonhosted.org/packages/f7/51/e94599a36be0cbd45ee1465d0ee46e67ef68542727ce45f7ee0a00a890cd/openai-assistants-cli-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-27 20:57:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "grid-link-inc",
    "github_project": "gpt-cli",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openai-assistants-cli"
}
        
Elapsed time: 0.15673s