llm

package
v0.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package llm provides a minimal chat client for LLM-powered memory features: auto topic extraction and project summarization. Supports Ollama, any OpenAI-compatible endpoint and the Anthropic Messages API. Optional: nil client disables LLM features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChatJSON

func ChatJSON(ctx context.Context, c Client, system, user string, v any) error

ChatJSON asks the model to return a JSON object and decodes it into v. It strips markdown code fences if the model wraps the JSON.

Types

type AnthropicClient added in v0.5.0

type AnthropicClient struct {
	BaseURL   string
	APIKey    string
	Model     string
	MaxTokens int
}

AnthropicClient talks to the Anthropic Messages API (/v1/messages). Any Anthropic-compatible endpoint (api.anthropic.com, Bedrock/Vertex proxies, self-hosted gateways) works through the same client.

func NewAnthropic added in v0.5.0

func NewAnthropic(baseURL, apiKey, model string) *AnthropicClient

NewAnthropic returns an Anthropic client with defaults. A small fast model is chosen: topic extraction and summarization are short JSON tasks.

func (*AnthropicClient) Chat added in v0.5.0

func (a *AnthropicClient) Chat(ctx context.Context, system, user string) (string, error)

type Client

type Client interface {
	// Chat sends a system+user message and returns the assistant reply.
	Chat(ctx context.Context, system, user string) (string, error)
}

Client is the minimal chat interface used by memory features.

type OllamaClient

type OllamaClient struct {
	BaseURL string
	Model   string
}

OllamaClient talks to a local Ollama /api/chat endpoint.

func NewOllama

func NewOllama(baseURL, model string) *OllamaClient

NewOllama returns an Ollama client with defaults.

func (*OllamaClient) Chat

func (o *OllamaClient) Chat(ctx context.Context, system, user string) (string, error)

type OpenAICompatClient

type OpenAICompatClient struct {
	BaseURL string
	APIKey  string
	Model   string
}

OpenAICompatClient talks to any OpenAI-compatible /v1/chat/completions endpoint.

func NewOpenAICompat

func NewOpenAICompat(baseURL, apiKey, model string) *OpenAICompatClient

NewOpenAICompat returns an OpenAI-compatible chat client with defaults.

func (*OpenAICompatClient) Chat

func (o *OpenAICompatClient) Chat(ctx context.Context, system, user string) (string, error)

Jump to

Keyboard shortcuts

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