schema

package
v1.2.0 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: 21 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 schema has the requests and responses of the registry's API

Index

Constants

View Source
const (
	EventText     = string(llm.StreamText)
	EventThinking = string(llm.StreamThinking)
	EventLog      = string(llm.StreamLog)
)

The events of a stream of a model's reply: a text or thinking event for each piece of the reply as it's generated, a log event for each line a tool logs as it runs, a progress event, as a model's download is, of how a tool is getting on, and then a result event, with the response, or an error event

View Source
const (
	EventProgress = string(llm.StreamProgress)
	EventResult   = "result"
	EventError    = "error"
)

The events of a stream of a model which is loaded: its progress, and then the model, or the error. A tool's progress, as a model replies, is a progress event too.

View Source
const AskBodyLimit = 32 << 20

AskBodyLimit is the largest request body, in bytes, when a model is asked, which allows for images in the messages

View Source
const EmbedBodyLimit = 32 << 20

EmbedBodyLimit is the largest request body, in bytes, when messages are embedded, which allows for images and audio in the messages

View Source
const EventSegment = "segment"

EventSegment is the event of a stream of a transcript with a segment, once it's transcribed, when segments are asked for, as its text events have each piece of its text

View Source
const RecognizeBodyLimit = 64 << 20

RecognizeBodyLimit is the largest request body, in bytes, when text is recognized, which allows for a document of 48 MiB encoded as base64

View Source
const TranscribeBodyLimit = 48 << 20

TranscribeBodyLimit is the largest request body, in bytes, when speech is transcribed, which allows for audio of 32 MiB encoded as base64

Variables

This section is empty.

Functions

func Lateness added in v1.2.0

func Lateness(scheduled, fired time.Time) string

Lateness returns how late the time it fired is, after it was due, in words, such as on time, or 3h12m late, to the minute

func ProviderTypes

func ProviderTypes() []string

ProviderTypes returns the types of providers which the registry creates, in order

func RedactURL

func RedactURL(u *url.URL) string

RedactURL returns the URL without its password, or an empty string when it's nil

func SortEvents added in v1.2.0

func SortEvents(events []Event)

SortEvents sorts the events, the most recently created first, and then by their identifiers, as a store lists them

Types

type Agent added in v0.6.0

type Agent struct {
	Serial   uint64    `json:"serial,omitempty" readonly:"" help:"Serial of the agent, which its store changes each time it's stored" example:"3"`
	Created  time.Time `json:"created,omitzero" readonly:"" help:"When the agent was created"`
	Modified time.Time `json:"modified,omitzero" readonly:"" help:"When the agent was last stored"`
	AgentMeta
}

Agent is an agent as it's stored: its definition, and its serial, which its store sets, and changes each time it's stored, so a change is made to the agent as it was last seen

func (Agent) Cell added in v0.6.0

func (a Agent) Cell(col int) tui.CellText

Cell returns the agent's name, title, model, tools, and when it was last updated, which is when it was created, or modified, whichever is later

func (Agent) Header added in v0.6.0

func (a Agent) Header() []string

func (Agent) String added in v0.6.0

func (a Agent) String() string

func (Agent) Width added in v0.6.0

func (a Agent) Width(col int) int

type AgentList added in v0.6.0

type AgentList struct {
	AgentListRequest
	Count uint    `json:"count" help:"How many agents there are"`
	Body  []Agent `json:"body,omitzero" help:"Agents, in the store's order"`
}

AgentList is the agents a request selects, and how many there are

func (AgentList) String added in v0.6.0

func (r AgentList) String() string

type AgentListRequest added in v0.6.0

type AgentListRequest struct {
	Offset uint  `json:"offset,omitempty" help:"Skips this many agents" example:"0" optional:""`
	Limit  *uint `json:"limit,omitempty" help:"Returns at most this many agents" example:"10" optional:""`
}

AgentListRequest selects agents: from an offset, and at most a limit of them

func (AgentListRequest) Query added in v0.6.0

func (r AgentListRequest) Query() url.Values

Query returns the request as the parameters of a URL's query

func (AgentListRequest) String added in v0.6.0

func (r AgentListRequest) String() string

type AgentMeta added in v0.6.0

type AgentMeta struct {
	PromptMeta
	GeneratorMeta
}

AgentMeta is an agent's definition: its prompt, and how a model is asked it, which is its model, system prompt, tools, options, and the schema of its reply

func ParseAgentMeta added in v0.6.0

func ParseAgentMeta(data []byte) (AgentMeta, error)

ParseAgentMeta returns the definition in the data, which is YAML, such as go-nanoradio's agent/segment.yaml, or JSON, which is YAML too, by the names its JSON has, so its input, options and schema are JSON. A key which isn't one of its names, such as system_prompt, rather than system, is an error, as is an alias, such as *name. Returns ErrBadParameter when it can't be parsed.

func (AgentMeta) IsZero added in v0.6.0

func (a AgentMeta) IsZero() bool

IsZero returns true when the definition sets nothing, apart from its name, so as an update, it changes nothing

func (AgentMeta) Merge added in v0.6.0

func (a AgentMeta) Merge(update AgentMeta) AgentMeta

Merge returns the definition, changed by the update, as PromptMeta.Merge and GeneratorMeta.Merge do

func (AgentMeta) String added in v0.6.0

func (a AgentMeta) String() string

func (AgentMeta) YAML added in v0.6.0

func (a AgentMeta) YAML() ([]byte, error)

YAML returns the definition as YAML, as a file of an agent's definition is, which ParseAgentMeta parses: by the names its JSON has, in the same order, in block style, with text of more than one line, such as its prompt, as a literal block

