Goaichat

Goaichat is a terminal-based AI chat client written in Go. It connects to OpenAI-compatible APIs using configuration supplied via config.yaml and environment variables.

Features

  • Config-driven startup: Loads defaults from config.yaml with environment overrides.
  • Interactive chat loop: Command-driven conversation with OpenAI-compatible models.
  • Persistent history: Sessions and messages are stored in SQLite, allowing /open and /rename commands.
  • Session naming assistance: The assistant suggests descriptive session names that you can adopt.
  • Extensible architecture: Structured packages under internal/ for configuration, chat orchestration, storage, OpenAI client integration, and CLI wiring.

Getting Started

Prerequisites

  • Go 1.23 or later
  • Access to an OpenAI-compatible API endpoint

Installation

go install github.com/stig/goaichat/cmd/goaichat@latest

Alternatively, clone the repository and build locally:

git clone https://github.com/stig/goaichat.git
cd goaichat
go build ./cmd/goaichat

Configuration

Create config.yaml in the project root or pass --config to specify a path. When no path is provided, Goaichat searches the current working directory first and then $HOME/.config/goaichat/config.yaml. A minimal configuration looks like:

api:
  url: "https://api.openai.com/v1"
  key: "${GOAICHAT_API_KEY}"
model:
  name: "gpt-4o-mini"
  temperature: 0.7
  stream: true
ui:
  show_timestamps: true
logging:
  level: "info"

Environment variables override several fields:

  • GOAICHAT_API_URL
  • GOAICHAT_API_KEY

Running

go run ./cmd/goaichat --config path/to/config.yaml

Usage

After launching, type messages at the prompt. The following commands are available:

  • /help display available commands.
  • /reset clear the current in-memory conversation.
  • /list list saved sessions with summaries.
  • /open <name> load a previously saved session by name.
  • /rename <name> assign a new name to the current session (use suggestions or provide your own).
  • /exit quit the application.

The assistant proposes session name suggestions after the first reply in a session. Use /rename <suggested-name> to accept them quickly.

Persistence

Goaichat uses SQLite for storage. On first run, the application applies migrations from internal/storage/migrations/. Sessions are automatically created when you begin chatting, and every message is stored for later retrieval.

By default the database is stored at $HOME/.local/share/goaichat/goaichat.db. You can override the location via the storage.path or storage.base_dir settings in config.yaml.

Development

  • Run tests with go test ./....
  • Follow the roadmap in dev-plan.md for milestone progression.

License

This project is licensed under the MIT License.

Description
A terminal based AI chat written in Go
Readme MIT 98 KiB
Languages
Go 100%