ai

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package ai provides AI backends for article translation and summarization. Supports OpenAI-compatible HTTP APIs and local AI CLIs (Claude Code, pi, opencode).

Index

Constants

View Source
const (
	ProviderOpenAI   = "openai"   // OpenAI-compatible HTTP API
	ProviderClaude   = "claude"   // Claude Code CLI (subscription)
	ProviderPi       = "pi"       // pi CLI
	ProviderOpencode = "opencode" // opencode CLI
)

Provider selects the AI backend.

Variables

This section is empty.

Functions

func Complete

func Complete(ctx context.Context, cfg Config, system, user string) (string, error)

Complete sends a request and returns the assistant reply. Routes to the appropriate backend based on cfg.Provider.

func Summarize

func Summarize(ctx context.Context, cfg Config, text string) (string, error)

Summarize sends the text for summarization.

func Translate

func Translate(ctx context.Context, cfg Config, text, targetLang string) (string, error)

Translate sends the text for translation to the target language.

Types

type Config

type Config struct {
	Provider string // "openai", "claude", "pi", or "opencode"
	Endpoint string // HTTP API URL (openai provider only)
	APIKey   string // optional API key (openai provider only)
	Model    string // model name (openai) or optional CLI model flag
}

Config holds the connection parameters for AI.

func (Config) Enabled

func (c Config) Enabled() bool

Enabled returns true when a usable provider is configured.

Jump to

Keyboard shortcuts

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