type AskRequest

type AskRequest struct {
	GeneratorMeta
	Messages []providerschema.MessageMeta `json:"messages" help:"Messages, including earlier turns of the conversation, and the results of the tools the model called"`
}

AskRequest asks a model for its reply to the messages, which include earlier turns of the conversation, after the system prompt, with the options. The model can call the tools, whose calls are in its reply, for the caller to run, and send their results back. With a schema, the model replies with JSON which conforms to it.

func (AskRequest) String

func (r AskRequest) String() string

type AskResponse

type AskResponse struct {
	Model   string                 `json:"model" help:"Canonical name of the model which replied" example:"ollama:llama3.2:latest"`
	Message providerschema.Message `json:"message" help:"The model's reply, which can have the tools it called"`
	Schema  bool                   `` /* 135-byte string literal not displayed */
	Result  json.RawMessage        `` /* 136-byte string literal not displayed */
	Usage   llm.Usage              `json:"usage" help:"Tokens used, by every request to the model"`
}

AskResponse is the model's reply, with its canonical name, its result, when the request has a schema, and the model replied with JSON which conforms to it, and the tokens used

func (AskResponse) String

func (r AskResponse) String() string

type ChatRequest added in v0.6.0

type ChatRequest struct {
	Messages []providerschema.MessageMeta `json:"messages" help:"Messages to add to the session, such as a question, which the session's model replies to"`
}

ChatRequest is the messages to add to a session, which its model replies to

func (ChatRequest) String added in v0.6.0

func (r ChatRequest) String() string

type ChatResponse added in v0.6.0

type ChatResponse struct {
	ID     uuid.UUID `json:"id" help:"Identifier of the session" example:"3b241101-e2bb-4255-8caf-4136c566a962"`
	Serial uint64    `json:"serial" help:"Serial of the session, as it was stored" example:"4"`
	SessionResponse
}

ChatResponse is what was added to a session, which is stored, with its identifier, and its serial, as it was stored

func (ChatResponse) String added in v0.6.0

func (r ChatResponse) String() string

type EmbedAttachment

type EmbedAttachment struct {
	Type string `json:"type" help:"MIME type of the attachment" example:"image/png"`
	Data []byte `json:"data" help:"Data of the attachment, encoded as base64" example:"iVBORw0KGgo="`
}

EmbedAttachment is an image or audio to embed, by its type and data, as a URL can't be read

type EmbedContent

type EmbedContent struct {
	Text       *string          `json:"text,omitempty" help:"Text to embed" example:"A cat asleep in the sun" optional:""`
	Attachment *EmbedAttachment `json:"attachment,omitempty" help:"Image or audio to embed, for a model which embeds them" optional:""`
}

EmbedContent is a piece of a message to embed: its text, or an attachment

type EmbedForm

type EmbedForm struct {
	Model string     `json:"model" help:"Model for the embedding, by name, or by provider and name" example:"ollama:embeddinggemma-2:latest"`
	Opt   string     `` /* 144-byte string literal not displayed */
	File  types.File `` /* 208-byte string literal not displayed */
}

EmbedForm is the form for embedding one message, such as from a web browser, which is a file, uploaded as text, an image or audio, which is read as an EmbedRequest with one message, as RecognizeForm is. The options are a JSON object, as a form's values are strings.

type EmbedMessage

type EmbedMessage struct {
	Content []EmbedContent `json:"content" help:"Text and attachments of the message to embed" example:"[{\"text\":\"A cat asleep in the sun\"}]"`
}

EmbedMessage is a message to embed, by its text, and its images and audio, inline, as a message has them, without the role, thinking or tools, which aren't embedded

func (EmbedMessage) Message

func (m EmbedMessage) Message() (llm.Message, error)

Message returns the message to embed, as a message from the user, with its text, and its attachments, or an error when it has neither, or an attachment has no type, or no data

type EmbedRequest

type EmbedRequest struct {
	Model    string                     `json:"model" help:"Model for the embeddings, by name, or by provider and name" example:"ollama:embeddinggemma-2:latest"`
	Messages []EmbedMessage             `json:"messages" help:"Messages to embed, each by its text, and its images and audio for a model which embeds them"`
	Opt      map[string]json.RawMessage `json:"opt,omitzero" help:"Options for embeddings, by key, such as dimensions=256" example:"{\"dimensions\":256}" optional:""`
}

EmbedRequest asks a model for a vector for each of the messages, such as for semantic search, with the options. It's one model, as vectors from different models can't be compared.

func (EmbedRequest) Opts

func (r EmbedRequest) Opts() []llm.Opt

Opts returns the options, for the provider to decode

func (EmbedRequest) String

func (r EmbedRequest) String() string

type EmbedResponse

type EmbedResponse struct {
	Model   string       `json:"model" help:"Canonical name of the model which embedded the messages" example:"ollama:embeddinggemma-2:latest"`
	Vectors []llm.Vector `json:"vectors" help:"A vector for each of the messages, in the same order"`
	Usage   llm.Usage    `json:"usage" help:"Tokens used, which are input tokens"`
}

EmbedResponse is a vector for each of the messages, in the same order, with the model which embedded them, and the tokens used

func (EmbedResponse) String

func (r EmbedResponse) String() string

type ErrorEvent

type ErrorEvent struct {
	Error string `json:"error" help:"Why the model couldn't be loaded"`
}

ErrorEvent is the data of an error event, which ends a stream when it fails

type Event added in v1.2.0

