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 ¶
const Name = "llm"
Name is the name of the namespace
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
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 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)
// 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 ¶
Description returns what the namespace's tools are for
func (*Namespace) Notify ¶
func (*Namespace) Notify(func(eventschema.EventAction, string))
Notify does nothing, as the tools don't change
func (*Namespace) SystemPrompt ¶
SystemPrompt returns nothing, as each tool says what it does
type Opt ¶
type Opt func(*opt) error
Opt is an option of the namespace
func WithOCR ¶
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
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 ¶
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 ¶
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