Skip to main content

This CLI tool allows you to easily chat with chatGPT in the command line. You can chat with it, ask questions, and even translate text. It also

Project description

AI Tools for chatGPT

This CLI tool allows you to conveniently use chatGPT or new bing in the command line interface. You can chat with it or ask it questions. It can also help you translate text and supports rendering markdown in the terminal.

PyPI

English | 中文 | 日本語

Dependencies

  • OPENAI_API_BASE (optional)

If you are unable to access https://api.openai.com due to GFW, you can specify another API address using the OPENAI_API_BASE environment variable. It is recommended to use this method as it is more stable than using a proxy. For information on how to use Cloudflare Workers to set up a proxy, see Setting up an OpenAI API Proxy with Cloudflare Workers.

  • OPENAI_API_KEY

You can set the OPENAI_API_KEY environment variable or specify it using the --api-key parameter. You can also set it using the ai setting command.

If you use Azure OpenAI, you can set the AZURE_OPENAI_API_KEY or AZURE_OPENAI_AD_TOKEN environment variable. and AZURE_OPENAI_ENDPOINT for Azure OpenAI endpoint.

  • Bard Support

If you use the Bard Bot, you must be logged into Google Bard on at least one browser, which will automatically be detected.

  • Bing Cookie

If you use the Bing Bot, you need to set the Bing Cookie. You can set it using the ai setting command.

ai setting --edit bing_cookie="BING_COOKIE.JSON"

For information on how to get the cookie, see Checking Access Required for Bing Bot.

Installation

pip install py-ai-cli

Alternatively, install the latest version:

pip install git+https://github.com/yufeikang/ai-cli.git    

Configuration

You can now set the API key and API base using the ai setting command. Environmental variables and CLI parameters are still valid.

# View settings
ai setting
# Set settings
ai setting -e

Usage

Use ai -h to view all supported commands.

  • Automatic Commit Messages
ai commit

  • Ask a Question
ai ask "Hello"
# no stream mode
ai --no-stream ask "Hello"
# help
ai ask --help
# use pre prompt
curl -s https://raw.githubusercontent.com/yufeikang/ai-cli/main/README.md | ai ask --prompt "summary this, how to install"

  • Translation
ai translate "Hello"
ai translate "Hello" -t japanese
ai translate -t english -f "file.txt"
echo "Hello" | ai translate -t english
cat "file.txt" | ai translate -t english

  • Chatting
ai chat

  • Code Review
ai review
ai review -t develop
ai review -t HEAD~1

Proxy Support

OPENAI_API_BASE is more stable with a forward proxy. It is recommended.

Support environment variables HTTP_PROXY and HTTPS_PROXY, or ALL_PROXY. You can also specify a proxy using the --proxy parameter.

For example:

export HTTP_PROXY=http://x.x.x.x:xxxx
# or
export HTTPS_PROXY=https://x.x.x.x:xxxx

SOCKS5 proxy is also supported, for example:

export ALL_PROXY=socks5://x.x.x.x:xxxx

SOCKS5 proxy requires pip install pysocks.

Additional Information

Please use ai --help to view more commands.

Thanks

JetBrains Logo (Main) logo

This project is developed using JetBrains products.

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

py-ai-cli-0.4.0.tar.gz (17.7 kB view details)

Uploaded Source

Built Distribution

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

py_ai_cli-0.4.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file py-ai-cli-0.4.0.tar.gz.

File metadata

  • Download URL: py-ai-cli-0.4.0.tar.gz
  • Upload date:
  • Size: 17.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for py-ai-cli-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3e2cea4a271cc2dd01bf5e24f136475866bf772c2c94d6b7ce957a3ae76a4e6b
MD5 2a742265b020d0e7aab9b48b5cc64d2f
BLAKE2b-256 9a2fb30417f759b062d43843724a77a7a0964e7367ae141f658ad595fe5b7adc

See more details on using hashes here.

File details

Details for the file py_ai_cli-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: py_ai_cli-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 16.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for py_ai_cli-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e2891159332a30157ca35c60f9e72385fa71c6ebe3bf176eb8851cced1c2544e
MD5 07e26b51282a1d67ccc10bb792a82350
BLAKE2b-256 76ba5ae551bb40ddef1442cee764400c8101df68b34dd51751f52bfb91d71061

See more details on using hashes here.

Supported by

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