type Event struct {
	ID     uuid.UUID `json:"id" readonly:"" help:"Identifier of the event" example:"0f8fad5b-d9cb-469f-a165-70867728950e"`
	Serial uint64    `json:"serial,omitempty" readonly:"" help:"Serial of the event, which its store changes each time it's stored" example:"1"`
	EventMeta
	Created  time.Time `json:"created,omitzero" readonly:"" help:"When the event's outcome was stored"`
	Modified time.Time `json:"modified,omitzero" readonly:"" help:"When the event's outcome was last changed"`
}

Event is the outcome of an event, as it's stored: its identifier, and serial, which its store changes each time it's stored, so a change is made to it as it was last seen, and when it was created, and last changed

func (Event) Cell added in v1.2.0

func (e Event) Cell(col int) tui.CellText

Cell returns the event's identifier, title, importance, status, and when it fired, in local time

func (Event) Header added in v1.2.0

func (Event) Header() []string

func (Event) String added in v1.2.0

func (e Event) String() string

func (Event) Width added in v1.2.0

func (Event) Width(int) int

type EventChange added in v1.2.0

type EventChange struct {
	Session uuid.UUID   `json:"session,omitzero" help:"Identifier of the session the event is for"`
	Serial  uint64      `json:"serial,omitempty" help:"Serial of the event, as it is now"`
	Status  EventStatus `json:"status,omitempty" help:"Status of the event, as it is now"`
}

EventChange is the data of the registry's event of an event's outcome, which was created, or changed: the session it's for, its serial, and its status

type EventImportance added in v1.2.0

type EventImportance string

EventImportance is how important an event's message is: whether it's ignored, the person is notified, or alerted

const (
	ImportanceIgnore EventImportance = "ignore" // There's nothing worth telling the person
	ImportanceNotify EventImportance = "notify" // It's worth telling them
	ImportanceAlert  EventImportance = "alert"  // Acting late would cost them something
)

func ParseEventImportance added in v1.2.0

func ParseEventImportance(s string) (EventImportance, error)

ParseEventImportance returns the importance, which is notify when it's empty, or ErrBadParameter when it isn't one

func (EventImportance) Status added in v1.2.0

func (i EventImportance) Status() EventStatus

Status returns the status of an event of the importance, when it's run, which is ignored, when it's ignored, and otherwise pending, until it's delivered

type EventList added in v1.2.0

type EventList struct {
	EventListRequest
	Count uint    `json:"count" help:"How many events there are, of the session, and status" example:"42"`
	Body  []Event `json:"body,omitempty" help:"The events, the most recent first"`
}

EventList is the events a request selects, the most recent first, and how many there are

func (EventList) String added in v1.2.0

func (l EventList) String() string

type EventListRequest added in v1.2.0

type EventListRequest struct {
	Session string      `json:"session,omitempty" help:"Identifier of the session the events are for, or every session" optional:""`
	Status  EventStatus `` /* 139-byte string literal not displayed */
	Offset  uint        `json:"offset,omitempty" help:"Events to skip" example:"0" optional:""`
	Limit   *uint       `json:"limit,omitempty" help:"Most events to return" example:"10" optional:""`
}

EventListRequest selects events: those for a session, and of a status, when they're given, from an offset, and at most a limit of them

func (EventListRequest) Matches added in v1.2.0

func (r EventListRequest) Matches(event Event) bool

Matches returns whether the event is of the request's session, and status, when it has them, which are compared as a session, whatever its case, and a status, without the space around it. A session which isn't one matches no event.

func (EventListRequest) Query added in v1.2.0

func (r EventListRequest) Query() url.Values

Query returns the request as the parameters of a URL's query

func (EventListRequest) String added in v1.2.0

func (r EventListRequest) String() string

type EventMeta added in v1.2.0

type EventMeta struct {
	Run        uuid.UUID       `` /* 130-byte string literal not displayed */
	Session    uuid.UUID       `` /* 146-byte string literal not displayed */
	Source     string          `` /* 132-byte string literal not displayed */
	Title      string          `json:"title,omitempty" help:"What the event is for" example:"Morning briefing"`
	Message    string          `` /* 189-byte string literal not displayed */
	Importance EventImportance `json:"importance,omitempty" help:"How important the message is, once it's run" enum:"ignore,notify,alert" example:"notify"`
	Status     EventStatus     `json:"status" help:"What's become of the event" enum:"scheduled,failed,ignored,pending,notified,delivered" example:"pending"`
	Scheduled  time.Time       `json:"scheduled,omitzero" help:"When the event was due"`
	Fired      time.Time       `json:"fired,omitzero" help:"When the event fired, which is later than it was due, when it's late"`
}

EventMeta is the outcome of an event, such as a heartbeat which fired, which was run: the session it ran in, the conversation it's for, what it's for, when it was due, and fired, and the message, how important it is, and what's become of it

type EventRequest added in v1.2.0

type EventRequest struct {
	Session   uuid.UUID       `json:"session" help:"Identifier of the session the event is for" example:"3b241101-e2bb-4255-8caf-4136c566a962"`
	Source    string          `` /* 165-byte string literal not displayed */
	Title     string          `json:"title,omitempty" help:"What the event is for, in a few words" example:"New document" optional:""`
	Prompt    string          `` /* 173-byte string literal not displayed */
	Data      json.RawMessage `` /* 199-byte string literal not displayed */
	Scheduled time.Time       `json:"scheduled,omitzero" help:"When it happened, or was due, which is when it's run, unless it's given" optional:""`

	// When it's run, which the registry sets
	Fired time.Time `json:"-"`
}

