llm

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 12 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

Index

Constants

This section is empty.

Variables

View Source
var ErrDailyLimitExceeded = errors.New("daily LLM call limit exceeded")

ErrDailyLimitExceeded is returned when the daily LLM call limit is reached.

Functions

This section is empty.

Types

type Client

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

Client wraps the Gemini API for text generation and embeddings.

func New

func New(apiKey string, logger *slog.Logger) *Client

New creates a new LLM client.

func (*Client) DailyCount

func (c *Client) DailyCount() int

DailyCount returns the current day's LLM call count.

func (*Client) Embed

func (c *Client) Embed(ctx context.Context, text string) ([]float32, error)

Embed generates an embedding for the given text using Gemini's embedding model.

func (*Client) GenerateJSON

func (c *Client) GenerateJSON(ctx context.Context, prompt string, temperature float64, maxTokens int) (string, error)

GenerateJSON sends a prompt to Gemini and returns the raw JSON response text.

func (*Client) GenerateJSONWithSystem

func (c *Client) GenerateJSONWithSystem(ctx context.Context, systemPrompt, userContent string, temperature float64, maxTokens int) (string, error)

GenerateJSONWithSystem sends user content to Gemini with a trusted system instruction and returns the raw JSON response text.

func (*Client) SetDailyLimit

func (c *Client) SetDailyLimit(limit int)

SetDailyLimit sets the maximum number of LLM API calls per day. 0 means unlimited. Values exceeding math.MaxInt32-1 are clamped to math.MaxInt32-1; negative values are clamped to 0 (unlimited). The upper bound is math.MaxInt32-1 (not MaxInt32) so that checkAndIncrementDaily can Add(1) past the limit without int32 wraparound, which would otherwise cause count>limit to read false and silently bypass the cap.

type Provider

type Provider interface {
	GenerateJSON(ctx context.Context, prompt string, temperature float64, maxTokens int) (string, error)
	GenerateJSONWithSystem(ctx context.Context, systemPrompt, userContent string, temperature float64, maxTokens int) (string, error)
	Embed(ctx context.Context, text string) ([]float32, error)
}

Provider defines the LLM operations that triage phases require.

Jump to

Keyboard shortcuts

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