llm

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder creates LLM instances with configured capabilities using builder pattern. Each method immediately creates/decorates the instance.

Example:

llm, err := llm.New().
    Profile("bedrock/claude-3-sonnet").
    Debug(true).
    Think(true).
    MaxEpoch(10).
    Build()

func New

func New() *Builder

New creates a new LLM builder with mock LLM as default.

func (*Builder) Build

func (b *Builder) Build() (chatter.Chatter, error)

Build returns the configured LLM instance. Returns any error encountered during building.

func (*Builder) Cache

func (b *Builder) Cache(path string) *Builder

func (*Builder) Debug

func (b *Builder) Debug(enable bool) *Builder

Debug enables debug logging to stderr. Returns builder for chaining.

func (*Builder) Profile

func (b *Builder) Profile(profile, model string) *Builder

Creates LLM from profile defined at ~/.iqrc

machine iq

provider provider:bedrock/foundation/converse
model us.anthropic.claude-3-7-sonnet-20250219-v1:0
region us-west-2

Special value "mock" creates a mock LLM for testing of client applications.

func (*Builder) Quota

func (b *Builder) Quota(epoch int, usage chatter.Usage) *Builder

Quota the maximum number of epochs and tokens. Returns builder for chaining.

func (*Builder) Reporter

func (b *Builder) Reporter(reporter interface{ SetTokenSource(progress.TokenSource) }) *Builder

Reporter sets the progress reporter and wires it to the Router for token reporting. Returns builder for chaining.

func (*Builder) Think

func (b *Builder) Think(enable bool) *Builder

Think enables thinking mode (prints thinking content to stderr). Returns builder for chaining.

type Mock

type Mock struct{}

Mock is a simple mock LLM that echoes the input.

func (*Mock) Prompt

func (m *Mock) Prompt(ctx context.Context, prompt []chatter.Message, opt ...chatter.Opt) (*chatter.Reply, error)

func (*Mock) Usage

func (m *Mock) Usage() chatter.Usage

type ProfileUsage

type ProfileUsage struct {
	Name  string
	Usage chatter.Usage
}

ProfileUsage represents token usage for a specific LLM profile

type Route

type Route string

Chatter interface option allowing to dynamically route prompts to choosen models

func (Route) ChatterOpt

func (Route) ChatterOpt()

type Router

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

Dynamic routing strategy throught pool of LLMs. The LLMs pool consists of default "route" and multiple named models.

func NewRouter

func NewRouter(profile, model string) (*Router, error)

Creates LLMs pools instance

func (*Router) ProfileUsage

func (router *Router) ProfileUsage() []ProfileUsage

ProfileUsage returns token usage breakdown by LLM profile

func (*Router) Prompt

func (router *Router) Prompt(ctx context.Context, prompt []chatter.Message, opts ...chatter.Opt) (reply *chatter.Reply, err error)

func (*Router) Usage

func (router *Router) Usage() chatter.Usage

Jump to

Keyboard shortcuts

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