EventRequest is an event to run, from a source other than a heartbeat, such as a file which changed, or a webhook: the session it's for, what it's for, the instruction for it, and what happened, as data, which is information, rather than instructions, and when it happened. Events of the same source, for the same session, run in the one session, as a heartbeat's do, and each other event in a session of its own.

func (EventRequest) Input added in v1.2.0

func (r EventRequest) Input(context []string) (json.RawMessage, error)

Input returns the event agent's input for the event: its title, and prompt, how late it is, its data, as text, all without the tags of what the system says, so they can't fake it, and what the system says, which is the lines, such as the time, and the person's name

func (EventRequest) RunID added in v1.2.0

func (r EventRequest) RunID() uuid.UUID

RunID returns the identifier of the session the event runs in: one for each source, for each session, which is the same each time, or a new one, for an event without a source

func (EventRequest) String added in v1.2.0

func (r EventRequest) String() string

type EventStatus added in v1.2.0

type EventStatus string

EventStatus is what's become of an event: it's scheduled, until it's run, failed, when it couldn't be, and otherwise its message is ignored, as there's nothing worth telling the person, pending, until it's delivered, notified, as the person was told, such as by an alert, or delivered, into the conversation it's for

const (
	EventScheduled EventStatus = "scheduled" // It's to be run
	EventFailed    EventStatus = "failed"    // It couldn't be run
	EventIgnored   EventStatus = "ignored"   // There's nothing worth telling the person
	EventPending   EventStatus = "pending"   // It's to be delivered
	EventNotified  EventStatus = "notified"  // The person was told, such as by an alert
	EventDelivered EventStatus = "delivered" // It's in the conversation it's for
)

func ParseEventStatus added in v1.2.0

func ParseEventStatus(s string) (EventStatus, error)

ParseEventStatus returns the status, or ErrBadParameter when it isn't one

type GeneratorMeta added in v0.6.0

type GeneratorMeta struct {
	Model  *string                    `json:"model,omitempty" help:"Model, by name, or by provider and name" example:"ollama:llama3.2:latest" optional:""`
	System *string                    `json:"system,omitempty" help:"System prompt, sent before the messages" example:"Be brief" optional:""`
	Tools  []string                   `` /* 208-byte string literal not displayed */
	Opt    map[string]json.RawMessage `` /* 139-byte string literal not displayed */
	Schema json.RawMessage            `` /* 199-byte string literal not displayed */
}

GeneratorMeta is how a model is asked: the model, the system prompt, the tools it can call, the options, and the schema of its reply, which agents, sessions and requests to ask a model have

func (GeneratorMeta) IsZero added in v0.6.0

func (s GeneratorMeta) IsZero() bool

IsZero returns true when the settings set nothing, so as an update, they change nothing

func (GeneratorMeta) JSONSchema added in v0.6.0

func (g GeneratorMeta) JSONSchema() (*jsonschema.Schema, error)

JSONSchema returns the schema of the reply, or nil when the reply is text. Returns ErrBadParameter when it isn't a JSON schema.

func (GeneratorMeta) Merge added in v0.6.0

func (s GeneratorMeta) Merge(update GeneratorMeta) GeneratorMeta

Merge returns the settings, changed by those of the update: its model, and its system prompt, when they're set, which empty clears; its tools, when they're set, which an empty list clears; its schema, when it's set, which null clears; and its options, each of which is set, or removed, when it's null. What the update doesn't set is kept.

func (GeneratorMeta) Opts added in v0.6.0

func (g GeneratorMeta) Opts(system string) ([]llm.Opt, error)

Opts returns the system prompt, and the options, for the provider to decode. A tool choice of "none" isn't an option, as the model is sent no tools instead, so a provider which can't choose tools needn't. Returns ErrBadParameter when an option is one which there's a field for, which is the system prompt, and the schema.

func (GeneratorMeta) String added in v0.6.0

func (g GeneratorMeta) String() string

type LoadModelRequest

type LoadModelRequest struct {
	Provider string `` /* 182-byte string literal not displayed */
	Name     string `json:"name" help:"Name of the model to load" example:"llama3.2:latest"`
}

LoadModelRequest is a request to load a model, with a provider which loads models, such as Ollama, which downloads it when it isn't stored

func (LoadModelRequest) String

func (r LoadModelRequest) String() string

type MessageList added in v0.6.0

type MessageList struct {
	MessageListRequest
	Count uint                     `json:"count" help:"How many messages there are, of the role" example:"42"`
	Body  []providerschema.Message `json:"body,omitempty" help:"The messages, each with its tokens"`
}

MessageList is a list of a session's messages, oldest first, and how many there are, of the role

func (MessageList) String added in v0.6.0

func (r MessageList) String() string

type MessageListRequest added in v0.6.0

type MessageListRequest struct {
	Role   string `` /* 175-byte string literal not displayed */
	Offset uint   `json:"offset,omitempty" help:"Messages to skip" example:"0" optional:""`
	Limit  *uint  `json:"limit,omitempty" help:"Most messages to return" example:"10" optional:""`
}

MessageListRequest is a request to list a session's messages, oldest first, of a role, or every role, from the offset, and at most the limit of them, or all of them, when there's no limit

func (MessageListRequest) Query added in v0.6.0

func (r MessageListRequest) Query() url.Values

Query returns the request as the parameters of a URL's query

func (MessageListRequest) String added in v0.6.0

func (r MessageListRequest) String() string

type Model

