chat

command
v1.25.3 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

README

Chat Example

An interactive chatbot CLI that demonstrates the zerfoo one-line API. Loads a model, reads prompts from stdin, and prints responses in a loop.

Build

go build -o chat ./examples/chat/

Usage

# With a local GGUF file
./chat --model path/to/model.gguf

# With a HuggingFace model ID (downloads automatically)
./chat --model google/gemma-3-1b-it

Once running, type a message and press Enter to get a response. Type quit or press Ctrl-D to exit.

Chat started. Type your message and press Enter. Type 'quit' to exit.
> What is the capital of France?
The capital of France is Paris.
> quit

Code

The core loop is minimal — load the model, then call m.Chat(prompt) in a readline loop:

m, err := zerfoo.Load("path/to/model.gguf")
if err != nil {
    log.Fatal(err)
}
defer m.Close()

response, err := m.Chat("What is the capital of France?")
fmt.Println(response)

Documentation

Overview

Command chat demonstrates a simple interactive chatbot using the zerfoo one-line API.

Usage:

go build -o chat ./examples/chat/
./chat --model path/to/model.gguf

Jump to

Keyboard shortcuts

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