Skip to content
/ ai Public

πŸ€– A command line program designed to interact with OpenAI API or Azure OpenAI API.

License

Notifications You must be signed in to change notification settings

cyyyu/ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

82 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– AI

A command-line tool for chat completions using the OpenAI API or Azure OpenAI.

Example

πŸ“₯ Installation

$ npm install -g @cyyyu/ai or $ yarn global add @cyyyu/ai or $ pnpm add -g @cyyyu/ai

πŸš€ Usage

Configure your API key and model (or deployment) name. Use OpenAI (api.openai.com) by default, or Azure OpenAI by setting a custom endpoint.

OpenAI (default):
Use an API key from your OpenAI account.

export OPENAI_API_KEY="sk-..."
export OPENAI_DEPLOYMENT="gpt-4"   # or gpt-3.5-turbo, etc.

Azure OpenAI:
Get your endpoint and key from the Azure portal; create a resource and deployment via Azure OpenAI if needed.

export OPENAI_ENDPOINT="https://<your-resource>.openai.azure.com/openai/v1/"
export OPENAI_API_KEY="<your api key>"
export OPENAI_DEPLOYMENT="<your deployment name>"

Then run the tool:

$ ai [options] [message]

Options:

-h, --help: Display a help message that explains how to use the tool.

-m, --message: Send a message to the AI assistant.

-i, --interactive: Start an interactive chat session with the AI assistant.

-p, --prompt: The prompt to use for the AI assistant. Default is "Assistant is a large language model trained by OpenAI.".

-u, --usage: Show usage statistics.

-v, --version: Display the version of the tool.

If you use the -i or --interactive option, the tool will start an interactive chat session. You can type messages to the AI assistant and it will respond to you.

πŸ’‘ Examples

Here are some examples of how to use the tool:

Send a message to the AI assistant

ai "How to find the biggest folder in a bash shell?"

ai 'How to find the biggest folder in a bash shell?'

Start an interactive chat session

ai -i or with a message ai -i "Why is the ocean blue?"

ai -i 'Why is the ocean blue?'

Use a different prompt

  1. Act as a smart commit message generator:
alias aicommit="ai -p 'I want you to act as a commit message generator. I will provide you with information about the task and the prefix for the task code, and I would like you to generate an appropriate commit message using the conventional commit format. Do not write any explanations or other words, just reply with the commit message.'"

You can pipe to it.

demo3

  1. Act as a fancy title generator:
alias ai-fancy-title-generator="ai -p 'I want you to act as a fancy title generator. I will type keywords via comma and you will reply with fancy titles.'"

demo4

  1. Act as an english translator:
alias ai-english-translator="ai -p 'I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations.'"

demo5

Explore more wonderful prompts

πŸ“ License

MIT

About

πŸ€– A command line program designed to interact with OpenAI API or Azure OpenAI API.

Resources

License

Stars

Watchers

Forks

Packages

No packages published