Skip to content

Migration: pkg/chat extracted to the go/chat module

The multi-provider AI chat client has been extracted from go-tool-base into the phpboyscout/go language subgroup as a standalone, SDK-free module plus one module per provider:

Module Provides
gitlab.com/phpboyscout/go/chat v0.1.0 the SDK-free core (client, ReAct loop, streaming, fallback, persistence, media) + the claude-local provider
gitlab.com/phpboyscout/go/chat-anthropic v0.1.0 the claude provider (anthropic-sdk-go)
gitlab.com/phpboyscout/go/chat-openai v0.1.0 the openai / openai-compatible providers (openai-go + tiktoken)
gitlab.com/phpboyscout/go/chat-gemini v0.1.0 the gemini provider (genai)

Documentation now lives at chat.go.phpboyscout.uk.

gtb CLI users: nothing changes

gtb ai, gtb docs ask, config keys (ai.provider, anthropic.api.env, …), and credential posture behave exactly as before. This migration only affects code that imports the chat packages.

What go-tool-base did

go-tool-base/pkg/chat is now a thin adapter that:

  • re-exports the module's public types/constructors (chat.Config, chat.New, chat.Tool, …), so existing GTB call sites are unchanged;
  • owns the GTB Viper config-key schema (ConfigKeyClaudeKey, ConfigKeyAIProvider, …) and the SettingsFromProps / NewFromProps / NewWithFallbackFromProps adapters that map Props into the module's typed Settings;
  • blank-imports all three provider modules, so every provider is registered — GTB tools keep working with every provider with no import changes.

The chat core source (~4,400 lines) was deleted from the tree; only the adapter remains.

What you need to do

If you consume GTB's pkg/chat (e.g. chat.New, chat.Config, the config-key constants): nothing — the adapter re-exports the same API and links every provider.

If you want the light, framework-free client directly (no go-tool-base): import the module and opt into only the provider(s) you use:

import (
    "gitlab.com/phpboyscout/go/chat"
    _ "gitlab.com/phpboyscout/go/chat-anthropic" // activate "claude"
)

client, err := chat.New(ctx, chat.Settings{
    Config: chat.Config{Provider: chat.ProviderClaude, Token: apiKey},
})

The module is config-system-agnostic: supply credentials via Config.Token, Config.Credentials, or the well-known env vars — the GTB Viper config schema stays in go-tool-base's adapter. See chat.go.phpboyscout.uk for the full API, provider matrix, and the core↔provider version-compatibility rules.