type Model struct {
	Name             string                     `json:"name" readonly:"" help:"Model name" example:"llama3.2:latest"`
	Provider         string                     `json:"provider" readonly:"" help:"Name of the model's provider in the registry" example:"my-ollama"`
	Canonical        string                     `` /* 158-byte string literal not displayed */
	Description      string                     `json:"description,omitempty" readonly:"" help:"Model description"`
	Created          time.Time                  `json:"created,omitzero" readonly:"" help:"When the model was created"`
	Aliases          []string                   `json:"aliases,omitempty" readonly:"" help:"Other names for the model"`
	Meta             map[string]json.RawMessage `json:"meta,omitempty" readonly:"" help:"Provider-specific metadata"`
	InputTokenLimit  *uint                      `json:"input_token_limit,omitempty" readonly:"" help:"Maximum number of input tokens"`
	OutputTokenLimit *uint                      `json:"output_token_limit,omitempty" readonly:"" help:"Maximum number of output tokens"`
	Capabilities     llm.ModelCap               `json:"capabilities" readonly:"" help:"What the model can do, of what's known"`
}

Model is a model of a provider in the registry

func NewModel

func NewModel(provider, canonical string, model llm.Model) *Model

NewModel returns the model, of the provider with the name in the registry, with its canonical name

func (Model) Cell

func (m Model) Cell(col int) tui.CellText

func (Model) Header

func (m Model) Header() []string

func (Model) String

func (m Model) String() string

func (Model) Width

func (m Model) Width(col int) int

type ModelList

type ModelList struct {
	ModelListRequest
	Count uint     `json:"count"`
	Body  []*Model `json:"body,omitempty"`
}

ModelList is the models of the providers in the registry, in order of their providers' names, and then their names

func (ModelList) String

func (l ModelList) String() string

type ModelListRequest

type ModelListRequest struct {
	Provider string `` /* 135-byte string literal not displayed */
}

ModelListRequest filters a list of models

func (ModelListRequest) Query

func (r ModelListRequest) Query() url.Values

Query returns the request as the query of a URL

func (ModelListRequest) String

func (r ModelListRequest) String() string

type ProgressEvent

type ProgressEvent struct {
	Status   string  `json:"status" help:"Status of the download, or of the tool, which is its message"`
	Percent  float64 `json:"percent" help:"Percentage which is complete, from 0 to 100, or zero when it isn't known"`
	Progress float64 `json:"progress,omitempty" help:"How far a tool has got, which increases each time, as MCP's progress notification says"`
	Total    float64 `json:"total,omitempty" help:"How far a tool has to go, when it's known"`
	Message  string  `json:"message,omitempty" help:"What a tool is doing, such as that an agent it runs is replying"`
}

ProgressEvent is the data of a progress event, streamed while a model is loaded

type PromptMeta added in v0.6.0

type PromptMeta struct {
	Name        string          `json:"name" help:"Name of the agent, which is an identifier, and refers to it" example:"segment"`
	Title       *string         `json:"title,omitempty" help:"Title of the agent, for people" example:"Segment the transcript of an episode" optional:""`
	Description *string         `` /* 165-byte string literal not displayed */
	Input       json.RawMessage `` /* 206-byte string literal not displayed */
	Prompt      *string         `` /* 160-byte string literal not displayed */
	Internal    *bool           `` /* 172-byte string literal not displayed */
}

PromptMeta is what MCP calls a prompt: a template of a message to a model, by its name, with its title and description, and the schema of its input, which the template is executed with

func (PromptMeta) InputSchema added in v0.6.0

func (p PromptMeta) InputSchema() (*jsonschema.Schema, error)

InputSchema returns the schema of the input, or nil when there's none. Returns ErrBadParameter when it isn't a JSON schema of an object.

func (PromptMeta) IsZero added in v0.6.0

func (p PromptMeta) IsZero() bool

IsZero returns true when the prompt sets nothing, apart from its name, so as an update, it changes nothing

func (PromptMeta) Merge added in v0.6.0

func (p PromptMeta) Merge(update PromptMeta) PromptMeta

Merge returns the prompt, changed by the update: its title, description and prompt, when they're set, which empty clears, its input, when it's set, which null clears, and whether it's internal, when it's set. The name isn't changed. What the update doesn't set is kept.

func (PromptMeta) Message added in v0.6.0

func (p PromptMeta) Message(input json.RawMessage) (string, error)

Message returns the message to the model, which is the prompt, executed with the input, which is validated, or the input, as JSON, when there's no prompt. A field of the input which the prompt uses, and the input hasn't, is an error. Returns ErrBadParameter when the input isn't valid, the prompt can't be executed with it, or there's neither a prompt, nor an input.

func (PromptMeta) String added in v0.6.0

func (p PromptMeta) String() string

func (PromptMeta) Template added in v0.6.0

func (p PromptMeta) Template() (*template.Template, error)

Template returns the prompt's template, or nil when there's none. Returns ErrBadParameter when it isn't a Go template.

func (PromptMeta) Validate added in v0.6.0

func (p PromptMeta) Validate(input json.RawMessage) error

Validate returns ErrBadParameter when the input isn't an object, which its input schema, when it has one, validates. No input is an empty object.

type Provider

type Provider struct {
	Name string `` /* 218-byte string literal not displayed */
	Type string `json:"provider" help:"Provider type" enum:"elevenlabs,eliza,gowhisper,ollama,openai" example:"ollama"`
	ProviderMeta
	Serial uint64 `` /* 130-byte string literal not displayed */
}

Provider is a provider's definition: its name in the registry, so there can be more than one provider of a type, its type, its fields which can be set, and its serial, which changes each time its definition does. It's what's needed to create it, and what a store of providers holds.

func (Provider) Equal

func (r Provider) Equal(other Provider) bool

Equal returns true when the requests create the same provider: with the same name and type, and fields

func (Provider) String

func (r Provider) String() string

