ai

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ai contains bounded HTTP clients for optional model integrations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentOptions

type AgentOptions struct {
	Model           string
	API             string
	Instructions    string
	Prompt          string
	Initial         string
	MaxSteps        int
	MaxCalls        int
	MaxOutputTokens int
	MaxToolBytes    int
}

type AgentResult

type AgentResult struct {
	Status    string `json:"status"`
	Response  string `json:"response"`
	Steps     int    `json:"steps"`
	ToolCalls int    `json:"toolCalls"`
}

type Call

type Call struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Function struct {
		Name      string `json:"name"`
		Arguments string `json:"arguments"`
	} `json:"function"`
}

type Choice

type Choice struct {
	Type          string             `json:"type"`
	Choice        string             `json:"choice"`
	Confidence    *float64           `json:"confidence"`
	Probabilities map[string]float64 `json:"probabilities"`
	Abstention    bool               `json:"abstention,omitempty"`
}

type Classification

type Classification struct {
	ID            int64              `json:"id"`
	Category      string             `json:"category"`
	Confidence    float64            `json:"confidence"`
	Probability   float64            `json:"probability"`
	Probabilities map[string]float64 `json:"probabilities"`
	NeedsReview   bool               `json:"needsReview"`
}

type ClassificationResult

type ClassificationResult struct {
	Model   string           `json:"model"`
	Results []Classification `json:"results"`
}

func Classify

func Classify(ctx context.Context, c Poster, model string, items []raindrop.Raindrop, categories map[string]string, minConfidence, minProbability float64) (ClassificationResult, error)

type Client

type Client struct {
	BaseURL string
	Key     string
	HTTP    *http.Client
}

func NewClient

func NewClient(baseURL, key string) (*Client, error)

func (*Client) Classify

func (c *Client) Classify(ctx context.Context, model string, items []raindrop.Raindrop, categories map[string]string, minConfidence, minProbability float64) (ClassificationResult, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, path string, body, out any) error

func (*Client) RunAgent

func (c *Client) RunAgent(ctx context.Context, options AgentOptions, tools []Tool, execute Execute) (AgentResult, error)

RunAgent executes tools sequentially and feeds their results back until the model finishes or a hard limit/error stops the loop. It does not retry writes.

type CloudflareProvider

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

CloudflareProvider adapts the Workers AI envelope to System One decisions.

func NewCloudflareProvider

func NewCloudflareProvider(base, key, account, model string) (*CloudflareProvider, error)

func (*CloudflareProvider) Post

func (p *CloudflareProvider) Post(ctx context.Context, method string, body, out any) error

type CommandProvider

type CommandProvider struct {
	Path    string
	Args    []string
	Timeout time.Duration
}

CommandProvider executes a user-configured executable directly. No shell is involved and model/tool inputs never choose an executable or its arguments.

func (CommandProvider) Post

func (c CommandProvider) Post(ctx context.Context, _ string, body, out any) error

type Execute

type Execute func(context.Context, string, json.RawMessage) any

type Poster

type Poster interface {
	Post(context.Context, string, any, any) error
}

type Tool

type Tool struct {
	Name        string
	Description string
	Schema      any
	Validate    func(json.RawMessage) error
}

Jump to

Keyboard shortcuts

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