Skip to main content

Use Open AI models in xonsh shell.

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

Installation

To install use pip:

xpip install -U xontrib-openai
# or: xpip install -U git+https://github.com/anki-code/xontrib-openai

Usage

$OPENAI_API_KEY = 'abcd1234'  # https://platform.openai.com/account/api-keys

# Defaults:
# $OPENAI_MODEL = 'text-davinci-003'  # https://platform.openai.com/docs/models/overview
# $OPENAI_MAX_TOKENS = 500

xontrib load openai

ai! hello
# Hello! How are you?

In case you need addon with new model:

aliases['ai4'] = "$OPENAI_MODEL='gpt-4' $OPENAI_MAX_TOKENS=1000 @('ai')"

ai4! hello gpt-4
# Hello human

Get shell commands

ai! how to git commit. Give me only command
# git commit -m "Commit message"
ai! how to remove all containers and images in docker. Only commands please
# docker stop $(docker ps -a -q)
# docker rm $(docker ps -a -q)
# docker rmi $(docker images -a -q)

Get Python code

ai! send post request with json data on python
# import requests
# import json
# 
# url = 'http://example.com/api/1/users'
# data = {
#   "first_name": "John",
#   "last_name": "Smith"
# }
# 
# headers = {'Content-type': 'application/json'}
# response = requests.post(url, data=json.dumps(data), headers=headers)

Generate data

ai! give me json where keys are fruits and values are most common fruit color
# {
#     "Apple": "Red",
#     "Banana": "Yellow",
#     "Orange": "Orange",
#     "Grape": "Purple",
#     "Strawberry": "Red",
#     "Lemon": "Yellow",
#     "Kiwi": "Green",
#     "Cherry": "Red",
#     "Watermelon": "Green"
# }

Using the data:

import json
j = json.loads($(ai give me small json))
j
# {'name': 'John', 'age': 25}

Known issues

To use gpt-4 model join wait list.

Credits

This package was created with xontrib template.

Metadata

Release files for xontrib-openai 0.1.0

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-openai 0.1.0
File Size Uploaded Provenance Actions
xontrib_openai-0.1.0.tar.gz 3.1 kB Without provenance Details for xontrib_openai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for xontrib-openai 0.1.0
File Interpreter ABI Platform Actions
xontrib_openai-0.1.0-py3-none-any.whl Python 3 none any Details for xontrib_openai-0.1.0-py3-none-any.whl

Total release size: 6.5 kB

Release files / xontrib_openai-0.1.0.tar.gz

Download URL xontrib_openai-0.1.0.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
0c10632c94bb19f97540b6f114e886b0c7820b57892dbd71d44899b6fdd05da0
BLAKE2b-256 checksum
How to use checksums
fcbd56413c4ce62b6a6f211201a60ad1d190ce842037dafa192eaab5c8ab3fef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / xontrib_openai-0.1.0-py3-none-any.whl

Download URL xontrib_openai-0.1.0-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a22331364affa1a726437f61941974a618bd8d93971c00f4ddcdfc7047ef59da
BLAKE2b-256 checksum
How to use checksums
f06915f79a38d6ff04eccfee23141f69f76952303fbc0078f40b81a6d3716853
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Security for xontrib-openai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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