llm

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const SystemPrompt = `` /* 719-byte string literal not displayed */

Variables

View Source
var Providers = map[string]Provider{
	"openai": {
		Key:         "openai",
		DisplayName: "OpenAI",
		BaseURL:     "https://api.openai.com/v1",
		APIKeyEnv:   "OPENAI_API_KEY",
		RequiresKey: true,
	},
	"openrouter": {
		Key:         "openrouter",
		DisplayName: "OpenRouter",
		BaseURL:     "https://openrouter.ai/api/v1",
		APIKeyEnv:   "OPENROUTER_API_KEY",
		RequiresKey: true,
	},
	"ollama": {
		Key:         "ollama",
		DisplayName: "Ollama",
		BaseURL:     "http://localhost:11434/v1",
		RequiresKey: false,
	},
}

Functions

func BuildSelectionPrompt

func BuildSelectionPrompt(description string, tree string, candidates []*scanner.TreeEntry) string

func ClientFromConfig

func ClientFromConfig(cfg config.Config, selection config.AISelection) (Client, Provider, error)

func ParseDecisionIDs

func ParseDecisionIDs(response string, validIDs map[int]struct{}) ([]int, error)

func RequireDecisions

func RequireDecisions(ids []int) error

func ValidIDSet

func ValidIDSet(ids []int) map[int]struct{}

Types

type Client

type Client struct {
	Provider   Provider
	APIKey     string
	HTTPClient *http.Client
	Logger     *slog.Logger
}

func NewClient

func NewClient(provider Provider, apiKey string) Client

func (Client) ChatCompletion

func (c Client) ChatCompletion(ctx context.Context, model string, messages []Message) (string, error)

func (Client) ListModels

func (c Client) ListModels(ctx context.Context) ([]string, error)

type Message

type Message struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type Provider

type Provider struct {
	Key         string
	DisplayName string
	BaseURL     string
	APIKeyEnv   string
	RequiresKey bool
}

func ProviderByKey

func ProviderByKey(key string) (Provider, error)

Jump to

Keyboard shortcuts

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