vichat

command module
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 2 Imported by: 0

README

vichat

A simple LLM chat cli (with Vim).

demo

Why

I find it easier to use text files to test different system prompts on the same user input than a Web UI.

Installation

go install github.com/JackKCWong/vichat@latest

# install vim plugin
vichat i 

Usage

export OPENAI_API_KEY=<your LLM api key>
export OPENAI_API_BASE=<your LLM api base>

Chat directly on cli and open the respone in Vim:

vichat chat [options] tell me a joke about Go

# e.g. 
vichat tell me a joke about Vim

# or output to terminal directly
vichat -r tell me a joke about emacs

Chat with history:

cat <<_EOF | vichat chat
SYSTEM: You are a professional joke writer

USER: tell me a joke about goose

AI: Why did the goose go to the doctor? Because he was feeling a little down!

USER: Why did it feel down?
_EOF

Or chat with history in Vim:

cat <<_EOF > test.chat
SYSTEM: You are a professional joke writer

USER: tell me a joke about goose
_EOF

vim test.chat

ctrl+s

When in Vim:

  • ctrl+s (n or i mode) to send the full chat, the result will be appended to the end of the current buffer, just like a usual chat experience.

  • ctrl+t (n or i mode) to send the full chat, but the result will be put to a new buffer, useful when you want to ask many simple questions that doesn't require context. Saves token usages.

  • ctrl+a (n mode) to jump to the end and start asking a new question.

  • ctrl+t (n mode) to estimate the number of tokens using titoken gpt-like encoding.

  • ctrl+k (n or v mode) to count the number of tokens.

  • ctrl+c (n or v mode) to chunk the text using RecursiveTextSplitter.

  • ctrl+n (n mode) to start a new chat with the same system prompt.

  • q (n mode) close current chat.

  • ctrl+q (n mode) force close current chat.

Vim tips:

  • put this line in your ~/.vimrc to enable code block highlight in markdown
syntax on
let g:markdown_fenced_languages = ['html', 'js=javascript', 'rust', 'go', 'java']

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
cmd

Jump to

Keyboard shortcuts

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