type ProviderCapabilities

type ProviderCapabilities struct {
	Generator   bool `json:"generator,omitempty" readonly:"" help:"Whether the provider generates messages"`
	Embedder    bool `json:"embedder,omitempty" readonly:"" help:"Whether the provider embeds messages"`
	Downloader  bool `json:"downloader,omitempty" readonly:"" help:"Whether the provider downloads and deletes models, such as Ollama"`
	Transcriber bool `json:"transcriber,omitempty" readonly:"" help:"Whether the provider transcribes and translates audio"`
	Recognizer  bool `json:"recognizer,omitempty" readonly:"" help:"Whether the provider recognizes text in images and documents"`
}

ProviderCapabilities are what a provider can do

func (ProviderCapabilities) String

func (c ProviderCapabilities) String() string

type ProviderList

type ProviderList struct {
	ProviderListRequest
	Count uint              `json:"count"`
	Body  []*ProviderStatus `json:"body,omitempty"`
}

ProviderList is the providers in the registry, in order of their names

func (ProviderList) String

func (l ProviderList) String() string

type ProviderListRequest

type ProviderListRequest struct {
	Type string `json:"provider,omitempty" help:"Returns only the providers of this type" example:"ollama" optional:""`
}

ProviderListRequest filters a list of providers

func (ProviderListRequest) Query

func (r ProviderListRequest) Query() url.Values

Query returns the request as the query of a URL

func (ProviderListRequest) String

func (r ProviderListRequest) String() string

type ProviderMeta

type ProviderMeta struct {
	URL     string   `` /* 170-byte string literal not displayed */
	Include []string `` /* 167-byte string literal not displayed */
	Exclude []string `` /* 132-byte string literal not displayed */
	APIKey  string   `` /* 171-byte string literal not displayed */
}

ProviderMeta are the fields of a provider which can be set, and changed: its endpoint, which isn't needed for every type, the patterns of the names of its models, and its API key, which isn't returned

func (ProviderMeta) Equal

func (m ProviderMeta) Equal(other ProviderMeta) bool

Equal returns true when the fields are the same: the endpoint, API key, or its placeholder, and patterns

func (ProviderMeta) String

func (m ProviderMeta) String() string

type ProviderStatus

type ProviderStatus struct {
	Provider
	ProviderCapabilities
	Error string `json:"error,omitempty" readonly:"" help:"Why the provider can't be reached, when it can't"`
}

ProviderStatus is a provider in the registry: its definition, without its API key, and what's known of it now, which is what it can do, and the error of its ping, when it can't be reached

func (ProviderStatus) Cell

func (p ProviderStatus) Cell(col int) tui.CellText

func (ProviderStatus) Header

func (p ProviderStatus) Header() []string

func (ProviderStatus) String

func (p ProviderStatus) String() string

func (ProviderStatus) Width

func (p ProviderStatus) Width(col int) int

type RecognizeForm

type RecognizeForm struct {
	Model string     `json:"model" help:"Model which recognizes text, by name, or by provider and name" example:"mistral:mistral-ocr-latest"`
	Opt   string     `json:"opt,omitempty" help:"Options, as a JSON object, such as {\"pages\":\"0-1\"}" example:"{\"pages\":\"0-1\"}" optional:""`
	File  types.File `json:"file,omitzero" help:"Image or document to recognize, uploaded as a file"`
}

RecognizeForm is the form for recognizing the text in an image or document uploaded as a file, such as from a web browser, which is read as a RecognizeRequest. The options are a JSON object, as a form's values are strings.

type RecognizeRequest

type RecognizeRequest struct {
	Model string                     `json:"model" help:"Model which recognizes text, by name, or by provider and name" example:"mistral:mistral-ocr-latest"`
	Type  string                     `json:"type" help:"MIME type of the image or document" example:"application/pdf"`
	Data  []byte                     `json:"data" help:"Data of the image or document, encoded as base64" example:"JVBERi0xLjQ="`
	Opt   map[string]json.RawMessage `` /* 174-byte string literal not displayed */
}

RecognizeRequest asks a model for the text in an image, or a document such as a PDF, by its type and data, with the options

func (RecognizeRequest) Opts

func (r RecognizeRequest) Opts() []llm.Opt

Opts returns the options, for the provider to decode

func (RecognizeRequest) Resource

func (r RecognizeRequest) Resource() (llm.Resource, error)

Resource returns the image or document to recognize, or an error when it has no type, or no data

func (RecognizeRequest) String

func (r RecognizeRequest) String() string

String returns the request without its data, which can be large

type RecognizeResponse

type RecognizeResponse struct {
	Model string `json:"model" help:"Canonical name of the model which recognized the text" example:"mistral:mistral-ocr-latest"`
	llm.Document
	Usage llm.Usage `json:"usage" help:"Pages recognized, and tokens used, for providers which report them"`
}

RecognizeResponse is the text of each page, in order, in Markdown, and its regions, when they're asked for, with the model which recognized it, and the pages, and tokens, used

func (RecognizeResponse) String

func (r RecognizeResponse) String() string

type RunAgentRequest added in v0.6.0

type RunAgentRequest struct {
	Input   json.RawMessage `` /* 162-byte string literal not displayed */
	Session uuid.UUID       `` /* 182-byte string literal not displayed */
	Tools   []string        `` /* 131-byte string literal not displayed */
}

RunAgentRequest runs an agent: its input, which is validated against the agent's input schema, and executed with its prompt, and the session it's run from, such as the conversation whose model called it, as a tool, whose model it's run with, when it has none

func (RunAgentRequest) String added in v0.6.0

