Metadata-Version: 2.1
Name: xontrib-chatgpt-v1
Version: 1.0.0
Summary: Gives the ability to use ChatGPT directly from the command line
Author-email: Justin Pallansch <pallanschja@gmail.com>
License: MIT License
        
        Copyright (c) 2023, Justin Pallansch
        
        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.
        
Project-URL: Homepage, https://github.com/jpal91/xontrib-chatgpt
Project-URL: Documentation, https://github.com/jpal91/xontrib-chatgpt/blob/master/README.md
Project-URL: Code, https://github.com/jpal91/xontrib-chatgpt
Project-URL: Issue tracker, https://github.com/jpal91/xontrib-chatgpt/issues
Platform: any
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: System :: Shells
Classifier: Topic :: System :: System Shells
Classifier: Topic :: Terminals
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: xonsh>=0.12.5
Requires-Dist: prompt_toolkit>=3.0.36
Requires-Dist: openai>=1
Requires-Dist: pygments>=2.16.1
Requires-Dist: tiktoken>=0.5.1
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pyyaml>=0.2.5; extra == "dev"
Provides-Extra: yaml
Requires-Dist: pyyaml>=0.2.5; extra == "yaml"

<p align="center">
Gives the ability to use ChatGPT directly from the command line
</p>

<p align="center">
If you like the idea click ⭐ on the repo and <a href="https://twitter.com/intent/tweet?text=Nice%20xontrib%20for%20the%20xonsh%20shell!&url=https://github.com/jpal91/xontrib-chatgpt" target="_blank">tweet</a>.
</p>

![Chat Screenshot](assets/chatgpt_xonsh_v013.png)

## Installation

To install use pip:

```xsh
xpip install xontrib-chatgpt
# or: xpip install -U git+https://github.com/jpal91/xontrib-chatgpt
```

Then use the following command in your `xonsh` shell or add it directly to your `.xonshrc`

```xsh
xontrib load chatgpt
```

### Environment Variables

❗**REQUIRED** ❗
```xsh
# Recommended you put this in your .xonshrc
$OPENAI_API_KEY = <your api key>
```
If you do not have an api key, you can create an account on [OpenAI](https://openai.com/). You will need to add a credit card on file to pay for any of the api usage charges. 

*You are 100% responsible for any and all cost you incur by using this xontrib.* 

For more information on `OpenAI` usage pricing, please go to [OpenAI Pricing](https://openai.com/pricing).

**Optional**
```xsh
$OPENAI_CHAT_MODEL = 'gpt-3.5-turbo'
```
If this is not set, it will default to `gpt-3.5-turbo`. Currently the only accepted options are `gpt-3.5-turbo` or `gpt-4`.

## Usage

**NEW in Version 0.1.3**

Use `chat-manager` to easily create and manage new chats

```xsh
chat-manager add gpt
gpt! Hello, what's your name?
# ChatGPT responds here
```

Use your chat as a callable alias or `xonsh` context block

```xsh
echo "Hello, what's your name" | gpt
gpt < input.txt
echo @(myvar) | gpt

# The entire contents of the block is sent as text to ChatGPT
with! gpt:
   Can you help me fix my python function?

   def hello_world():
      return
      print('Hello, world!')
```

To get see more CLI options:

```xsh
chat-manager -h
```

To get a quick tutorial:

```xsh
chat-manager help
# or
chat-manager?
```

⭐ **BONUS**: If [xontrib-abbrevs](https://github.com/xonsh/xontrib-abbrevs) is loaded, use `cm` to expand to `chat-manager`

#### See Also
- [Tips and Tricks](/docs/tips_and_tricks.md)
- [How To Edit System Messages](/docs/edit_sys_messages.md)

## Future Plans
- **Streaming Responses**
   - Expand the ability to get streaming responses on the command line as opposed to waiting until the full completion is done
- **Chat Settings**
   - Allow customizable max tokens
   - Allow each chat to have separate models (ie 3.5-turbo, 4, etc.)
   - Timeouts on long responses
   - ~~Update individual instance system messages/chat instructions~~ **NEW in v0.1.6**
- **Additional Models**
   - Open up the ability to use other models besides 3.5 and 4
- ~~**Completions**~~ **NEW in v0.1.5**
   - ~~Helper completions for `chat-manager`~~


## Credits

- This package was created with [xontrib template](https://github.com/xonsh/xontrib-template).
- [Xonsh Documentation](https://xon.sh/contents.html)
- [prompt_toolkit](https://python-prompt-toolkit.readthedocs.io/)
- [Pygments](https://pygments.org/docs/)
- [Awesome Xontribs](https://github.com/xonsh/awesome-xontribs) - Much inspiration was taken from many projects in this fantastic repo

