Skip to main content

Gives the ability to use ChatGPT directly from the command line

If you like the idea click ⭐ on the repo and tweet.

Chat Screenshot

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

See Also

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

xontrib_chatgpt_v1-1.0.0.tar.gz (20.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xontrib_chatgpt_v1-1.0.0-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file xontrib_chatgpt_v1-1.0.0.tar.gz.

File metadata

  • Download URL: xontrib_chatgpt_v1-1.0.0.tar.gz
  • Upload date:
  • Size: 20.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for xontrib_chatgpt_v1-1.0.0.tar.gz
Algorithm Hash digest
SHA256 a57c6236d135bd5043e88fb24717191902cc6bb916f49382ac728f5d497aaa33
MD5 33e343235132b168e6b265467df972db
BLAKE2b-256 afe835285720be784b8f627df50ab3b601e17d4cf52fb5324e2d05c467421a0f

See more details on using hashes here.

File details

Details for the file xontrib_chatgpt_v1-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for xontrib_chatgpt_v1-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb0440acffd8e8c98200cd6fdb786f950ba140bf4222d86f8adffc359fa019da
MD5 0d5fd970d4cd0b82e87ce629424be494
BLAKE2b-256 7847270380852dd2b4c4c7a397a49f5f2377a12114103457912e298758723d06

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page