clai

command module
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 21 Imported by: 0

README

clai: command line artificial intelligence

Go Report Card

clai brings convenience to the OpenAI models. You can generate images, text and summarize content from the command line with ease (see examples below). Changing models and tweaking the prompt is as easy as changing a few flags, or persist it with a configuration file.

clai_in_action_example

Prerequisites

  • OpenAI API Key: Set the OPENAI_API_KEY environment variable to your OpenAI API key. See here: OpenAI API Key.
  • Glow (Optional): Install Glow for formatted markdown output when querying text responses.

Installation

go install github.com/baalimago/clai@latest
Examples

Simple queries:

clai query My favorite color is blue, tell me some facts about it
clai -re `# Use the -re flag to use the previous query as context for some next query` \
    q Write a poem about my favorite colour 

Chatting:

clai chat new Lets have a conversation about the Hegel
clai c continue `# Continue some previous chat, list all chats with 'clai chat list'` \
    Lets_have_a_conversation_about 

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.md

Photos:

printf "flowers" `                  # Pipe any data into clai, such as a specialized prompt` \
    | clai  --photo-prefix flower ` # Photos are stored locally with randomized string as suffix, this sets prefix` \
            --photo-dir  /tmp/ `    # You can modify where to store the rendered image ` \ 
            -i `                    # Use xargs notation for replacing some substring with the piped in content` \
            photo A cat made 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 flowers
clai help `# For more info about the available commands (and shorthands)`

Configuration

On initial run, clai will create configuration files at $HOME/.clai/, one for photo and one for chat. 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.

Honorable mentions

This project is heavily inspired by: https://github.com/Licheam/zsh-ask, many thanks to Licheam for the inspiration.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL