Gives the ability to use ChatGPT directly from the command line
Project description
Gives the ability to use ChatGPT directly from the command line
If you like the idea click ⭐ on the repo and tweet.
Installation
To install use pip:
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
xontrib load chatgpt
Environment Variables
❗REQUIRED ❗
# 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. 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.
Optional
$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
chat-manager add gpt
gpt "Hello, what's your name?"
# ChatGPT responds here
Use your chat as a callable alias or xonsh
context block
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:
chat-manager -h
To get a quick tutorial:
chat-manager help
# or
chat-manager?
⭐ BONUS: If xontrib-abbrevs is loaded, use cm
to expand to chat-manager
Version 0.1.3 Notes
chat-manager
is meant to replace prior direct usage of utilizing theChatGPT
python class directly- Direct usage of
ChatGPT
will not be deprecated, yet, but the plan is to havechat-manager
be the defacto usage of this package chat-manager
is also getting passed to the global ctx for debugging purposes for now aschat_manager
, but will later be deprecated- The one-off alias
chatgpt
is also available, but will be deprecated in later versions - To see the original documentation on these, please visit the old usage docs
- Three new
xonsh
events were added to help manage changes see events for details
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
- Additional Models
- Open up the ability to use other models besides 3.5 and 4
- Completions
- Helper completions for
chat-manager
- Helper completions for
- OpenAI Error Handling
Credits
- This package was created with xontrib template.
- Xonsh Documentation
- prompt_toolkit
- Pygments
- Awesome Xontribs - Much inspiration was taken from many projects in this fantastic repo
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for xontrib_chatgpt-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab8c73cfc7da00c2b1ee1568565c9e5dbba48443508694a835a8e3402c0efcac |
|
MD5 | 3d6eb30b189b2f5cdda0a21764abc729 |
|
BLAKE2b-256 | 6680d9675591679053cd71153768e29096186cc20cee3ac60334ce3e201bc3d9 |