llm

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 33 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 has the llm namespace of tools, which ask the registry's models to do what a model which calls them can't, such as speak text, whose results, such as audio, are resources, which are kept, as resources of the session the tools run in

Index

Constants

View Source
const Name = "llm"

Name is the name of the namespace

View Source
const PreferredModels = "preferred_models"

PreferredModels is the key of the memory which has the models the person chose for each capability, such as ocr, which the tools' descriptions tell the model which calls them to recall, and remember

View Source
const (
	// VoiceNote is the format of speech which is a voice note, such as a
	// messaging app's, which is Ogg Opus
	VoiceNote = "voice-note"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agents added in v1.6.4

type Agents interface {
	ListAgents(ctx context.Context, req registryschema.AgentListRequest) (*registryschema.AgentList, error)
	GetAgent(ctx context.Context, name string) (*registryschema.Agent, error)
	InsertAgent(ctx context.Context, meta registryschema.AgentMeta) (*registryschema.Agent, error)
	UpdateAgent(ctx context.Context, name string, meta registryschema.AgentMeta) (*registryschema.Agent, error)
}

Agents are the registry's agents, which the agent tool lists, gets, creates, and updates, of the agent namespace, which can be changed

type AgentsFunc added in v1.6.4

type AgentsFunc func() Agents

AgentsFunc returns the agents, or nil, when there are none yet, such as when the registry, which has the toolkit, isn't made yet

type Models

type Models interface {
	// ListModels returns the models of every provider, or of the providers
	// with the names, of those which can be listed, and an error for those
	// which can't
	ListModels(ctx context.Context, providers ...string) ([]gollm.Model, error)

	// Name returns the name of the model, by which it's given, which is its
	// provider's name, and its own, such as ollama:phonon:latest
	Name(model gollm.Model) string

	// GetModel returns the model with the name, or ErrNotFound
	GetModel(ctx context.Context, name string) (gollm.Model, error)

	// Speak returns the text, spoken by the model, as audio
	Speak(ctx context.Context, model gollm.Model, text string, opts ...gollm.Opt) (gollm.Resource, gollm.Usage, error)

	// ListVoices returns the voices the model speaks in, or none, when its
	// provider can't say, a page at a time, with how many there are, and the
	// token of the next page
	ListVoices(ctx context.Context, model gollm.Model, opts ...gollm.Opt) (*gollm.VoiceList, error)

	// Illustrate returns the images the model makes from the prompt, or by
	// changing, or combining, the images
	Illustrate(ctx context.Context, model gollm.Model, prompt string, images []gollm.Resource, opts ...gollm.Opt) ([]gollm.Resource, gollm.Usage, error)

	// Recognize returns the text in the image, or document
	Recognize(ctx context.Context, model gollm.Model, resource gollm.Resource, opts ...gollm.Opt) (gollm.Document, gollm.Usage, error)

	// Transcribe returns the speech in the audio, as text
	Transcribe(ctx context.Context, model gollm.Model, audio gollm.Resource, stream gollm.TranscriberStreamFn, opts ...gollm.Opt) (gollm.Transcript, gollm.Usage, error)

	// Translate returns the speech in the audio, as English text
	Translate(ctx context.Context, model gollm.Model, audio gollm.Resource, stream gollm.TranscriberStreamFn, opts ...gollm.Opt) (gollm.Transcript, gollm.Usage, error)
}

Models is what the tools ask: the models, a model, by its name, to speak text, to recognize the text in an image or document, and to transcribe, or translate, speech, such as the registry

type ModelsFunc

type ModelsFunc func() Models

ModelsFunc returns the models, or nil, when there are none yet, such as when the registry, which has the toolkit, isn't made yet

type Namespace

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

Namespace is the llm namespace, of its tools: models, speak, illustrate, ocr, and transcribe, each with the model the model which calls it gives, or its default

func New

func New(models ModelsFunc, opts ...Opt) (*Namespace, error)

New returns the namespace, whose tools ask the models the function returns, with the model which calls them gives, or the defaults the options set

func (*Namespace) Description

func (*Namespace) Description() string

Description returns what the namespace's tools are for

func (*Namespace) Name

func (*Namespace) Name() string

Name returns the namespace's name

func (*Namespace) SystemPrompt

func (*Namespace) SystemPrompt() string

SystemPrompt returns nothing, as each tool says what it does

func (*Namespace) Tools

func (n *Namespace) Tools() []gollm.Tool

Tools returns the tools which are set up

func (*Namespace) Type added in v1.6.0

func (*Namespace) Type() string

Type returns that the namespace's tools are built in

func (*Namespace) Watch added in v1.7.0

func (ns *Namespace) Watch(ctx context.Context, ch chan<- eventschema.Change) error

Watch sends the namespace's tools, which don't change

type Opt

type Opt func(*opt) error

Opt is an option of the namespace

func WithAgents added in v1.6.4

func WithAgents(agents AgentsFunc) Opt

WithAgents adds the agent tool, which lists, gets, creates, and updates the agents of the agent namespace, of the function's agents, such as the registry's, once it's made

func WithOCR

func WithOCR(model string) Opt

WithOCR sets the model the ocr tool recognizes the text in an image, or a document, such as a PDF, with, by its name, such as mistral:mistral-ocr-latest, unless the model which calls it gives another

func WithResources added in v1.4.2

func WithResources(resources Resources) Opt

WithResources adds the resource tool, which lists the chat's files, and reads a file, by its URI, as Markdown, a part at a time, from the resources, such as a resource.Manager

func WithSpeak

func WithSpeak(model, voice string) Opt

WithSpeak sets the model the speak tool speaks text with, by its name, such as ollama:phonon:latest, and the voice, each unless the model which calls it gives another. Without a model, the model which calls it gives one, and without a voice, it's the model's own. Returns ErrBadParameter when neither is set.

func WithTranscribe

func WithTranscribe(model string) Opt

WithTranscribe sets the model the transcribe tool transcribes, or translates into English, the speech in audio with, by its name, such as openai:whisper-1, unless the model which calls it gives another

func WithVoiceNoteConverter added in v1.5.0

func WithVoiceNoteConverter(converter VoiceNoteConverter) Opt

WithVoiceNoteConverter sets the converter of voice notes, such as one which runs opusenc, which speech is converted with, when it's asked for as a voice note, and its model can't speak one itself, without which it's only one when the model can

type Resources added in v1.4.2

type Resources interface {
	// List returns the resources, such as a chat's, the most recently used
	// first
	List(context.Context, schema.ResourceListRequest) (schema.ResourceList, error)

	// Open returns the resource, and its content, which is closed once it's
	// read
	Open(context.Context, schema.ResourceKey) (schema.Resource, io.ReadCloser, error)
}

Resources are the files of chats, and on their own, which the resource tool lists, and reads, such as a resource.Manager

type VoiceNoteConverter added in v1.5.0

type VoiceNoteConverter interface {
	// Convert returns the audio as a voice note, which is Ogg Opus, or
	// ErrNotImplemented when it isn't audio it converts
	Convert(ctx context.Context, audio gollm.Resource) (gollm.Resource, error)
}

VoiceNoteConverter converts audio, such as speech a model spoke, to a voice note, which is Ogg Opus, such as with opusenc, of opus-tools

Jump to

Keyboard shortcuts

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