func (r RunAgentRequest) String() string

type RunAgentResponse added in v0.6.0

type RunAgentResponse struct {
	Name   string `json:"name" help:"Name of the agent" example:"segment"`
	Serial uint64 `json:"serial,omitempty" help:"Serial of the agent's definition which was run" example:"3"`
	SessionResponse
	Reply json.RawMessage `json:"reply,omitempty" help:"The agent's reply, as a JSON string of its text, or JSON, when the agent has a schema"`
}

RunAgentResponse is what an agent did: the agent, by its name, and the serial of the definition which was run, the messages it added, which are its prompt, its reply, and the tools it called, and the tokens used, and its reply, which is text, or JSON, when the agent has a schema

func (RunAgentResponse) String added in v0.6.0

func (r RunAgentResponse) String() string

type RunEventRequest added in v1.1.0

type RunEventRequest struct {
	Session uuid.UUID       `` /* 138-byte string literal not displayed */
	Agent   string          `` /* 131-byte string literal not displayed */
	Without []string        `` /* 187-byte string literal not displayed */
	Input   json.RawMessage `` /* 157-byte string literal not displayed */

	// What the event is for, and when it was due, and fired, which its
	// outcome has, when it's stored
	Title     string    `json:"title,omitempty" help:"What the event is for" example:"Morning briefing" optional:""`
	Scheduled time.Time `json:"scheduled,omitzero" help:"When the event was due" optional:""`
	Fired     time.Time `json:"fired,omitzero" help:"When the event fired" optional:""`
}

RunEventRequest is an event to run, such as a heartbeat which fired, in its own session: the session it's for, whose model, and tools, it's run with, apart from those of the namespaces it's without, and the agent which runs it, which is the event agent, unless it's given, with its input

type RunEventResponse added in v1.1.0

type RunEventResponse struct {
	Session Session          `json:"session" help:"The session the event ran in, without its messages"`
	Run     RunAgentResponse `json:"run" help:"What the agent which ran the event did, and replied"`
	Event   *Event           `json:"event,omitempty" help:"The event's outcome, as it's stored, when there's an event store"`
}

RunEventResponse is the session the event ran in, and what the agent which ran it did, and replied

type Session added in v0.6.0

type Session struct {
	ID       uuid.UUID `json:"id" readonly:"" help:"Identifier of the session, which its store sets" example:"3b241101-e2bb-4255-8caf-4136c566a962"`
	Serial   uint64    `json:"serial,omitempty" readonly:"" help:"Serial of the session, which its store changes each time it's stored" example:"3"`
	Created  time.Time `json:"created,omitzero" readonly:"" help:"When the session was created"`
	Modified time.Time `json:"modified,omitzero" readonly:"" help:"When the session was last stored"`
	SessionMeta
	Messages []providerschema.Message `` /* 129-byte string literal not displayed */
	Usage    SessionUsage             `json:"usage,omitzero" help:"Tokens used by every request to the model, and of the conversation, as of the last"`
	Status   SessionStatus            `` /* 195-byte string literal not displayed */
}

Session is a conversation with a model, as it's stored: its identifier, and serial, which its store sets, and changes each time it's stored, so a change is made to the session as it was last seen, its settings, its messages, each with its tokens, and its usage. The registry returns a session without its messages, which are listed on their own.

func (Session) Cell added in v0.6.0

func (s Session) Cell(col int) tui.CellText

Cell returns the session's identifier, model, tools, the tokens of its conversation, as of its last request, and when it was last updated, which is when it was created, or modified, whichever is later

func (Session) Header added in v0.6.0

func (s Session) Header() []string

func (Session) String added in v0.6.0

func (s Session) String() string

func (Session) Width added in v0.6.0

func (s Session) Width(col int) int

type SessionEvent added in v0.6.0

type SessionEvent struct {
	Serial uint64        `json:"serial,omitempty" help:"Serial of the session, as it was stored" example:"3"`
	Status SessionStatus `json:"status,omitempty" help:"Status of the session, as it changed" example:"replying"`
}

SessionEvent is what an event of a session says of the change: the session's new serial, when it was stored, or its new status, when that changed

func (SessionEvent) String added in v0.6.0

func (e SessionEvent) String() string

type SessionList added in v0.6.0

type SessionList struct {
	SessionListRequest
	Count uint      `json:"count" help:"How many sessions there are" example:"42"`
	Body  []Session `json:"body,omitempty" help:"The sessions, without their messages"`
}

SessionList is a list of sessions, without their messages, and how many sessions there are

func (SessionList) String added in v0.6.0

func (s SessionList) String() string

type SessionListRequest added in v0.6.0

type SessionListRequest struct {
	Offset uint  `json:"offset,omitempty" help:"Sessions to skip" example:"0" optional:""`
	Limit  *uint `json:"limit,omitempty" help:"Most sessions to return" example:"10" optional:""`
}

SessionListRequest is a request to list sessions, from the offset, and at most the limit of them, or all of them, when there's no limit

func (SessionListRequest) Query added in v0.6.0

func (r SessionListRequest) Query() url.Values

Query returns the request as the parameters of a URL's query

func (SessionListRequest) String added in v0.6.0

func (s SessionListRequest) String() string

type SessionMeta added in v0.6.0

type SessionMeta struct {
	GeneratorMeta

	// Event is whether the session is an event's, such as a heartbeat's,
	// which the registry runs it in, so it isn't chatted in. It's set by the
	// registry, rather than by its API, which ignores it.
	Event bool `` /* 170-byte string literal not displayed */
}

SessionMeta is a session's settings: how its model is asked

func (SessionMeta) IsZero added in v0.6.0

