clai integrates the OpenAI models with the terminal.
You can generate images, text, summarize content and chat while using native terminal functionality, such as pipes and termination signals.
- OpenAI API Key: Set the
OPENAI_API_KEYenvironment variable to your OpenAI API key. See here: OpenAI API Key. - Glow (Optional): Install Glow for formatted markdown output when querying text responses.
go install github.com/baalimago/clai@latestSimple queries:
clai query My favorite color is blue, tell me some facts about itclai -re `# Use the -re flag to use the previous query as context for some next query` \
q Write a poem about my favorite colour Personally I have alias ask=clai q and then alias rask=clai -re q.
This way I can ask -> rask -> rask for a temporary conversation.
Chatting:
clai chat new Lets have a conversation about Hegelclai chat list `# List all your chats`clai c continue 1 `# Continue some previous chat` Glob queries:
clai --raw ` # Don't format output as markdown` \
--chat-model gpt-3.5-turbo `# Use some other model` \
glob '*.go' Generate a README for this project > README.mdPhotos:
printf "flowers" | clai -i --photo-prefix=flowercat --photo-dir=/tmp photo "A cat made out of {}"Since -N alternatives are disabled for many newer OpenAI models, you can use repeater to generate several responses from the same prompt:
NO_COLOR=true repeater -n 10 -w 3 -increment -file out.txt -output BOTH \
clai -pp flower_INC p A cat made of flowersclai help `# For more info about the available commands (and shorthands)`On initial run, clai will create configuration files at $HOME/.clai/, one for photo and one for chat/text.
Here you can configure initial prompts, temperature and other settings.
Within $HOME/.clai/conversations you'll find all the conversations.
You can also modify the chats here as a way to prompt, or create entirely new ones as you see fit.
This project is heavily inspired by: https://github.com/Licheam/zsh-ask, many thanks to Licheam for the inspiration.