llm

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 2 modules, 2 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.

README

go-llm

Go Reference License

go-llm is a server, command-line tool and Go SDK which puts large language models and speech models from several providers behind one interface. You add providers, such as Ollama, OpenAI, Anthropic, Mistral, go-whisper and ElevenLabs, and then ask any of their models to reply to messages, call tools, run agents, embed text and images, read the text in documents, and transcribe and translate speech. The same operations are available as a REST API, from the llm command, which includes an interactive chat in the terminal, or directly from Go.

Quick Start

1. Run the server, with Docker

The image has the server, and its web UI, and keeps its providers, sessions, agents and memory in the /data volume:

docker run -d --name llm -p 8084:8084 -v llm:/data \
  -e OLLAMA_ADDR=http://host.docker.internal:11434 \
  -e OPENAI_API_KEY \
  ghcr.io/mutablelogic/llm

Then open http://localhost:8084/, to chat, and see the models and tools:

host.docker.internal is the machine Docker runs on, such as for an Ollama server which runs there, which Docker Desktop has, and Linux has with --add-host=host.docker.internal:host-gateway.

When it's first started, the server has the Eliza provider, unless NO_ELIZA is set, and those whose variables are set: OLLAMA_ADDR and GOWHISPER_ADDR, as their URLs, and OPENAI_API_KEY, ANTHROPIC_API_KEY, DEEPSEEK_API_KEY, MISTRAL_API_KEY and ELEVENLABS_API_KEY, whose keys are read from the container's environment when they're used, rather than stored. UID and GID set the user it runs as, such as the owner of a directory which is mounted at /data.

Or run it with Docker Compose, whose compose file has every variable the server reads, from the environment, or a .env file, and, with the ollama profile, an Ollama server, which OLLAMA_ADDR=http://ollama:11434 adds:

docker compose -f docker/compose.yaml --profile ollama up -d
2. Install the command-line tool

The command-line tool, without the server, is built with the client tag. Install it with Go:

go install -tags client github.com/mutablelogic/go-llm/cmd/llm@latest

Or, in a clone of the repository, run make client, which builds it into build/llm.

It connects to the server at localhost:8084, or the one at --http.addr, or LLM_ADDR, such as LLM_ADDR=nas.local:8084.

3. Add providers

Providers which weren't added when the server was first started are added with the command-line tool. An API key is given by the name of its variable, as --api-key-credential, which the server reads from its own environment, which is the container's, rather than the command-line tool's, so the key isn't stored, or sent:

# Providers
llm provider-create-ollama http://host.docker.internal:11434
llm provider-create-openai --api-key-credential OPENAI_API_KEY
llm provider-create-anthropic --api-key-credential ANTHROPIC_API_KEY
llm provider-create-mistral --api-key-credential MISTRAL_API_KEY
llm provider-create-gowhisper http://host.docker.internal:8081
llm provider-create-elevenlabs --api-key-credential ELEVENLABS_API_KEY

# The providers, and their models, in order of name
llm providers
llm models
4. Ask, and chat

Then ask models to do something. A command's model is kept, and used until another is given:

# Ask a question, and stream the reply
llm ask --model gpt-4o-mini "Explain a KV cache in two sentences"

# Ask about files: text, such as code, is sent as text, and an image or a
# PDF as an attachment, which the model must accept
llm ask --file main.go "What does this do?"
llm ask --model gpt-4o --file chart.png --file notes.md "Do these agree?"

# Embed text, or an image
llm embed --model mistral-embed "A cat asleep in the sun"

# The text of a document, as Markdown
llm ocr --model mistral-ocr-latest report.pdf

# The speech in audio, as text, or as subtitles, with speakers
llm transcribe --model whisper-1 talk.m4a
llm transcribe --model voxtral-mini-latest --opt speakers=true --format srt talk.m4a

# Speech in any language, in English
llm translate --model whisper-1 interview.wav

# Download a model
llm model-load ollama:llama3.2

Or chat in a session, which the server keeps. A session is kept, and used until another is given:

# A session, with a model, a system prompt, and tools it can call
llm session-create --model ollama:llama3.2 --system "Be brief" --tools "weatherapi:*"

# Chat in the terminal, or ask once, in the session
llm chat
llm chat "Will it rain in Berlin tomorrow?"

# Its messages, and its sessions
llm session-messages
llm sessions
Without Docker

Install the server and command-line tool, which are both llm, with Go, and run the server, which listens on localhost:8084, and keeps its data in the user's cache directory:

go install github.com/mutablelogic/go-llm/cmd/llm@latest
llm run

A server installed with go install serves the API, without the web UI, which make, from a clone of the repository, builds, with npm, into build/llm.

Architecture

