Skip to main content

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.

  • Gemini Pro

If you use the Gemini, you can set the GOOGLE_API_KEY or --google-api-key parameter. You can also set it using the ai setting command. Need to set bot to GeminiBot by ai setting --edit bot=GeminiBot. Now, support gemini-pro mode only. You can set by ai setting --edit mode=gemini-pro, or ai --mode gemini-pro.

  • Bard Support [Deprecated]

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.

Release files for py-ai-cli 0.5.4

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

Source distribution (sdist)

Source distribution for py-ai-cli 0.5.4
File Size Uploaded
py-ai-cli-0.5.4.tar.gz 19.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for py-ai-cli 0.5.4
File Interpreter ABI Platform
py_ai_cli-0.5.4-py3-none-any.whl Python 3 none any Details

Total release size: 36.9 kB

Release files / py-ai-cli-0.5.4.tar.gz

Download URL py-ai-cli-0.5.4.tar.gz
Size 19.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d9e0d38cf5b333856906ab034e6f855aa6cc0ea6cbb463a7f61b5cf567f20a1a
BLAKE2b-256 checksum
How to use checksums
16c5718389601c9ae1e62c02bc38811b92c1cdcac7e873880abcc937f11f7cb5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release files / py_ai_cli-0.5.4-py3-none-any.whl

Download URL py_ai_cli-0.5.4-py3-none-any.whl
Size 17.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6605d61a7d0eb93c251bdd0a7b860c8fed3892d03faa9217d0766c57b8f7755
BLAKE2b-256 checksum
How to use checksums
2978400f776928810312415e3c859b3aae8ec9cd2e468aa7be91bc14bc32323c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.8

Release history Release notifications | RSS feed

This release

0.5.4 This release

2 release files

0.5.3

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

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