Documentation
¶
Overview ¶
Package schema has the requests and responses of the registry's API
Index ¶
- Constants
- func ProviderTypes() []string
- func RedactURL(u *url.URL) string
- type Agent
- type AgentList
- type AgentListRequest
- type AgentMeta
- type AskRequest
- type AskResponse
- type ChatRequest
- type ChatResponse
- type EmbedAttachment
- type EmbedContent
- type EmbedForm
- type EmbedMessage
- type EmbedRequest
- type EmbedResponse
- type ErrorEvent
- type GeneratorMeta
- type LoadModelRequest
- type MessageList
- type MessageListRequest
- type Model
- type ModelList
- type ModelListRequest
- type ProgressEvent
- type PromptMeta
- func (p PromptMeta) InputSchema() (*jsonschema.Schema, error)
- func (p PromptMeta) IsZero() bool
- func (p PromptMeta) Merge(update PromptMeta) PromptMeta
- func (p PromptMeta) Message(input json.RawMessage) (string, error)
- func (p PromptMeta) String() string
- func (p PromptMeta) Template() (*template.Template, error)
- func (p PromptMeta) Validate(input json.RawMessage) error
- type Provider
- type ProviderCapabilities
- type ProviderList
- type ProviderListRequest
- type ProviderMeta
- type ProviderStatus
- type RecognizeForm
- type RecognizeRequest
- type RecognizeResponse
- type RunAgentRequest
- type RunAgentResponse
- type Session
- type SessionEvent
- type SessionList
- type SessionListRequest
- type SessionMeta
- type SessionResponse
- type SessionStatus
- type SessionStatusRequest
- type SessionUsage
- type StreamEvent
- type TranscribeForm
- type TranscribeRequest
- type TranscribeResponse
Constants ¶
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
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.
const AskBodyLimit = 32 << 20
AskBodyLimit is the largest request body, in bytes, when a model is asked, which allows for images in the messages
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
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
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
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 ProviderTypes ¶
func ProviderTypes() []string
ProviderTypes returns the types of providers which the registry creates, in order
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
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
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
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
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
Merge returns the definition, changed by the update, as PromptMeta.Merge and GeneratorMeta.Merge do
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
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 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
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
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 */
}
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, and its input, when it's set, which null clears. 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.
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) 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 */
}
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 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.
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
}
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
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