ai

package
v0.21.3 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotConfigured = errors.New("ai: not configured (no API key)")

ErrNotConfigured is returned when AI features are used without an API key.

Functions

func RecipePrompt added in v0.7.0

func RecipePrompt(promptFile string) string

RecipePrompt returns the system prompt for recipe creation. If promptFile is non-empty and the file exists, its contents are appended to the base prompt.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles Anthropic API interactions.

func NewClient

func NewClient(apiKey string) *Client

NewClient creates a Client. If apiKey is empty, calls will return ErrNotConfigured.

func (*Client) RunAgent added in v0.7.0

func (c *Client) RunAgent(
	systemPrompt string,
	userPrompt string,
	tools []Tool,
	maxIterations int,
) (string, error)

RunAgent executes an agentic loop with tools. Returns the final text response. The agent calls tools until it produces a text-only response or hits maxIterations.

type Tool added in v0.7.0

type Tool struct {
	Param   anthropic.ToolParam
	Handler func(input json.RawMessage) (string, error)
}

Tool defines a tool the agent can call.

func RecipeTools added in v0.7.0

func RecipeTools(
	recipeDir string,
	checkRecipe func(string) bool,
) ([]Tool, func(), error)

RecipeTools returns the tools available for recipe creation, a cleanup function, and any error from creating the temp download directory. recipeDir is where recipes are written (letter-bucketed). The caller must check error before deferring cleanup; on error, cleanup is a no-op.

Jump to

Keyboard shortcuts

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