flowchart LR
    subgraph Clients
        direction TB
        CLI["`**llm** command
        and interactive chat`"]
        Client["`**registry/httpclient**
        Go client`"]
        UI["`**frontend**
        web UI`"]
    end

    subgraph Server["Server, or your own Go program"]
        direction TB
        API["`**httphandler**
        REST API and events`"]
        Registry["`**registry**
        providers, models, sessions`"]
        Toolkit["`**toolkit**
        tools, in namespaces`"]
        Agents["`**agents**
        prompts which models call as tools`"]
        Memory["`**memory**
        what every session knows`"]
        Heartbeat["`**heartbeat**
        prompts which fire on a schedule`"]
        Stores[("`**stores**
        providers, sessions, agents, memory, heartbeats`")]
    end

    subgraph Providers
        direction TB
        Ollama["`**ollama**`"]
        OpenAI["`**openai**
        OpenAI, Mistral, DeepSeek`"]
        Anthropic["`**anthropic**`"]
        Whisper["`**gowhisper**`"]
        ElevenLabs["`**elevenlabs**`"]
        Eliza["`**eliza**
        for testing`"]
    end

    subgraph Tools
        direction TB
        HA["Home Assistant"]
        News["NewsAPI"]
        Weather["WeatherAPI"]
        Search["Ollama web search"]
    end

    CLI --> Client
    Client --> API
    UI --> API
    API --> Registry
    Registry --> Stores
    Registry --> Toolkit
    Toolkit --> Agents
    Toolkit --> Memory
    Agents --> Registry
    API --> Memory
    Memory --> Stores
    Toolkit --> Heartbeat
    API --> Heartbeat
    Heartbeat --> Stores
    Toolkit --> Tools
    Registry --> Ollama & OpenAI & Anthropic & Whisper & ElevenLabs & Eliza

    classDef highlight fill:#e8f0fe,stroke:#1a73e8,stroke-width:2px,color:#111
    class CLI,Client,UI,Registry,Toolkit,Agents,Memory,Heartbeat highlight
    class Ollama,OpenAI,Anthropic,Whisper,ElevenLabs,Eliza highlight
  • The client and CLI: the llm command, in cmd/llm, runs the server, and is its client, with commands for each operation, and an interactive chat in the terminal, which streams replies and follows other clients of the same session. The Go client, registry/httpclient, is what it uses to talk to the server.
  • The web UI, in frontend, which the server serves, when it's built with make, is a page to chat in sessions, with replies streamed, to see the models and tools, to add, edit and delete providers, whose API keys are given as the names of environment variables on the server, so the keys aren't stored, to load and delete models, and to create, edit and delete agents, as YAML, apart from the built-in ones, which can be copied.
  • The registry, in registry, finds a model by name, checks what it can do, and asks its provider. It keeps providers, sessions and agents in stores, runs the agent loop, which calls tools until the model replies, and publishes events about what changed.
  • The toolkit, in toolkit, holds the tools which models can call, in namespaces, such as homeassistant or weatherapi, and streams what they log, and their progress, as they run.
  • The memory, in memory, is what every session and agent knows: the details of the person, and of the assistant, such as their names, where the person is, and their time zone and language, each known, not known, or declined, and memories, which are what a model keeps beyond the conversation, such as the person's preferences, or the people in their life, under keys. It's the toolkit's memory namespace, whose system prompt has the details, the time, and how to search, keep and use memories, and whose tools remember them.
  • Heartbeats, in heartbeat, are prompts for a session, which fire once, at a time, or again and again, on a schedule, such as a reminder, or a briefing each morning. A schedule is in its time zone, or the person's, which the memory has, so it follows them. It's the toolkit's heartbeat namespace, whose tool schedules them, and a heartbeat which fires is run, in a session of its own, whose identifier is the heartbeat's, with the model of the session it's for.
  • Agents are named prompts, with their model, tools and the schemas of their input and reply, which models call as tools in the agent namespace. The agents folder has examples, which the server adds when it starts.
  • The providers, in provider, each wrap a provider's API, and do what it can: generate, embed, read documents, or transcribe and translate speech.

The registry can be used without the server, from your own Go program, as the examples show.

Features

  • Providers: add, update and remove providers while the server runs, and keep them in a store between restarts. A model is referred to by its name, or by its provider and name, such as ollama:llama3.2:latest.
  • Ask: a model's reply to messages, with a system prompt, options, tools whose calls are returned for the caller to run, and structured output with a JSON schema. Replies can be streamed as server-sent events.
  • Chat: a conversation with a model, in a session, which the server keeps, with its model, system prompt, tools, options and schema. The model calls the tools until it replies, and the conversation is shortened to fit its context. Chat in the terminal, in the web UI, or with the API, whose replies are streamed, and every client of a session sees its new messages, and whether someone is typing, or the model is replying.
  • Agents: named definitions of a prompt, its input, and how a model is asked it, with its system prompt, tools, options and the schema of its reply, which are kept, in YAML or JSON, and which models call as tools, in the agent namespace, however deep, with their progress streamed, and their tokens counted as their caller's. The server adds example agents when it starts, such as one which translates text, and the event agent, which runs a heartbeat which fires, in its own session, with what the system says of the person and the time in a <system-reminder> block, and replies with what the person is told, and whether they're alerted, notified, or it's ignored.
  • Embed: a vector for each message, of its text, and of images and audio for models which embed them.
  • OCR: the text of images and documents, such as PDFs, as Markdown, page by page, with the regions of each page and their boxes.
  • Transcribe and translate: the speech in audio, as text, in its language or in English, with timed segments and speakers, streamed as it's transcribed, and printed as SRT or WebVTT subtitles.
  • Models: download, delete and unload models, for providers which store them, such as Ollama and go-whisper.
  • Tools: a toolkit of tools, in namespaces, for Home Assistant, NewsAPI, WeatherAPI and Ollama's web search, which models can call.
  • Memory: the details of the person, and of the assistant, such as their names, location, time zone and language, which every session knows, as a model learns them, or they're set, and which can be declined, so they're never asked for; and memories, which a model searches, keeps and forgets, as Markdown, under keys, with versions, so a change is made to a memory as it was last seen. The server keeps each memory in a file, which can be read, and edited, by hand.
  • Heartbeats: prompts for a session, which a model schedules, or the API, once, at a time, or on a schedule, as a cron expression, such as a reminder at six, or a briefing every weekday at eight, in a time zone, or the person's, which they follow, as it changes. When the clocks change, a time fires once, and a heartbeat which was due when the server wasn't running fires once, when it starts. One which won't fire again is deleted a week after it last fired. Servers which share a store fire a heartbeat once. A heartbeat which fires is run by the event agent, in a session of its own, with the model and tools of the session it's for, which replies with what the person is told, and how important it is. Its outcome is stored, as ignored, or pending, until it's delivered, which is next, and listed at /llm/event.
  • Events: a stream of changes to the providers and their models, to sessions, with whether someone is typing in a session, or its model is replying, so two chat windows on one session follow each other, to the memory's details and memories, and to heartbeats, including when they fire.
  • OpenAPI: the REST API is described by an OpenAPI specification, which llm openapi shows as documentation in a browser, or outputs as JSON or YAML.
  • OpenTelemetry: traces of requests, through the registry, providers and tools.

Providers

Type Provider Generate Embed OCR Transcribe Translate Models
ollama Ollama ✅ ✅ ✅ (images) Download, delete, unload
openai OpenAI ✅ ✅ ✅ ✅ (whisper)
anthropic Anthropic's Claude models, which count tokens exactly, to fit a conversation to the model's context ✅
openai Mistral, at https://api.mistral.ai/v1 ✅ ✅ ✅ ✅
openai DeepSeek, and other OpenAI-compatible servers ✅
gowhisper go-whisper ✅ ✅ Download, delete
elevenlabs ElevenLabs ✅
eliza A mock of Weizenbaum's 1966 chatbot, for testing ✅

What a model can do depends on the model, which its provider reports, where it knows: such as whether it calls tools, thinks, sees images, or recognizes text. A request for something a model is known not to do is rejected before it's sent.

CLI Commands

Group Commands
Server run, openapi
Providers providers, provider, provider-create-ollama, provider-create-openai, provider-create-anthropic, provider-create-mistral, provider-create-deepseek, provider-create-gowhisper, provider-create-elevenlabs, provider-create-eliza, provider-update, provider-delete
Models models, model, model-load, model-delete, model-unload
Sessions sessions, session, session-messages, session-create, session-update, session-delete
Inference ask, chat, embed, ocr, transcribe, translate
Events events
Memory details, detail-set, detail-forget, memories, memory, memory-remember, memory-forget
Heartbeats heartbeats, heartbeat, heartbeat-create, heartbeat-update, heartbeat-delete
Tools and agents tools, tool, call, agents, agent, agent-create, agent-update, agent-delete

Run llm <command> --help for a command's arguments and flags. Options for a model are given with --opt, such as --opt temperature=0.2, or --opt pages=0-2 for OCR.

A few options are for the agent loop, which asks a model, runs the tools it calls, and asks it again, rather than for the model's provider:

Option Default
max_iterations 10, or 3 for ask The most times the model is asked for its reply.
max_depth 3 The most agents which run in one another, as a model calls an agent, which calls another, or itself. An agent can lower it, but not raise it.
tool_timeout 30s The most time a tool has to return.

They're given to a session, or an agent, such as llm session-update --opt max_iterations=20 --opt max_depth=2.

Tools

Tools are added to the server's toolkit when their credentials are set, as environment variables:

Namespace Tools Credentials
memory Remember the details of the person, and the assistant, with the time in the system prompt, and search, keep and forget memories None, as it's always added
heartbeat Schedule, list, update and cancel heartbeats, which are prompts which come back to the conversation, at a time, or on a schedule None, as it's always added
weatherapi Current weather, forecasts and alerts WEATHERAPI_API_KEY, from weatherapi.com
newsapi News articles, headlines and sources NEWSAPI_API_KEY, from newsapi.org
homeassistant Query, and search, and control smart home devices HOMEASSISTANT_URL, HOMEASSISTANT_API_KEY
ollama Web search and fetch, with Ollama's cloud service, rather than a local Ollama OLLAMA_API_KEY, from ollama.com

A model is given tools by name, by namespace and name, such as weatherapi:current, or all of a namespace's, such as weatherapi:*, or all of them, *.

API

The server's REST API is under /api, and documented in registry/httphandler/README.md, with its events in broadcaster/httphandler/README.md, the memory's in memory/httphandler/README.md, and the heartbeats' in heartbeat/httphandler/README.md, and as OpenAPI, with llm openapi. Inference which streams, such as ask and transcribe, sends server-sent events when text/event-stream is accepted.

Go

The packages can be used without the server:

  • llm: the interfaces of providers and models, and what they do: Generator, Embedder, Recognizer, Transcriber and Downloader, and the options for them.
  • provider/...: a client for each provider, which implements the interfaces it can.
  • registry: the registry of providers, which finds a model by name, checks what it can do, and asks its provider, with a store, events, and HTTP handlers and a client.
  • toolkit: the toolkit of tools, which a model calls.
  • memory: the memory, which is a namespace of the toolkit, with a store, events, and HTTP handlers and a client.
  • heartbeat: the heartbeats, which are a namespace of the toolkit, with a store, events, Run, which fires them, and HTTP handlers and a client.
  • broadcaster: publishes events, which are changes, to the channels which watch them, with an HTTP handler which streams them as server-sent events, and a client.

The registry is meant to be composed with other modules into a whole system, rather than to be one itself. It's created with options, which plug in what a system has:

  • WithProviderStore keeps the providers' definitions in a store, such as a database, so they're kept when the server restarts, and are shared between servers. A ProviderStore lists, puts and deletes providers, each with a serial, so a change to a provider which another server has changed is a conflict, and watches the store for the changes other servers make. The providers' models aren't stored, as they're listed from the providers, and cached.
  • WithSessionStore keeps sessions, which are conversations with models, in a store, such as a database, so they're kept when the server restarts. A SessionStore creates, gets, lists, puts and deletes sessions, each with a UUID and a serial, which the store sets, so a change to a session which was changed since it was read is a conflict, and watches the store for the changes other servers make. Without one, the registry's session methods return ErrServiceUnavailable.
  • WithAgentStore keeps agents, which are prompts with a model, tools and a schema of their input and reply, in a store, such as a database or files, so they're kept when the server restarts. An AgentStore creates, gets, lists, puts and deletes agents, each with its name and a serial, so a change to an agent which was changed since it was read is a conflict. The registry's agents are tools in the toolkit's agent namespace, which models can call. Without one, the registry's agent methods return ErrServiceUnavailable.
  • WithCredentialsProvider expands an API key's placeholder, such as ${OPENAI_KEY}, with a secret, from the environment by default, or from a secrets manager, so keys are never stored.
  • WithToolkit gives the registry the tools which models can call.
  • WithBroadcaster gives the registry the broadcaster which it publishes its events to, such as one which a system's other modules share, so their events are streamed together. Without one, the registry has its own.
  • WithTracer and WithClientOpts trace, and configure, the requests to providers.

Its HTTP handlers are registered with a router, alongside a system's own, and its events, such as a provider being created, or a session's model replying, are watched with Watch. The llm command, in cmd/llm, is one such system: it runs the registry, with a store which keeps its providers in the command's defaults, and its sessions and agents in files, the toolkit, and a broadcaster, which streams the registry's events, in a server.

The examples use the packages without the server, each with Ollama, when OLLAMA_ADDR is set, OpenAI, when OPENAI_API_KEY is, or Eliza, which needs neither:

Example
ask Ask a model a question, and stream its reply
tools A tool of your own, in a toolkit, which the registry runs as the model calls it
chat Chat in the terminal, with the conversation kept in memory
agent Run the example agent which translates text, which replies with JSON
ocr Read the text in an image, or a PDF, as Markdown, with Mistral or Ollama
transcribe Transcribe, or translate, the speech in audio, with OpenAI, Mistral, go-whisper or ElevenLabs
go run ./examples/ask "Explain a KV cache in two sentences"

Development

make vet race-test TEST_FLAGS=-short   # As CI runs the tests
make test                              # All the tests, with coverage

Tests which make requests to a provider are skipped with -short, and unless its credentials are set, such as OPENAI_API_KEY, ANTHROPIC_API_KEY, MISTRAL_API_KEY or ELEVENLABS_API_KEY, or its address, such as OLLAMA_ADDR or GOWHISPER_ADDR.

Roadmap

Sessions
  • Compaction: a session's conversation is compacted, so it doesn't grow without end, and each request doesn't trim the same messages again.
    • Markers: a message in a session which says its context starts there. The messages before the last marker aren't sent to the model, but are kept, so the UI still shows them, with a divider at each marker.
    • Summaries in the background: a marker is added at once, and a built-in compact agent then writes a summary of what came before it, in the background, which is added to the marker. The summary is sent first in the context, in a <system-reminder> block, so the model knows what was said. Until it's written, the model has only what's after the marker.
    • When markers are added: automatically, once a reply is stored, when the conversation fills more than about 80% of the model's context, and when it's asked for, with POST /llm/session/{id}/compact, and a Compact action in the chat. An event's session has a marker before each run, so a run sees only itself, and a summary of the runs before it.
    • Forgetting: forgetting a session's messages could add a marker, without a summary, rather than delete them, so they're kept.
    • The trimming each request does now, which drops tools' results, and the oldest turns, stays, for what's after the marker, so a conversation still fits the model's context while its summary is written.
Agents and tools
  • MCP: connectors to MCP servers, whose tools are added to the toolkit, each in its own namespace, so models can call them.
  • Heartbeats which are asked: the prompt of a heartbeat which fires is asked of its session's model, as a message which says it's scheduled, with a history of what ran, and agents which run on a schedule.
  • Events between servers: servers which share stores, such as a database, share their events, so a client of one sees the changes, and fires, of another.
Providers
  • Google Gemini, which the earlier version of go-llm had, for generation, and its embeddings.
  • LM Studio, which runs models locally, as Ollama does, with its own API to list, download, delete, load and unload them, as well as an OpenAI-compatible API.
  • Text to speech and images, such as ElevenLabs' and OpenAI's voices, and image generation.
  • OpenAI's Responses API, so OpenAI's newest models can think while they call tools, and the models which only it has can be used.
  • OpenAI's token limits, which are from memory, and should be checked.
Improvements
  • Attachments by URL: a message's image or document by its URL, rather than its data, which the server doesn't yet read, as it shouldn't fetch any URL it's given.
  • OCR: the images in documents, PDFs with Ollama's models, and glm-ocr's prompt, which isn't tested.
  • Speech:
    • Speakers with go-whisper's diarizing model, which only knows when the speaker changes.
    • ElevenLabs' realtime transcription, over a WebSocket.
    • Translation with models which hear audio in a conversation, such as Voxtral Small.
    • Subtitles whose lengths can be set.

License

go-llm is licensed under the Apache License, Version 2.0.

Documentation

Index

Constants

View Source
const (
	// Sampling
	TemperatureKey      = "temperature"       // float64, randomness of sampling
	TopPKey             = "top_p"             // float64, nucleus sampling probability mass
	TopKKey             = "top_k"             // uint, sample from the K most likely tokens
	MaxTokensKey        = "max_tokens"        // uint, maximum tokens to generate
	StopSequencesKey    = "stop_sequences"    // []string, sequences which stop generation
	SeedKey             = "seed"              // uint, seed for deterministic generation
	PresencePenaltyKey  = "presence_penalty"  // float64, penalty for tokens already present
	FrequencyPenaltyKey = "frequency_penalty" // float64, penalty by frequency of tokens

	// Prompt
	SystemPromptKey = "system_prompt" // string, system prompt for the model

	// Thinking
	ThinkingKey       = "thinking"        // bool, enable or disable thinking
	ThinkingEffortKey = "thinking_effort" // string, reasoning effort: "low", "medium" or "high"

	// Output
	JSONSchemaKey = "json_schema" // json.RawMessage, JSON schema the output conforms to

	// Tools
	ToolChoiceKey = "tool_choice" // string, whether the model uses the tools: "auto", "any" or "none"

	// Agents
	MaxIterationsKey = "max_iterations" // uint, most times an agent loop asks the model for its reply
	MaxDepthKey      = "max_depth"      // uint, most agents which run in one another, as an agent calls an agent, as a tool
	ToolTimeoutKey   = "tool_timeout"   // time.Duration, or a string such as "30s", most time a tool an agent loop runs has to return

	// Model loading
	ContextWindowKey = "context_window" // uint, context window size in tokens
	KeepAliveKey     = "keep_alive"     // time.Duration, how long a model stays loaded, or negative to stay loaded

	// Requests
	UserKey        = "user"         // string, identifier of the end user, for abuse monitoring
	ServiceTierKey = "service_tier" // string, provider service tier, for example "auto"

	// Embeddings
	TaskTypeKey   = "task_type"  // string, task the embedding is used for
	TitleKey      = "title"      // string, title of the document being embedded
	DimensionsKey = "dimensions" // uint, number of dimensions of the embedding

	// Recognition
	PagesKey       = "pages"        // []uint, uint, or a string such as "0,2-4", pages of a document to recognize, from zero
	TableFormatKey = "table_format" // string, format of the tables in the text: "markdown" or "html"
	RegionsKey     = "regions"      // bool, whether a page has its regions, with their boxes

	// Transcription
	LanguageKey = "language" // string, ISO 639-1 code of the language the speech is in, such as "en"
	SegmentsKey = "segments" // bool, whether a transcript has its segments, with when each was spoken
	SpeakersKey = "speakers" // bool, whether a transcript's segments have who spoke them
)

Keys for options shared by providers. Each key notes the type of its value. Providers ignore or reject the options they don't support, and validate ranges, which differ between providers.

View Source
const (
	Ollama     = "ollama"
	Eliza      = "eliza"
	OpenAI     = "openai"
	GoWhisper  = "gowhisper"
	ElevenLabs = "elevenlabs"
	Anthropic  = "anthropic"
)

Variables

This section is empty.

Functions

func GetOpt added in v0.5.0

func GetOpt[T any](o *Opts, key string) (T, error)

GetOpt returns the value of the option with the key, or an error if it isn't set or isn't of the type. A value which is JSON, such as an option stored with a session, is decoded as the type, and can't be null.

func GetPages added in v0.5.0

func GetPages(o *Opts) ([]uint, error)

GetPages returns the pages of a document to recognize, in order, without duplicates, from the option, which is the page numbers, a page number, or a string of them and ranges, such as "0,2-4", from zero. Returns an error if it isn't set, or isn't pages.

func HTTPErr added in v0.5.0

func HTTPErr(err error) error

HTTPErr translates an error into an error wrapping a HTTP status code, which httpresponse.Error uses for the response. The message is prefixed with the status text, and errors.Is and errors.As still match the original error. An llm.Err's own text, such as "not found", isn't in the message, when it starts it, and the status says the same, such as "Not Found", so the message is "Not Found: model ...", rather than "Not Found: not found: model ...".

An llm.Err is translated with its HTTP method, even when it wraps a HTTP status code, such as a provider's response, and fs errors (fs.ErrNotExist and so on) to the corresponding status code. Other errors which already wrap a HTTP status code are returned unchanged, a server's response is its status, and any other error is an internal server error. Returns nil when err is nil.

func HTTPStatus added in v0.5.0

func HTTPStatus(err error) (int, bool)

HTTPStatus returns the HTTP status code of an error, which wraps one, as httpresponse.Err, or is a server's response, as httpresponse.ErrResponse, which a client returns for an error whose body is JSON, such as go-whisper's. Returns false when it hasn't one.

func IsToolName added in v0.5.0

func IsToolName(name string) bool

IsToolName returns true if the name is a valid tool name, which is 1 to 64 letters, digits, underscores or hyphens

func ReadAll added in v0.5.0

func ReadAll(ctx context.Context, r Resource) ([]byte, error)

ReadAll reads all of a resource's content, for providers which send it whole, such as encoded in a request

Types

type Document added in v0.5.0

type Document struct {
	Pages []DocumentPage `json:"pages" help:"The pages, in order"`
}

Document is the text recognized in an image or document, by page, in order. An image is one page.

type DocumentPage added in v0.5.0

type DocumentPage struct {
	Text    string           `json:"text" help:"Text of the page, in Markdown" example:"# Hello, World"`
	Regions []DocumentRegion `json:"regions,omitempty" help:"Regions of the page, in reading order, when they're asked for"`
}

DocumentPage is the text of a page, in Markdown, and its regions, in reading order, when they're asked for

type DocumentRegion added in v0.5.0

type DocumentRegion struct {
	Type string     `json:"type,omitempty" help:"What the region is, as the model labels it, such as text, title or table" example:"text"`
	Text string     `json:"text" help:"Text of the region, in Markdown" example:"Hello, World"`
	Box  [4]float64 `` /* 163-byte string literal not displayed */
}

DocumentRegion is a part of a page, such as a paragraph, a title or a table, with its text, and its box. The type is the model's, such as "text" or "table", which differ between models.

type DownloadProgressFn added in v0.5.0

type DownloadProgressFn func(status string, percent float64)

DownloadProgressFn is called with the status of a model download, and how complete it is, as a percentage from 0 to 100

type Downloader added in v0.1.0

type Downloader interface {
	// LoadModel downloads the model with the given name, and otherwise
	// loads the model if it's already present. The progress function, if not
	// nil, is called with the status of the download as it progresses.
	LoadModel(context.Context, string, DownloadProgressFn) (Model, error)

	// DeleteModel deletes the model from local storage
	DeleteModel(context.Context, Model) error

	// UnloadModel unloads the model from memory, keeping it in local
	// storage, so it's loaded again when it's next used
	UnloadModel(context.Context, Model) error
}

Downloader is an interface for managing model files, for providers which store models locally, such as Ollama

type Embedder added in v0.1.0

type Embedder interface {
	// Embed returns a vector for each of the messages, in the same order, and
	// the tokens used, which are input tokens. A message is embedded by its
	// text. The options can set what the vectors are for (WithTaskType), the
	// title of the document the messages are from (WithTitle), and the
	// number of dimensions of the vectors (WithDimensions), which the model
	// must support. Options which the provider doesn't support are ignored
	// or rejected.
	Embed(context.Context, Model, []Message, ...Opt) ([]Vector, Usage, error)
}

Embedder is an interface for providers which embed messages as vectors, such as for semantic search

type Err

type Err int

Errors

const (
	ErrSuccess Err = iota
	ErrNotFound
	ErrBadParameter
	ErrNotImplemented
	ErrConflict
	ErrInternalServerError
	ErrServiceUnavailable
	ErrForbidden
	ErrMaxTokens // the model's reply was truncated, as it reached the most tokens
	ErrRefusal   // the model refused to reply
	ErrPauseTurn // the model paused its turn, which is to be continued
)

func (Err) Error

func (e Err) Error() string

func (Err) HTTP added in v0.5.0

func (e Err) HTTP() httpresponse.Err

func (Err) With

func (e Err) With(args ...any) error

func (Err) Withf

func (e Err) Withf(format string, args ...any) error

Withf returns an error wrapping the error code, with a formatted message. As with fmt.Errorf, the format may use %w to wrap errors, so that they can still be matched with errors.Is and errors.As.

type Generator added in v0.1.0

type Generator interface {
	// WithoutSession returns the model's reply to the messages, and the
	// tokens used. Without a session, the messages include any system prompt
	// and earlier turns of the conversation. The model can call the tools,
	// which may be nil, by their names, and the reply has the calls rather
	// than their results. The stream function, if not nil, is called with
	// the pieces of the reply's thinking and text as they're generated.
	// Options which the provider doesn't support are ignored or rejected.
	WithoutSession(context.Context, Model, []Message, []Tool, GeneratorStreamFn, ...Opt) (Message, Usage, error)
}

Generator is an interface for providers which generate messages, such as chat completions

type GeneratorStreamFn added in v0.5.0

type GeneratorStreamFn func(StreamType, string)

GeneratorStreamFn is called with each piece of a message as it's generated, with what the piece is, such as the reply's text or the model's thinking

type Measurer added in v0.6.0

type Measurer interface {
	// Measure returns how many tokens the text is, for the model
	Measure(context.Context, Model, string) (uint, error)
}

Measurer is an interface for providers which count the tokens of text, as a model would, such as to fit what's sent to it into its context

type Message added in v0.5.0

type Message interface {
	Role() string              // Message role: user, assistant, system, thinking or tool
	Text() string              // Text content of the message
	Resources() []Resource     // Resources in the message, such as images or documents
	ToolCalls() []ToolCall     // Tools the model called, in a message from the model
	ToolResults() []ToolResult // Results of the tools the model called, in a tool message
}

Message is a message in a conversation with a model, which providers convert to their own formats

type Model

type Model interface {
	Name() string
	Provider() Provider // Model provider
	Description() string
	Created() time.Time
	Aliases() []string                // Model aliases
	Meta() map[string]json.RawMessage // Provider-specific metadata
	InputTokenLimit() *uint           // Input token limit (optional)
	OutputTokenLimit() *uint          // Output token limit (optional)
	Capabilities() ModelCap           // What the model can do, of what's known
}

Represents an LLM model

type ModelCap added in v0.5.0

type ModelCap struct {
	Completion    *bool `json:"completion,omitempty" help:"Generates replies to messages"`
	Tools         *bool `json:"tools,omitempty" help:"Calls tools"`
	Thinking      *bool `json:"thinking,omitempty" help:"Thinks, or reasons, before it replies"`
	Vision        *bool `json:"vision,omitempty" help:"Understands images"`
	OCR           *bool `json:"ocr,omitempty" help:"Recognizes the text in images and documents"`
	Transcription *bool `json:"transcription,omitempty" help:"Transcribes speech"`
	Translation   *bool `json:"translation,omitempty" help:"Translates speech into English"`
	Embedding     *bool `json:"embedding,omitempty" help:"Embeds text as vectors"`

	// Temperature is whether the model takes the sampling options, which are
	// the temperature, top_p and top_k, which the registry leaves out, for a
	// model which doesn't, rather than fail, as a session keeps its options
	// as its model changes. It's a setting, rather than what the model does,
	// so it isn't in String.
	Temperature *bool `json:"temperature,omitempty" help:"Takes a sampling temperature, and the other sampling options"`
}

ModelCap is what a model can do, of what its provider knows. A capability which isn't known is nil.

func (ModelCap) String added in v0.5.0

func (c ModelCap) String() string

String returns the names of the capabilities which the model is known to have, such as "completion, tools, thinking"

type Opt

type Opt func(*Opts) error

Opt is an option for an operation of a provider, such as generating a message. Options are set by key, so providers can define their own.

func WithContextWindow added in v0.5.0

func WithContextWindow(value uint) Opt

WithContextWindow sets the context window size in tokens, which is one or more

func WithDimensions added in v0.5.0

func WithDimensions(value uint) Opt

WithDimensions sets the number of dimensions of the embedding, which is one or more

func WithFrequencyPenalty added in v0.0.3

func WithFrequencyPenalty(value float64) Opt

WithFrequencyPenalty sets the penalty by frequency of tokens

func WithJSONSchema added in v0.5.0

func WithJSONSchema(value json.RawMessage) Opt

WithJSONSchema sets the JSON schema the output conforms to

func WithKeepAlive added in v0.5.0

func WithKeepAlive(value time.Duration) Opt

WithKeepAlive sets how long a model stays loaded after the request, or negative to stay loaded

func WithLanguage added in v0.5.0

func WithLanguage(value string) Opt

WithLanguage sets the language the speech in audio is in, as an ISO 639-1 code, such as "en", rather than it being detected

func WithMaxDepth added in v0.6.0

func WithMaxDepth(value uint) Opt

WithMaxDepth sets the most agents which run in one another, as an agent calls an agent, or itself, as a tool, which is one or more

func WithMaxIterations added in v0.6.0

func WithMaxIterations(value uint) Opt

WithMaxIterations sets the most times an agent loop asks the model for its reply, which is one or more

func WithMaxTokens added in v0.0.3

func WithMaxTokens(value uint) Opt

WithMaxTokens sets the maximum tokens to generate, which is one or more

func WithOpt added in v0.5.0

func WithOpt(key string, value any) Opt

WithOpt sets the option with the key to the value, replacing any value already set

func WithPages added in v0.5.0

func WithPages(values ...uint) Opt

WithPages sets the pages of a document to recognize, numbered from zero

func WithPresencePenalty added in v0.0.3

func WithPresencePenalty(value float64) Opt

WithPresencePenalty sets the penalty for tokens already present

func WithRegions added in v0.5.0

func WithRegions(value bool) Opt

WithRegions sets whether the pages of recognized text have their regions, such as paragraphs, titles and tables, with their boxes

func WithSeed added in v0.0.3

func WithSeed(value uint) Opt

WithSeed sets the seed for deterministic generation

func WithSegments added in v0.5.0

func WithSegments(value bool) Opt

WithSegments sets whether a transcript has its segments, with when each was spoken

func WithServiceTier added in v0.5.0

func WithServiceTier(value string) Opt

WithServiceTier sets the provider service tier, for example "auto"

func WithSpeakers added in v0.5.0

func WithSpeakers(value bool) Opt

WithSpeakers sets whether a transcript's segments have who spoke them, which is diarization

func WithStopSequences added in v0.5.0

func WithStopSequences(values ...string) Opt

WithStopSequences sets the sequences which stop generation, replacing any already set

func WithSystemPrompt

func WithSystemPrompt(value string) Opt

WithSystemPrompt sets the system prompt for the model

func WithTableFormat added in v0.5.0

func WithTableFormat(value string) Opt

WithTableFormat sets the format of the tables in recognized text: "markdown" or "html"

func WithTaskType added in v0.5.0

func WithTaskType(value string) Opt

WithTaskType sets the task the embedding is used for

func WithTemperature

func WithTemperature(value float64) Opt

WithTemperature sets the randomness of sampling, which is zero or more

func WithThinking added in v0.5.0

func WithThinking(value bool) Opt

WithThinking enables or disables thinking

func WithThinkingEffort added in v0.5.0

func WithThinkingEffort(value string) Opt

WithThinkingEffort sets the reasoning effort: "low", "medium" or "high"

func WithTitle added in v0.5.0

func WithTitle(value string) Opt

WithTitle sets the title of the document being embedded

func WithToolChoice added in v0.0.3

func WithToolChoice(value string) Opt

WithToolChoice sets whether the model uses the tools: "auto" to decide, "any" to use one of them, or "none" to use none of them. To use a particular tool, pass only that tool with "any".

func WithToolTimeout added in v0.6.0

func WithToolTimeout(value time.Duration) Opt

WithToolTimeout sets the most time a tool an agent loop runs has to return, which is more than zero

func WithTopK

func WithTopK(value uint) Opt

WithTopK sets sampling from the K most likely tokens, which is one or more

func WithTopP

func WithTopP(value float64) Opt

WithTopP sets the probability mass for nucleus sampling, between zero and one

func WithUser added in v0.0.6

func WithUser(value string) Opt

WithUser sets the identifier of the end user, for abuse monitoring

type Opts

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

Opts are the options for an operation, by key

func ApplyOpts

func ApplyOpts(opts ...Opt) (*Opts, error)

ApplyOpts returns the options set by each option in turn, or the first error. Nil options are skipped.

func (*Opts) Delete added in v0.5.0

func (o *Opts) Delete(key string)

Delete removes the option with the key, if it's set

func (*Opts) Get

func (o *Opts) Get(key string) any

Get returns the value of the option with the key, or nil if it isn't set

func (*Opts) Has

func (o *Opts) Has(key string) bool

Has returns true if the option with the key is set

func (*Opts) Keys added in v0.5.0

func (o *Opts) Keys() []string

Keys returns the keys of the options which are set, in sorted order

func (*Opts) Opt added in v0.5.0

func (o *Opts) Opt() Opt

Opt returns an option which sets the values of these options, so options can be applied once, and then passed on without being applied again

type Progress added in v0.6.0

type Progress struct {
	Progress float64 `json:"progress"`
	Total    float64 `json:"total,omitempty"`
	Message  string  `json:"message,omitempty"`
}

Progress is how a tool is getting on, as it runs, as MCP's progress notification is: how far it's got, which increases each time, out of the total, when it's known, or zero, and a message, such as "Agent segment is replying"

func ParseProgress added in v0.6.0

func ParseProgress(text string) Progress

ParseProgress returns the progress which the text of a piece of a stream is, which is a Progress, as JSON, or a message, when it isn't

func (Progress) Percent added in v0.6.0

func (p Progress) Percent() (float64, bool)

Percent returns how far the progress has got, as a percentage, and whether it's known, which it is when there's a total

func (Progress) Text added in v0.6.0

func (p Progress) Text() string

Text returns the progress, as JSON, which is the text of a piece of a stream which is progress

type Provider added in v0.5.0

type Provider interface {
	// Return the provider name
	Name() string

	// URL returns the provider's normalized endpoint, or nil if it has none
	URL() *url.URL

	// Self returns the underlying provider implementation for capability checks.
	Self() Provider

	// Ping checks the connectivity of the provider and returns an error if not successful
	Ping(context.Context) error

	// ListModels returns the list of available models
	ListModels(context.Context) ([]Model, error)

	// GetModel returns the model with the given name
	GetModel(context.Context, string) (Model, error)
}

Provider is the interface that interfaces with LLM providers (Anthropic, etc)

type ReadFunc added in v0.5.0

type ReadFunc func(context.Context, func(io.Reader) error) error

ReadFunc reads a resource's content: it opens the content, calls the function with a reader of it, and closes it when the function returns. The reader returns an error once the context is cancelled. Returns the function's error, or the error opening or closing the content.

func ReadBytes added in v0.5.0

func ReadBytes(data []byte) ReadFunc

ReadBytes returns a function which reads the data, for resources whose content is in memory

type Recognizer added in v0.5.0

type Recognizer interface {
	// Recognize returns the text in the resource, such as an image or a PDF,
	// as a document, with the text of each page, in Markdown, and its
	// regions, when they're asked for, and the pages and tokens used. The
	// resource's type must be one the provider supports, such as image/png
	// or application/pdf. Options which the provider doesn't support are
	// rejected.
	Recognize(context.Context, Model, Resource, ...Opt) (Document, Usage, error)
}

Recognizer is an interface for providers which recognize the text in images and documents, which is optical character recognition (OCR)

type Resource added in v0.4.2

type Resource interface {
	// URI returns the unique identifier of the resource. It must be an
	// absolute URI with a non-empty scheme (e.g. "file:///path/to/file").
	URI() string

	// Name returns a human-readable name for the resource.
	Name() string

	// Description returns an optional description of the resource.
	Description() string

	// Type returns the MIME type of the resource content, for example
	// image/png or application/pdf, or an empty string if unknown.
	Type() string

	// Read returns a function which reads the resource's content, or an
	// error when it can't be read, such as when it isn't found
	Read(context.Context) (ReadFunc, error)
}

Resource is media, such as an image, document or audio, or a readable resource which a server advertises, which is opaque until it's read

type StreamType added in v0.5.0

type StreamType string

StreamType is what a piece of a message is, as it's generated

const (
	// StreamText is a piece of the text of the reply
	StreamText StreamType = "text"

	// StreamThinking is a piece of the model's thinking, before or while it
	// replies
	StreamThinking StreamType = "thinking"

	// StreamLog is a line logged by a tool as it runs, such as to say what
	// it's doing, which isn't part of the reply
	StreamLog StreamType = "log"

	// StreamProgress is a tool's progress as it runs, such as that an agent
	// it runs is replying, which replaces its progress before, rather than
	// being kept, as a line it logs is, and isn't part of the reply. Its
	// text is a Progress, as JSON, which ParseProgress reads.
	StreamProgress StreamType = "progress"
)

type Tool

type Tool interface {
	// Return the name of the tool
	Name() string

	// Return the description of the tool
	Description() string

	// Return the JSON schema for the tool input parameters.
	InputSchema() *jsonschema.Schema

	// Return the JSON schema for the tool output, or nil if unspecified.
	OutputSchema() *jsonschema.Schema

	// Run the tool with the given input as JSON (may be nil). The result is
	// JSON as a json.RawMessage, a Resource such as an image or audio, any
	// other value which can be encoded as JSON, or nil when the tool has no
	// result.
	Run(ctx context.Context, input json.RawMessage) (any, error)
}

Tool is an interface for a callable tool with a name, description, input schema, and optional output schema.

type ToolCall

type ToolCall struct {
	ID    string          // Identifier of the call, which its result refers to
	Name  string          // Name of the tool the model called it by
	Input json.RawMessage // Input to the tool as JSON, which may be empty
}

ToolCall is a call by a model to a tool

type ToolResult

type ToolResult struct {
	ID      string          // Identifier of the call
	Name    string          // Name of the tool the model called it by
	Content json.RawMessage // Result of the tool as JSON
	IsError bool            // Whether the result is an error
}

ToolResult is the result of a call by a model to a tool

type Transcriber added in v0.5.0

type Transcriber interface {
	// Transcribe returns the speech in the audio as text, in the language
	// it was spoken in, with its segments and when each was spoken, when
	// they're asked for, so a part of a recording can be found, and the
	// seconds and tokens used. The audio is a resource whose type is audio,
	// such as audio/mpeg, which the provider must support. The stream
	// function, if not nil, is called with the pieces of the transcript as
	// they're transcribed, or once it's transcribed, by a model which
	// doesn't stream. Options which the provider doesn't support are
	// rejected.
	Transcribe(context.Context, Model, Resource, TranscriberStreamFn, ...Opt) (Transcript, Usage, error)

	// Translate returns the speech in the audio, in any language, as English
	// text, with its segments, as Transcribe does, whose language is "en",
	// and the seconds and tokens used
	Translate(context.Context, Model, Resource, TranscriberStreamFn, ...Opt) (Transcript, Usage, error)
}

Transcriber is an interface for providers which transcribe speech in audio, and translate it into English. A model which can't do one of them, such as one which only transcribes, returns ErrNotImplemented for it.

type TranscriberStreamFn added in v0.5.0

type TranscriberStreamFn func(text string, segment *TranscriptSegment)

TranscriberStreamFn is called with each piece of a transcript as it's transcribed: a piece of its text, or, when segments are asked for, a segment, once it's transcribed, with empty text. The pieces of text are the transcript's text, even for a model which only streams segments.

type Transcript added in v0.5.0

type Transcript struct {
	Text     string              `json:"text" help:"Text of the speech" example:"Hello, world."`
	Language string              `json:"language,omitempty" help:"Language the speech was spoken in, as an ISO 639-1 code, when it's known" example:"en"`
	Segments []TranscriptSegment `json:"segments,omitempty" help:"Segments of the speech, in order, when they're asked for"`
}

Transcript is the speech in audio: its text, the language it was spoken in, such as "en", when it's known, and its segments, in order, when they're asked for

type TranscriptSegment added in v0.5.0

type TranscriptSegment struct {
	Start   time.Duration `json:"start" help:"When the segment starts in the audio, in nanoseconds" example:"1600000000"`
	End     time.Duration `json:"end" help:"When the segment ends in the audio, in nanoseconds" example:"3500000000"`
	Text    string        `json:"text" help:"Text of the segment" example:"This is a test."`
	Speaker string        `json:"speaker,omitempty" help:"Who spoke the segment, as the provider labels them, when speakers are asked for" example:"A"`
}

TranscriptSegment is a part of a transcript, such as a sentence, with when it starts and ends in the audio, and who spoke it, when the provider distinguishes speakers

type Usage added in v0.5.0

type Usage struct {
	InputTokens     uint `json:"input_tokens" help:"Tokens in the messages sent to the model" example:"26"`
	OutputTokens    uint `json:"output_tokens,omitempty" help:"Tokens in the message generated by the model" example:"12"`
	CachedTokens    uint `json:"cached_tokens,omitempty" help:"Of the input tokens, those read from the provider's cache" example:"0"`
	ReasoningTokens uint `json:"reasoning_tokens,omitempty" help:"Of the output tokens, those of reasoning which isn't returned" example:"0"`
	Pages           uint `json:"pages,omitempty" help:"Pages of documents and images whose text was recognized" example:"0"`
	Seconds         uint `` /* 129-byte string literal not displayed */

	// Duration is how long it took, which is the time from when it started
	// to when it ended, rather than the sum of what ran at once
	Duration time.Duration `json:"duration,omitempty" help:"How long it took, in nanoseconds" example:"1500000000"`
}

Usage is the number of tokens used generating a message, or the pages recognized, or seconds of audio transcribed, for providers which charge by them. The cached and reasoning tokens are part of the input and output tokens, for providers which report them.

func (Usage) Add added in v0.6.0

func (u Usage) Add(other Usage) Usage

Add returns the tokens, pages, seconds and durations of both usages, as when one follows the other

func (Usage) IsZero added in v0.6.0

func (u Usage) IsZero() bool

IsZero returns true when the usage has no tokens, pages or seconds

type Vector added in v0.5.0

type Vector []float32

Vector is an embedding of a message, whose number of dimensions is the model's, or as set by WithDimensions

Directories

Path Synopsis
Package agents has example agents, as YAML, which the llm server creates when it starts, or which llm agent-create creates, such as:
Package agents has example agents, as YAML, which the llm server creates when it starts, or which llm agent-create creates, such as:
Package broadcaster publishes events, which are changes, such as to a registry's providers, or its sessions, to the channels which watch it, so a server's clients see the changes as they happen
Package broadcaster publishes events, which are changes, such as to a registry's providers, or its sessions, to the channels which watch it, so a server's clients see the changes as they happen
cmd
Package cmd has the broadcaster's commands and flags
Package cmd has the broadcaster's commands and flags
httpclient
Package httpclient is a client of the broadcaster's HTTP API
Package httpclient is a client of the broadcaster's HTTP API
httphandler
Package httphandler has the broadcaster's HTTP API, which streams its events to clients
Package httphandler has the broadcaster's HTTP API, which streams its events to clients
cmd
llm command
examples
agent command
Run an agent, which is the example agent which translates text, with a registry, and a store of agents, without a server:
Run an agent, which is the example agent which translates text, with a registry, and a store of agents, without a server:
ask command
Ask a model a question, and stream its reply, with a registry of providers, without a server:
Ask a model a question, and stream its reply, with a registry of providers, without a server:
chat command
Chat with a model in the terminal, keeping the conversation in memory, without a server, or a store of sessions:
Chat with a model in the terminal, keeping the conversation in memory, without a server, or a store of sessions:
ocr command
Read the text in an image, or a document, such as a PDF, as Markdown, which is optical character recognition (OCR), with a registry of providers, without a server:
Read the text in an image, or a document, such as a PDF, as Markdown, which is optical character recognition (OCR), with a registry of providers, without a server:
tools command
A tool of your own, which a model calls, with a toolkit, and a registry which runs the tools a model calls, until it replies, without a server:
A tool of your own, which a model calls, with a toolkit, and a registry which runs the tools a model calls, until it replies, without a server:
transcribe command
Transcribe the speech in audio, as text, streamed as it's transcribed, or translate it into English, with a registry of providers, without a server:
Transcribe the speech in audio, as text, streamed as it's transcribed, or translate it into English, with a registry of providers, without a server:
frontend
cmd
Package cmd serves the web UI, and its configuration, alongside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into build/frontend, which make does.
Package cmd serves the web UI, and its configuration, alongside the API, when the server is built with the "frontend" tag, which embeds the UI, once it's built, with npm, into build/frontend, which make does.
Package heartbeat has prompts for sessions, which fire once, at a time, or again and again, on a schedule, such as a briefing every morning, or a reminder.
Package heartbeat has prompts for sessions, which fire once, at a time, or again and again, on a schedule, such as a briefing every morning, or a reminder.
cmd
Package cmd has the heartbeats' commands and flags
Package cmd has the heartbeats' commands and flags
httpclient
Package httpclient is a client of the heartbeats' HTTP API
Package httpclient is a client of the heartbeats' HTTP API
httphandler
Package httphandler has the heartbeats' HTTP API, which lists, creates, gets, changes and deletes them
Package httphandler has the heartbeats' HTTP API, which lists, creates, gets, changes and deletes them
schema
Package schema has the heartbeats' schedules, and what they are: a prompt for a session, at a time, or on a schedule
Package schema has the heartbeats' schedules, and what they are: a prompt for a session, at a time, or on a schedule
internal
deadline
Package deadline has a writer of a stream to a client, such as of server-sent events, which gives each write its own deadline, rather than the server's write timeout, which is for the whole response
Package deadline has a writer of a stream to a client, such as of server-sent events, which gives each write its own deadline, rather than the server's write timeout, which is for the whole response
reminder
Package reminder has the block of what the system says to a model, in a message, which it reads as information, rather than what the person said, and which is taken out of what the system doesn't say, so it can't be faked, such as by the person, or what a model, or a tool, wrote
Package reminder has the block of what the system says to a model, in a message, which it reads as information, rather than what the person said, and which is taken out of what the system doesn't say, so it can't be faked, such as by the person, or what a model, or a tool, wrote
subtitle
Package subtitle writes the segments of a transcript as subtitles, in SRT or WebVTT format, whose cues are the segments, in turn, until one is spoken by another speaker, or after a silence, or would make the cue too long, or have too much text, to read
Package subtitle writes the segments of a transcript as subtitles, in SRT or WebVTT format, whose cues are the segments, in turn, until one is spoken by another speaker, or after a silence, or would make the cue too long, or have too much text, to read
taggroup
Package taggroup adds tags to the groups of an OpenAPI specification, which Redoc shows tags in, so modules which register their handlers on their own, in any order, can share a group
Package taggroup adds tags to the groups of an OpenAPI specification, which Redoc shows tags in, so modules which register their handlers on their own, in any order, can share a group
Package memory is what the assistant remembers, which is shared by every session and agent: the details of the person it's talking to, and of itself, such as their names, where the person is, and their time zone and language, which are in the system prompt, each of which is known, not known, or declined, so it isn't.
Package memory is what the assistant remembers, which is shared by every session and agent: the details of the person it's talking to, and of itself, such as their names, where the person is, and their time zone and language, which are in the system prompt, each of which is known, not known, or declined, so it isn't.
cmd
Package cmd has the memory's commands and flags
Package cmd has the memory's commands and flags
httpclient
Package httpclient is a client of the memory's HTTP API
Package httpclient is a client of the memory's HTTP API
httphandler
Package httphandler has the memory's HTTP API, which gets, sets and forgets the details it keeps, and lists, gets, remembers and forgets its memories
Package httphandler has the memory's HTTP API, which gets, sets and forgets the details it keeps, and lists, gets, remembers and forgets its memories
provider
anthropic
anthropic implements an API client for Anthropic's Claude API, which generates replies with the Messages API, and counts tokens.
anthropic implements an API client for Anthropic's Claude API, which generates replies with the Messages API, and counts tokens.
elevenlabs
elevenlabs implements an API client for ElevenLabs, whose Scribe models transcribe speech.
elevenlabs implements an API client for ElevenLabs, whose Scribe models transcribe speech.
eliza
eliza implements a mock LLM provider based on the classic ELIZA chatbot, created by Joseph Weizenbaum at MIT in 1966, which simulates a psychotherapist using pattern matching and transformation rules.
eliza implements a mock LLM provider based on the classic ELIZA chatbot, created by Joseph Weizenbaum at MIT in 1966, which simulates a psychotherapist using pattern matching and transformation rules.
gowhisper
gowhisper implements an API client for go-whisper, which transcribes, and translates, speech with whisper.cpp models, which it downloads and stores.
gowhisper implements an API client for go-whisper, which transcribes, and translates, speech with whisper.cpp models, which it downloads and stores.
ollama
ollama implements an API client for the Ollama provider.
ollama implements an API client for the Ollama provider.
openai
openai implements an API client for OpenAI, and for other providers with an OpenAI-compatible API, such as vLLM, llama.cpp and LM Studio.
openai implements an API client for OpenAI, and for other providers with an OpenAI-compatible API, such as vLLM, llama.cpp and LM Studio.
schema
Package schema has the messages which providers reply with, which implement llm.Message, so providers share them
Package schema has the messages which providers reply with, which implement llm.Message, so providers share them
Package registry has the providers of models, by names which the registry gives them, and finds the models across them
Package registry has the providers of models, by names which the registry gives them, and finds the models across them
cmd
Package cmd has the registry's commands and flags
Package cmd has the registry's commands and flags
cmd/tui
Package tui is a terminal interface to chat in a session, which is a throwaway, until there's a better one
Package tui is a terminal interface to chat in a session, which is a throwaway, until there's a better one
httpclient
Package httpclient is a client of the registry's HTTP API
Package httpclient is a client of the registry's HTTP API
httphandler
Package httphandler has the registry's HTTP API
Package httphandler has the registry's HTTP API
schema
Package schema has the requests and responses of the registry's API
Package schema has the requests and responses of the registry's API
test
Package test has a registry and a HTTP server of its API, for tests
Package test has a registry and a HTTP server of its API, for tests
cmd
homeassistant/httpclient
httpclient implements an API client for the Home Assistant REST API https://developers.home-assistant.io/docs/api/rest/
httpclient implements an API client for the Home Assistant REST API https://developers.home-assistant.io/docs/api/rest/
newsapi/httpclient
httpclient implements an API client for NewsAPI https://newsapi.org/docs
httpclient implements an API client for NewsAPI https://newsapi.org/docs
ollama/httpclient
httpclient implements an API client for Ollama's web search and web fetch https://docs.ollama.com/capabilities/web-search
httpclient implements an API client for Ollama's web search and web fetch https://docs.ollama.com/capabilities/web-search
weatherapi/httpclient
httpclient implements an API client for WeatherAPI https://www.weatherapi.com/docs/
httpclient implements an API client for WeatherAPI https://www.weatherapi.com/docs/

Jump to

Keyboard shortcuts

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