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

Metadata

Release files for xontrib-chatgpt 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xontrib-chatgpt 0.2.2
File Size Uploaded
xontrib-chatgpt-0.2.2.tar.gz 20.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-chatgpt 0.2.2
File Interpreter ABI Platform
xontrib_chatgpt-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 41.5 kB

Release files / xontrib-chatgpt-0.2.2.tar.gz

Download URL xontrib-chatgpt-0.2.2.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
36f236232df2db1340a485e58fce3e99bd4814df8c19e7ebfcc2847942d4dcd0
BLAKE2b-256 checksum
How to use checksums
3ff593b6fdff0f4f48a256b2d4c81314a0e14976ef1b56cf4218d0cf3d919da6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / xontrib_chatgpt-0.2.2-py3-none-any.whl

Download URL xontrib_chatgpt-0.2.2-py3-none-any.whl
Size 21.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d7bd2527cfadccee8aefcbd8518d88e9b0be9788deb6a832f595a426173ee5b
BLAKE2b-256 checksum
How to use checksums
185b75b96a93abf119eb82a0fdc091da1c19681dcae37a34fec9ad2c61c73efd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.0

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page