func (s SessionMeta) IsZero() bool

IsZero returns true when the settings set nothing, so as an update, they change nothing

func (SessionMeta) Merge added in v0.6.0

func (s SessionMeta) Merge(update SessionMeta) SessionMeta

Merge returns the settings, changed by those of the update, as GeneratorMeta.Merge does. Whether it's an event's isn't changed, as the registry sets it.

func (SessionMeta) String added in v0.6.0

func (s SessionMeta) String() string

type SessionResponse added in v0.6.0

type SessionResponse struct {
	Messages []providerschema.Message `` /* 149-byte string literal not displayed */
	Usage    SessionUsage             `json:"usage" help:"Tokens used, by every request to the model, and of the conversation, with the messages"`
}

SessionResponse is what's added to a session's conversation: the messages, the last of which is the model's reply, each with its tokens, and the usage of every request to the model, with the tokens of the conversation, with the messages. With a schema, the model's reply, when its result is stop, is JSON which conforms to it.

func (SessionResponse) String added in v0.6.0

func (s SessionResponse) String() string

type SessionStatus added in v0.6.0

type SessionStatus string

SessionStatus is who's doing what in a session: someone is typing a message, its model is replying to one, or neither, when it's idle

const (
	SessionIdle     SessionStatus = "idle"     // Neither typing nor replying
	SessionTyping   SessionStatus = "typing"   // Someone is typing a message
	SessionReplying SessionStatus = "replying" // The model is replying
)

func (SessionStatus) String added in v0.6.0

func (s SessionStatus) String() string

func (*SessionStatus) UnmarshalJSON added in v0.6.0

func (s *SessionStatus) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes a status, which must be one of the statuses

type SessionStatusRequest added in v0.6.0

type SessionStatusRequest struct {
	Status SessionStatus `json:"status" help:"Status of the session, which is typing or idle" enum:"typing,idle" example:"typing"`
}

SessionStatusRequest sets a session's status, which a client sets to typing, as someone types a message, or idle, when they stop

func (SessionStatusRequest) String added in v0.6.0

func (r SessionStatusRequest) String() string

type SessionUsage added in v0.6.0

type SessionUsage struct {
	llm.Usage
	Input    uint `` /* 149-byte string literal not displayed */
	Output   uint `json:"output,omitempty" help:"Tokens of the conversation's replies from the model" example:"300"`
	Overhead uint `` /* 127-byte string literal not displayed */
}

SessionUsage is the tokens used by requests to a model, and the tokens of a session's conversation, of the messages sent to the model, of its replies, and of what's sent with them, such as the system prompt and the tools, which together are about the tokens of the next request

func (SessionUsage) String added in v0.6.0

func (s SessionUsage) String() string

type StreamEvent

type StreamEvent struct {
	Text string `json:"text" help:"A piece of the reply's text, or of the model's thinking"`
}

StreamEvent is the data of a text or thinking event, which is a piece of the reply as it's generated

type TranscribeForm

type TranscribeForm struct {
	Model string     `json:"model" help:"Model which transcribes speech, by name, or by provider and name" example:"openai:whisper-1"`
	Opt   string     `json:"opt,omitempty" help:"Options, as a JSON object, such as {\"segments\":true}" example:"{\"segments\":true}" optional:""`
	File  types.File `json:"file,omitzero" help:"Audio to transcribe, uploaded as a file"`
}

TranscribeForm is the form for transcribing, or translating, the speech in audio uploaded as a file, such as from a web browser, which is read as a TranscribeRequest. The options are a JSON object, as a form's values are strings.

type TranscribeRequest

type TranscribeRequest struct {
	Model string                     `json:"model" help:"Model which transcribes speech, by name, or by provider and name" example:"openai:whisper-1"`
	Type  string                     `json:"type" help:"MIME type of the audio" example:"audio/mpeg"`
	Data  []byte                     `json:"data" help:"Data of the audio, encoded as base64" example:"SUQzBAAAAAAA"`
	Opt   map[string]json.RawMessage `` /* 167-byte string literal not displayed */
}

TranscribeRequest asks a model for the speech in audio, by its type and data, as text, in the language it was spoken in, or translated into English, with the options

func (TranscribeRequest) Opts

func (r TranscribeRequest) Opts() []llm.Opt

Opts returns the options, for the provider to decode

func (TranscribeRequest) Resource

func (r TranscribeRequest) Resource() (llm.Resource, error)

Resource returns the audio to transcribe, or an error when it has no type, or no data

func (TranscribeRequest) String

func (r TranscribeRequest) String() string

String returns the request without its data, which can be large

type TranscribeResponse

type TranscribeResponse struct {
	Model string `json:"model" help:"Canonical name of the model which transcribed the speech" example:"openai:whisper-1"`
	llm.Transcript
	Usage llm.Usage `json:"usage" help:"Seconds of audio, and tokens, used, for providers which report them"`
}

TranscribeResponse is the transcript, with its language, when it's known, and its segments, when they're asked for, with the model which transcribed it, and the seconds, and tokens, used

func (TranscribeResponse) String

func (r TranscribeResponse) String() string

type TriggerEventResponse added in v1.2.0

type TriggerEventResponse struct {
	Scheduled bool  `json:"scheduled" help:"Whether the event is scheduled to run, rather than an event of its source, which is already"`
	Event     Event `` /* 165-byte string literal not displayed */
}

TriggerEventResponse is whether an event which was triggered is scheduled to run, which it isn't, when an event of its source is already, and the event's outcome, which is scheduled, until it's run, or the outcome of the event which is already

Jump to

Keyboard shortcuts

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