llm

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 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 llm is the plugin that calls a model. Its chat gives the conversation so far, the tools on offer and what is wanted, and gets back what the model said, the tools it asked for, why it stopped and how many tokens were used. Its decide gives a System One model text or data and named questions about it, and gets back the answers.

Index

Constants

View Source
const (
	StopEnd    = "end"    // it finished
	StopTools  = "tools"  // it asked for tools
	StopLength = "length" // it ran out of room
)

Why a model stopped.

Variables

View Source
var (
	Images    = []Accept{{"image/png", 5 << 20}, {"image/jpeg", 5 << 20}, {"image/gif", 5 << 20}, {"image/webp", 5 << 20}}
	Documents = []Accept{{"application/pdf", 32 << 20}}
)

The types of content the services take beside text, and the largest of each, as the services say.

Functions

func Having added in v0.3.0

func Having(call func(*Service) bool) []string

Having gives the services that make a call: those with Chat, or those with Decide.

func Names

func Names() []string

Names are the services this Corbie holds.

func Of

func Of(model string) string

Of gives the service a model is usually of, from its name; none if no service claims it.

func Register

func Register(s *Service)

Register adds a model service.

func ResultText

func ResultText(result any) (string, bool)

func Schema

func Schema(args any) map[string]any

Schema, Text and ResultText are for a service kept in a package of its own.

func Text

func Text(v any) string

Types

type Accept

type Accept struct {
	Type string
	Most int64
}

Accept is one type of content a service takes beside text, and the largest of it that it takes.

type Answers added in v0.3.0

type Answers struct {
	Model   string
	Answers map[string]any
	Usage   map[string]any
}

Answers is what a System One model gave back: an answer under each question's name, as the service wrote it.

type Call

type Call struct {
	Model  string
	System string
	Said   []any // the conversation so far
	Tools  []any
	Effort string
	Room   int // the most a reply may hold
	// Address and Key are where a service on the web is and what opens it.
	Address string
	Key     any
	Limit   time.Duration
	// Own are the tools of its own that a program may use.
	Own []string
	// Shape is the shape of answer wanted, for a service that takes it
	// itself.
	Shape map[string]any
}

Call is one call to a model.

type File

type File struct {
	Name string
	Blob *plugin.Blob
}

A File is content beside text that a part of the conversation carries: an image or a document, under the name the model knows it by.

func Files

func Files(holder any) []File

Files gives the files a part of the conversation, or one tool's result, carries, in the order of their names.

func (File) Data

func (f File) Data(job *plugin.Job) (string, error)

Data gives a file's contents as base64, which is how every service takes them.

type Questions added in v0.3.0

type Questions struct {
	Model     string
	State     any
	Questions map[string]any
	Address   string
	Key       any
	Limit     time.Duration
}

Questions is one call to a System One model: the text or data the questions are about, and the questions under their names.

type Reply

type Reply struct {
	Text  string
	Calls []any // each { id, name, args }
	Stop  string
	Usage map[string]any
	Kept  any // parts the service wants back unchanged
}

Reply is what a model gave back.

type Service

type Service struct {
	Name string
	// Address is where a service on the web usually lives. Program is,
	// for one that is a program, the program that is started.
	Address string
	Program string
	// Models are how the names of the models it is the usual service of
	// begin. Known are models it is known to offer, by the names it knows
	// them by: for a person choosing one. It takes any name, and what is
	// not there is not listed.
	Models []string
	Known  []string
	// Tools are, for a program, the tools of its own it is known to have:
	// for a person choosing which it may use. Any may be named.
	Tools []string
	// Efforts are the levels of effort it takes, and Accepts the kinds of
	// content it takes beside text.
	Efforts []string
	Accepts []Accept
	// Needs says, for a program, what a tool of the program's own could
	// use: a group of permissions. Corbie does not run such a tool, so it
	// is allowed only where that whole group is.
	Needs func(tool string) string
	// Shapes says the service has a way of its own to be given the shape
	// of answer wanted. One that has none is told it in the system text.
	Shapes bool
	// Chat holds a conversation: one call. Decide puts questions with fixed
	// answers to a System One model. A service has one or both.
	Chat   func(job *plugin.Job, c *Call) (*Reply, error)
	Decide func(job *plugin.Job, q *Questions) (*Answers, error)
}

A Service is one way of reaching a model: an extension. One on the web speaks one service's way of talking; one that is a program starts it.

func Find

func Find(name string) (*Service, bool)

Find gives a service by its name.

func (*Service) Takes

func (s *Service) Takes(typ string, size int64) error

Takes says whether a service takes content of a type and size, and, if it does not, why.

Directories

Path Synopsis
Package claudecode is the model service that is a program: it starts Claude Code on the runner's machine and has it write one reply.
Package claudecode is the model service that is a program: it starts Claude Code on the runner's machine and has it write one reply.
Package standin is a model service for tests: it speaks Anthropic's Messages API, streams each reply as server-sent events, and keeps every call it is sent.
Package standin is a model service for tests: it speaks Anthropic's Messages API, streams each reply as server-sent events, and keeps every call it is sent.

Jump to

Keyboard shortcuts

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