Documentation
¶
Index ¶
- Constants
- Variables
- func ApplyGeneratorMeta(values url.Values, meta GeneratorMeta) url.Values
- func CanonicalNamespace(ns string) string
- func CanonicalURL(rawURL string) (string, error)
- func HTTPErr(err error) error
- func MetaForKey(meta []MetaValue, key string) any
- func MetaMap(meta []MetaValue) map[string]any
- func WithAttachment(r io.Reader) opt.Opt
- func WithAttachmentURL(u string, mimetype string) opt.Opt
- type Agent
- type AgentList
- type AgentListRequest
- type AgentMeta
- type AgentStore
- type AskRequest
- type AskRequestCore
- type AskResponse
- type Attachment
- func (a Attachment) Description() string
- func (a Attachment) IsText() bool
- func (a Attachment) MarshalJSON() ([]byte, error)
- func (a Attachment) Name() string
- func (a Attachment) Read(ctx context.Context) ([]byte, error)
- func (a Attachment) TextContent() string
- func (a Attachment) Type() string
- func (a Attachment) URI() string
- func (a *Attachment) UnmarshalJSON(data []byte) error
- type CallAgentRequest
- type CallToolRequest
- type CallToolResponse
- type ChatRequest
- type ChatResponse
- type CompletionResponse
- type Connector
- type ConnectorCapability
- type ConnectorGroupList
- type ConnectorGroupRef
- type ConnectorGroupSelector
- type ConnectorInsert
- type ConnectorList
- type ConnectorListRequest
- type ConnectorMeta
- type ConnectorState
- type ConnectorStateSelector
- type ConnectorURLSelector
- type ContentBlock
- type Conversation
- type CreateAgentSessionRequest
- type CreateAgentSessionResponse
- type CreateConnectorUnauthorizedResponse
- type Credential
- type CredentialInsert
- type CredentialKey
- type DeleteModelRequest
- type DownloadModelRequest
- type EmbeddingRequest
- type EmbeddingResponse
- type Err
- type GeneratorMeta
- type GetModelRequest
- type JSONSchema
- type ListAgentRequest
- type ListAgentResponse
- type ListModelsRequest
- type ListModelsResponse
- type Message
- type MessageInsert
- type MessageList
- type MessageListRequest
- type MetaValue
- type Model
- type ModelCap
- type ModelList
- type ModelListRequest
- type ModelNameSelector
- type ModelProviderSelector
- type MultipartAskRequest
- type OAuthCredentials
- type ProgressEvent
- type Provider
- type ProviderCredentials
- type ProviderGroupList
- type ProviderGroupRef
- type ProviderGroupSelector
- type ProviderInsert
- type ProviderList
- type ProviderListRequest
- type ProviderMeta
- type ProviderMetaMap
- type ProviderNameSelector
- type ResultType
- type Session
- type SessionChannelRequest
- type SessionIDSelector
- type SessionInsert
- type SessionList
- type SessionListRequest
- type SessionMeta
- type SessionOverheadSelector
- type SessionOverheadUpdate
- type StreamDelta
- type StreamError
- type ToolCall
- type ToolList
- type ToolListRequest
- type ToolMeta
- type ToolResult
- type Usage
- type UsageInsert
- type UsageMeta
- type UsageType
Constants ¶
const ( EventAssistant = "assistant" // Streamed text chunk from the assistant EventThinking = "thinking" // Streamed thinking/reasoning chunk EventTool = "tool" // Tool call feedback (name, description) EventUsage = "usage" // Token usage update EventError = "error" // Error during processing EventResult = "result" // Final complete response EventProgress = "progress" // Download progress update )
const ( RoleUser = "user" RoleAssistant = "assistant" RoleSystem = "system" RoleThinking = "thinking" RoleTool = "tool" MessageListMax uint64 = 100 )
Message role constants
const ( Gemini = "gemini" Anthropic = "anthropic" Mistral = "mistral" Eliza = "eliza" Ollama = "ollama" OpenAI = "openai" )
Provider name constants
const ( DefaultSchema = "llm" DefaultAuthSchema = "auth" DefaultNotifyChannel = "channel_notify" )
const BuiltinNamespace = "builtin"
BuiltinNamespace is the namespace used for locally-implemented (builtin) tools.
const (
ConnectorListMax uint64 = 100
)
const DefaultMaxIterations = 10
DefaultMaxIterations is the default maximum number of tool-calling iterations per chat turn.
const (
EmbeddingTaskTypeDefault = "DEFAULT"
)
const (
ProviderListMax uint64 = 100
)
const ResultOK = ResultStop
ResultOK is an alias for ResultStop (normal completion).
const (
SessionListMax uint64 = 100
)
Variables ¶
var ConnectorURLSchemes = []string{"http", "https"}
ConnectorURLSchemes lists the URL schemes that are accepted for connector registration. Connectors must use one of these schemes.
var Objects string
var Queries string
Functions ¶
func ApplyGeneratorMeta ¶
func ApplyGeneratorMeta(values url.Values, meta GeneratorMeta) url.Values
ApplyGeneratorMeta replaces generator-related keys in values with the encoded contents of meta while preserving unrelated keys.
func CanonicalNamespace ¶
CanonicalNamespace normalises a namespace string by lowercasing it, removing spaces and replacing "-" and "." characters with underscores.
func CanonicalURL ¶
CanonicalURL validates rawURL and returns a canonical form consisting of scheme://host[:port]/path with a lowercased scheme, host, and path. The URL must be absolute, use a supported scheme (http or https), have a non-empty host, and — if a port is present — a valid port in 1–65535. Any userinfo, query string, or fragment is stripped.
func MetaForKey ¶
MetaForKey returns the last value for the given key from a slice of MetaValue, or nil if not found. Returning the last match is consistent with MetaMap, where later entries override earlier ones.
func WithAttachment ¶
WithAttachmentURL creates an attachment from data read from the provided reader The MIME type is detected from the data. This is suitable for small attachments the caller is responsible for closing the reader after the data is read.
Types ¶
type Agent ¶
type Agent struct {
ID string `json:"id"`
Created time.Time `json:"created"`
Version uint `json:"version"`
AgentMeta
}
Agent is a versioned, stored agent definition.
type AgentList ¶
type AgentList struct {
AgentListRequest
Count uint `json:"count" help:"Total number of matching agents" example:"2"`
Body []*AgentMeta `` /* 141-byte string literal not displayed */
}
AgentList represents a response containing a list of externally exposed agents.
type AgentListRequest ¶
type AgentListRequest struct {
pg.OffsetLimit
// Namespace restricts results to a single namespace.
// Use BuiltinNamespace for locally-implemented agents, a connector namespace
// for remote agents, or leave empty to include all namespaces.
Namespace string `json:"namespace,omitempty" help:"Restrict results to a single namespace" example:"builtin"`
// Name restricts results to agents whose names appear in this list.
// An empty slice means no name filter.
Name []string `` /* 128-byte string literal not displayed */
}
AgentListRequest represents a request to list externally exposed agents, which are backed by toolkit prompts.
func (AgentListRequest) Query ¶
func (r AgentListRequest) Query() url.Values
func (AgentListRequest) String ¶
func (r AgentListRequest) String() string
type AgentMeta ¶
type AgentMeta struct {
GeneratorMeta `yaml:",inline"`
Name string `json:"name" yaml:"name" help:"Unique agent name"`
Title string `json:"title,omitempty" yaml:"title" help:"Human-readable title" optional:""`
Description string `json:"description,omitempty" yaml:"description" help:"Agent description" optional:""`
Template string `json:"template,omitempty" yaml:"-" help:"Go template for the user message" optional:""`
Input JSONSchema `json:"input,omitempty" yaml:"input" help:"JSON schema for agent input" optional:""`
Tools []string `json:"tools,omitzero" yaml:"tools" help:"Tool names the agent is allowed to use" optional:""`
}
AgentMeta describes the definition of an agent, including which model and provider to use and the schemas that govern its input and output.
type AgentStore ¶
type AgentStore interface {
// CreateAgent creates a new agent from the given metadata,
// returning the agent with a unique ID and version 1.
CreateAgent(ctx context.Context, meta AgentMeta) (*Agent, error)
// GetAgent retrieves an existing agent by ID or name.
// Returns an error if the agent does not exist.
GetAgent(ctx context.Context, id string) (*Agent, error)
// ListAgents returns agents matching the request, with pagination support.
// Returns offset, limit and total count in the response.
ListAgents(ctx context.Context, req ListAgentRequest) (*ListAgentResponse, error)
// DeleteAgent removes an agent by ID or name. When a name is provided,
// all versions of the agent are deleted. Returns an error if no matching
// agent exists.
DeleteAgent(ctx context.Context, id string) error
// UpdateAgent applies non-zero fields from the given metadata to an existing
// agent and increments the version. Returns the updated agent.
UpdateAgent(ctx context.Context, id string, meta AgentMeta) (*Agent, error)
}
AgentStore is the interface for agent storage backends.
type AskRequest ¶
type AskRequest struct {
AskRequestCore
Attachments []Attachment `` /* 143-byte string literal not displayed */
}
AskRequest represents a stateless request to generate content.
func (AskRequest) String ¶
func (r AskRequest) String() string
type AskRequestCore ¶
type AskRequestCore struct {
GeneratorMeta
Text string `json:"text" arg:"" help:"User input text" example:"Summarize the benefits of unit testing in one sentence."`
}
AskRequestCore contains the core fields of an ask request without attachments.
func (AskRequestCore) String ¶
func (r AskRequestCore) String() string
type AskResponse ¶
type AskResponse struct {
CompletionResponse
Usage *UsageMeta `` /* 138-byte string literal not displayed */
}
AskResponse represents the response from an ask request.
func (AskResponse) String ¶
func (r AskResponse) String() string
type Attachment ¶
type Attachment struct {
ContentType string `json:"type" help:"Attachment MIME type, for example image/png or application/pdf" example:"image/png"`
Data []byte `json:"data,omitempty" help:"Inline attachment payload encoded as a byte string" example:"iVBORw0KGgo="`
URL *url.URL `json:"url,omitempty" help:"Attachment URL reference, for example https, gs, or file" example:"https://example.com/image.png"`
}
Attachment represents binary or URI-referenced media (images, documents, etc.)
func (Attachment) Description ¶
func (a Attachment) Description() string
Description returns an empty string. Satisfies llm.Resource.
func (Attachment) IsText ¶
func (a Attachment) IsText() bool
IsText returns true if the attachment has a text/* MIME type (e.g. text/plain, text/html, text/csv). Handles MIME parameters like charset gracefully. Such attachments can be converted to text blocks when providers don't support them as media uploads.
func (Attachment) MarshalJSON ¶
func (a Attachment) MarshalJSON() ([]byte, error)
func (Attachment) Name ¶
func (a Attachment) Name() string
Name returns the last path segment of the attachment URL, or an empty string for inline data. Satisfies llm.Resource.
func (Attachment) Read ¶
func (a Attachment) Read(ctx context.Context) ([]byte, error)
Read returns the attachment's raw bytes. If Data is non-empty it is returned directly. If URL is set and has a supported scheme (http, https, file) the content is fetched. Satisfies llm.Resource.
func (Attachment) TextContent ¶
func (a Attachment) TextContent() string
TextContent returns the attachment's data as a string, optionally prefixed with the filename and content type for context. Only meaningful when IsText() returns true.
func (Attachment) Type ¶
func (a Attachment) Type() string
Type returns the MIME type of the attachment. Satisfies llm.Resource.
func (Attachment) URI ¶
func (a Attachment) URI() string
URI returns the URL of the attachment as a string, or an empty string if the attachment is inline data only. Satisfies llm.Resource.
func (*Attachment) UnmarshalJSON ¶
func (a *Attachment) UnmarshalJSON(data []byte) error
type CallAgentRequest ¶
type CallAgentRequest struct {
CallToolRequest
Attachments []interface {
URI() string
Name() string
Description() string
Type() string
Read(context.Context) ([]byte, error)
} `json:"attachments,omitempty" help:"Additional resources attached to the agent call" optional:""`
}
CallAgentRequest represents a request to call an agent directly.
func (CallAgentRequest) String ¶
func (r CallAgentRequest) String() string
type CallToolRequest ¶
type CallToolRequest struct {
Input json.RawMessage `json:"input,omitempty" help:"JSON-encoded arguments passed to the tool" example:"{\"query\":\"authentication flow\"}"`
}
CallToolRequest represents a request to call a tool directly.
func (CallToolRequest) String ¶
func (r CallToolRequest) String() string
type CallToolResponse ¶
type CallToolResponse struct {
Tool string `json:"tool"`
Result json.RawMessage `json:"result"`
}
CallToolResponse represents the result of calling a tool
func (CallToolResponse) String ¶
func (r CallToolResponse) String() string
type ChatRequest ¶
type ChatRequest struct {
Session uuid.UUID `json:"session" help:"Session ID"`
Text string `json:"text" arg:"" help:"User input text"`
Tools []string `json:"tools,omitzero" help:"Tool names to include (nil means all, empty means none)" optional:""`
MaxIterations uint `json:"max_iterations,omitempty" help:"Maximum tool-calling iterations (0 uses default)" optional:""`
SystemPrompt string `json:"system_prompt,omitempty" help:"Per-request system prompt appended to the session prompt" optional:""`
}
ChatRequest contains the core fields of a chat request without attachments.
func (ChatRequest) String ¶
func (r ChatRequest) String() string
type ChatResponse ¶
type ChatResponse struct {
ID uint64 `json:"id,omitempty" help:"Persisted message row ID for the final reply when available" example:"42"`
Session uuid.UUID `json:"session,omitzero" help:"Session owning the final reply when available" optional:""`
CompletionResponse
Usage *UsageMeta `json:"usage,omitempty"`
}
ChatResponse represents the response from a chat request.
func (ChatResponse) String ¶
func (r ChatResponse) String() string
type CompletionResponse ¶
type CompletionResponse struct {
Role string `json:"role" help:"Role of the generated response, typically assistant" example:"assistant"`
Content []ContentBlock `` /* 168-byte string literal not displayed */
Result ResultType `json:"result" help:"Completion result status" example:"\"stop\""`
}
CompletionResponse represents a response from a completion request.
func (CompletionResponse) String ¶
func (r CompletionResponse) String() string
type Connector ¶
type Connector struct {
// Mutable fields
ConnectorInsert
// CreatedAt is the time the connector was first registered.
CreatedAt time.Time `json:"created_at"`
// ModifiedAt is the time the connector metadata was last updated.
ModifiedAt *time.Time `json:"modified_at,omitempty"`
// Current Connector State
ConnectorState
}
Connector combines persisted metadata with runtime state for an MCP server.
type ConnectorCapability ¶
type ConnectorCapability string
ConnectorCapability represents a named capability advertised by an MCP server.
const ( // CapabilityTools indicates the server advertises callable tools. CapabilityTools ConnectorCapability = "tools" // CapabilityResources indicates the server can serve resources. CapabilityResources ConnectorCapability = "resources" // CapabilityPrompts indicates the server provides reusable prompt templates. CapabilityPrompts ConnectorCapability = "prompts" // CapabilityLogging indicates the server emits log notifications. CapabilityLogging ConnectorCapability = "logging" // CapabilityCompletions indicates the server supports argument/prompt completion. CapabilityCompletions ConnectorCapability = "completions" )
type ConnectorGroupList ¶
type ConnectorGroupList []string
ConnectorGroupList is a list of auth group identifiers associated with a connector.
type ConnectorGroupRef ¶
ConnectorGroupRef represents a single connector-to-group link.
type ConnectorGroupSelector ¶
ConnectorGroupSelector selects connector_group rows for a connector, optionally scoped to a single group.
type ConnectorInsert ¶
type ConnectorInsert struct {
URL string `json:"url" name:"url" help:"MCP server endpoint URL"`
ConnectorMeta
}
ConnectorInsert contains the fields required to insert a new connector row.
func (ConnectorInsert) String ¶
func (c ConnectorInsert) String() string
type ConnectorList ¶
type ConnectorList struct {
ConnectorListRequest
Count uint `json:"count"`
Body []*Connector `json:"body,omitzero"`
}
ConnectorList represents a response containing a list of MCP connectors.
func (ConnectorList) String ¶
func (r ConnectorList) String() string
type ConnectorListRequest ¶
type ConnectorListRequest struct {
pg.OffsetLimit
Namespace string `json:"namespace,omitempty" help:"Filter by namespace" optional:""`
Enabled *bool `json:"enabled,omitempty" help:"Filter by enabled state" negatable:""`
}
ConnectorListRequest represents a request to list registered MCP connectors.
func (ConnectorListRequest) Query ¶
func (req ConnectorListRequest) Query() url.Values
func (ConnectorListRequest) String ¶
func (r ConnectorListRequest) String() string
type ConnectorMeta ¶
type ConnectorMeta struct {
// Enabled controls whether the server is active. Disabled servers are
// retained in the registry but not connected on startup.
// A nil value in a patch request means "preserve the existing value".
Enabled *bool `` /* 147-byte string literal not displayed */
// Namespace is an optional prefix used to disambiguate tools from this
// connector when multiple connectors expose tools with the same name.
// A nil value in a patch request means "preserve the existing value".
Namespace *string `` /* 141-byte string literal not displayed */
// Groups holds auth group identifiers that are allowed to access this
// connector.
Groups []string `` /* 157-byte string literal not displayed */
// Meta holds arbitrary user-managed connector metadata.
// A nil value in a patch request means "preserve the existing value".
// An empty object clears the metadata.
Meta ProviderMetaMap `json:"meta,omitempty" jsonschema:"Arbitrary user-managed connector metadata as a JSON object."`
}
ConnectorMeta holds the user-configurable settings for a registered MCP server.
func (ConnectorMeta) HasTableUpdates ¶
func (c ConnectorMeta) HasTableUpdates() bool
func (ConnectorMeta) String ¶
func (c ConnectorMeta) String() string
type ConnectorState ¶
type ConnectorState struct {
// ConnectedAt is the time of the most recent successful connection.
ConnectedAt *time.Time `json:"connected_at,omitempty"`
// Name is the programmatic identifier reported by the server.
Name *string `json:"name,omitempty"`
// Title is a human-readable display name reported by the server.
Title *string `json:"title,omitempty"`
// Description is the server-reported description.
Description *string `json:"description,omitempty"`
// Version is the server-reported version string.
Version *string `json:"version,omitempty"`
// Capabilities is the set of capabilities declared at initialization.
Capabilities []ConnectorCapability `json:"capabilities,omitempty"`
}
ConnectorState carries the server-reported runtime state of a connector. All fields are pointers so callers can update a subset without overwriting fields they did not observe.
func (ConnectorState) HasTableUpdates ¶
func (c ConnectorState) HasTableUpdates() bool
func (ConnectorState) String ¶
func (c ConnectorState) String() string
type ConnectorStateSelector ¶
type ConnectorStateSelector string
ConnectorStateSelector selects a connector by canonical URL for runtime state updates.
type ConnectorURLSelector ¶
type ConnectorURLSelector string
ConnectorURLSelector selects a connector by canonical URL.
type ContentBlock ¶
type ContentBlock struct {
Text *string `` /* 141-byte string literal not displayed */
Thinking *string `` /* 136-byte string literal not displayed */
Attachment *Attachment `` /* 173-byte string literal not displayed */
ToolCall *ToolCall `` /* 161-byte string literal not displayed */
ToolResult *ToolResult `` /* 190-byte string literal not displayed */
}
ContentBlock represents a single piece of content within a message. Exactly one of the fields should be non-nil/non-empty.
func NewToolError ¶
func NewToolError(id, name string, err error) ContentBlock
NewToolError creates a content block containing a tool error result
func NewToolResult ¶
func NewToolResult(id, name string, v any) ContentBlock
NewToolResult creates a content block containing a successful tool result
type Conversation ¶
type Conversation []*Message
Conversation is a sequence of messages exchanged with an LLM
func (*Conversation) Append ¶
func (s *Conversation) Append(message Message)
Append adds a message to the conversation
func (*Conversation) AppendWithOuput ¶
func (s *Conversation) AppendWithOuput(message Message, input, output uint)
AppendWithOutput adds a message to the conversation, attributing token counts to individual messages. The last message in the conversation (typically the just-appended user message) receives an estimated token count based on its content rather than absorbing overhead such as tool schemas and system prompts. The response message receives the actual output token count from the provider.
func (Conversation) Last ¶
func (c Conversation) Last(n int) *Message
func (Conversation) Len ¶
func (c Conversation) Len() int
func (Conversation) String ¶
func (c Conversation) String() string
func (Conversation) Tokens ¶
func (s Conversation) Tokens() uint
Return the total number of tokens in the conversation
type CreateAgentSessionRequest ¶
type CreateAgentSessionRequest struct {
Parent string `json:"parent,omitempty" help:"Parent session ID for traceability" optional:""`
Input json.RawMessage `json:"input,omitempty" help:"Input data for the agent template" optional:""`
}
CreateAgentSessionRequest represents the body of a request to create a session from an agent definition. The agent is identified by path/query parameters (agent ID or name, optional version) — not included here. The agent's template is executed with Input, and a new session is created with the merged GeneratorMeta and agent labels. If Parent is set, the parent session's GeneratorMeta is used as defaults (agent fields take precedence). The caller can then use the returned text and tools with the Chat endpoint.
func (CreateAgentSessionRequest) String ¶
func (r CreateAgentSessionRequest) String() string
type CreateAgentSessionResponse ¶
type CreateAgentSessionResponse struct {
Session string `json:"session"` // Created session ID
Text string `json:"text"` // Rendered template text (first user message)
Tools []string `json:"tools,omitempty"` // Tool names the agent is allowed to use
}
CreateAgentSessionResponse is the result of creating a session from an agent. It contains the session ID plus the prepared text and tools, which can be passed directly to a ChatRequest.
func (CreateAgentSessionResponse) String ¶
func (r CreateAgentSessionResponse) String() string
type CreateConnectorUnauthorizedResponse ¶
type CreateConnectorUnauthorizedResponse struct {
}
CreateConnectorUnauthorizedResponse is placed in the HTTP error detail when connector authorization is required before registration can complete.
func (CreateConnectorUnauthorizedResponse) String ¶
func (c CreateConnectorUnauthorizedResponse) String() string
type Credential ¶
type Credential struct {
CredentialKey
CreatedAt time.Time `json:"created_at" help:"Creation timestamp" readonly:""`
}
Credential is the public credential row returned from the database. Secret material and passphrase version are intentionally excluded.
func (*Credential) Scan ¶
func (c *Credential) Scan(row pg.Row) error
Expected column order: url, user, created_at.
func (Credential) String ¶
func (c Credential) String() string
type CredentialInsert ¶
type CredentialInsert struct {
CredentialKey
Credentials []byte `json:"credentials" help:"Encrypted credential payload"`
}
CredentialInsert contains the values required to insert a credential row. The returned Credential omits PV and Credentials.
func (CredentialInsert) RedactedString ¶
func (c CredentialInsert) RedactedString() string
func (CredentialInsert) String ¶
func (c CredentialInsert) String() string
type CredentialKey ¶
type DeleteModelRequest ¶
type DeleteModelRequest struct {
Provider string `json:"provider,omitempty" help:"Provider name" optional:""`
Name string `json:"name" help:"Model name to delete"`
}
DeleteModelRequest represents a request to delete a model
func (DeleteModelRequest) String ¶
func (r DeleteModelRequest) String() string
type DownloadModelRequest ¶
type DownloadModelRequest struct {
Provider string `json:"provider,omitempty" help:"Provider name" optional:""`
Name string `json:"name" help:"Model name to download"`
}
DownloadModelRequest represents a request to download a model
func (DownloadModelRequest) String ¶
func (r DownloadModelRequest) String() string
type EmbeddingRequest ¶
type EmbeddingRequest struct {
Provider string `json:"provider,omitempty" help:"Provider name" optional:""`
Model string `json:"model,omitempty" help:"Model name" optional:""`
Input []string `json:"input,omitempty" arg:"" help:"Text inputs to embed" optional:""`
TaskType string `` /* 244-byte string literal not displayed */
Title string `json:"title,omitempty" help:"Document title, used with RETRIEVAL_DOCUMENT task type (Google-specific)"`
OutputDimensionality uint `json:"output_dimensionality,omitempty" help:"Truncate embedding to this many dimensions (Google-specific)"`
}
EmbeddingRequest represents a request to embed text
func (EmbeddingRequest) String ¶
func (r EmbeddingRequest) String() string
type EmbeddingResponse ¶
type EmbeddingResponse struct {
EmbeddingRequest
Output [][]float64 `json:"output,omitempty"`
Usage *UsageMeta `` /* 127-byte string literal not displayed */
}
EmbeddingResponse represents a response from an embedding request
func (EmbeddingResponse) String ¶
func (r EmbeddingResponse) String() string
type GeneratorMeta ¶
type GeneratorMeta struct {
Provider *string `json:"provider,omitempty" yaml:"provider" help:"Provider name" optional:"" example:"ollama"`
Model *string `json:"model,omitempty" yaml:"model" help:"Model name" optional:"" example:"llama3.2"`
SystemPrompt *string `` /* 133-byte string literal not displayed */
MaxTokens *uint `json:"max_tokens,omitempty" yaml:"max_tokens" help:"Maximum output tokens to generate" optional:"" example:"4096"`
Format JSONSchema `` /* 173-byte string literal not displayed */
Thinking *bool `json:"thinking,omitempty" yaml:"thinking" help:"Enable thinking/reasoning" optional:"" negatable:"" example:"true"`
ThinkingBudget *uint `` /* 157-byte string literal not displayed */
}
GeneratorMeta represents generator settings which are persisted on a session as URL-style values within the session meta object.
func GeneratorMetaFromValues ¶
func GeneratorMetaFromValues(values url.Values) GeneratorMeta
GeneratorMetaFromValues decodes generator settings from session meta values.
func MergeGeneratorMeta ¶
func MergeGeneratorMeta(primary, fallback GeneratorMeta) GeneratorMeta
MergeGeneratorMeta fills nil fields in primary from fallback.
func (GeneratorMeta) IsZero ¶
func (g GeneratorMeta) IsZero() bool
IsZero reports whether all generator fields are unset.
func (GeneratorMeta) MergeFrom ¶
func (g GeneratorMeta) MergeFrom(override GeneratorMeta) GeneratorMeta
MergeFrom returns a new GeneratorMeta using the receiver as the base and filling in any non-blank fields from override.
func (GeneratorMeta) String ¶
func (g GeneratorMeta) String() string
func (GeneratorMeta) Values ¶
func (g GeneratorMeta) Values() url.Values
Values encodes generator settings as URL values so they can be stored in a session meta JSON object.
type GetModelRequest ¶
type GetModelRequest struct {
Provider string `json:"provider,omitempty" help:"Filter by provider name" optional:""`
Name string `json:"name,omitempty" help:"Model name"`
}
GetModelRequest represents a request to get a model
func (GetModelRequest) String ¶
func (r GetModelRequest) String() string
type JSONSchema ¶
type JSONSchema json.RawMessage
JSONSchema is a JSON-encoded schema that supports unmarshalling from both JSON and YAML sources. When unmarshalling from YAML, the YAML node is first decoded to a native Go value and then marshalled to JSON bytes.
func NewJSONSchema ¶
func NewJSONSchema(data json.RawMessage) JSONSchema
NewJSONSchema creates a JSONSchema from raw JSON bytes.
func (JSONSchema) Bytes ¶
func (s JSONSchema) Bytes() []byte
Bytes returns the underlying JSON bytes.
func (JSONSchema) MarshalJSON ¶
func (s JSONSchema) MarshalJSON() ([]byte, error)
func (*JSONSchema) UnmarshalJSON ¶
func (s *JSONSchema) UnmarshalJSON(data []byte) error
func (*JSONSchema) UnmarshalYAML ¶
func (s *JSONSchema) UnmarshalYAML(node *yaml.Node) error
type ListAgentRequest ¶
type ListAgentRequest struct {
Name string `json:"name,omitempty" help:"Filter by agent name" optional:""`
Version *uint `json:"version,omitempty" help:"Filter by version number (requires name)" optional:""`
Limit *uint `json:"limit,omitempty" help:"Maximum number of agents to return" default:"100"`
Offset uint `json:"offset,omitempty" help:"Offset for pagination" default:"0"`
}
ListAgentRequest represents a request to list agents
func (ListAgentRequest) String ¶
func (r ListAgentRequest) String() string
type ListAgentResponse ¶
type ListAgentResponse struct {
Count uint `json:"count"`
Offset uint `json:"offset,omitzero"`
Limit *uint `json:"limit,omitzero"`
Body []*Agent `json:"body,omitzero"`
}
ListAgentResponse represents a response containing a list of agents
func (ListAgentResponse) String ¶
func (r ListAgentResponse) String() string
type ListModelsRequest ¶ added in v0.4.5
type ListModelsRequest struct {
pg.OffsetLimit
}
List models request and response
type ListModelsResponse ¶ added in v0.4.5
type ListModelsResponse struct {
ListModelsRequest
Count uint `json:"count"`
Body []*Model `json:"models"`
}
func (ListModelsResponse) String ¶ added in v0.4.5
func (m ListModelsResponse) String() string
type Message ¶
type Message struct {
ID uint64 `json:"id,omitempty" help:"Monotonic message row ID" example:"42"`
Session uuid.UUID `json:"session,omitzero" help:"Session owning the message" optional:""`
Role string `json:"role" help:"Message role" enum:"user,assistant,system,thinking,tool" example:"assistant"`
Content []ContentBlock `` /* 162-byte string literal not displayed */
Tokens uint `json:"tokens,omitempty" help:"Token count attributed to this message" example:"12"`
Result ResultType `` /* 153-byte string literal not displayed */
Meta map[string]any `` /* 129-byte string literal not displayed */
}
Message represents a message in a conversation with an LLM. It uses a universal content block representation that can be marshaled to any provider's format.
func NewMessage ¶
Create a new message with the given role and text content
func (Message) EstimateTokens ¶
EstimateTokens returns a rough token count for the message content. It estimates ~4 characters per token for text, plus a fixed cost per non-text block (attachments, tool calls/results). This is useful for attributing per-message token costs without a provider-specific tokeniser.
func (Message) Text ¶
Text returns the concatenated text content from all text blocks in the message
type MessageInsert ¶
type MessageInsert struct {
Session uuid.UUID `json:"session" help:"Session ID"`
Message `embed:""`
}
MessageInsert persists a message within a session conversation.
type MessageList ¶
type MessageList struct {
MessageListRequest
Count uint `json:"count" help:"Total number of matching messages" example:"2"`
Body []*Message `` /* 184-byte string literal not displayed */
}
MessageList represents a paginated list of stored messages.
func (MessageList) String ¶
func (r MessageList) String() string
type MessageListRequest ¶
type MessageListRequest struct {
pg.OffsetLimit
Sessions []uuid.UUID `json:"-"`
Last uint64 `json:"-"`
Until uint64 `json:"-"`
Role string `json:"role,omitempty" help:"Filter by exact message role" optional:""`
Text string `json:"text,omitempty" help:"Case-insensitive text search over message content" optional:""`
}
MessageListRequest represents a request to list stored messages.
func (MessageListRequest) Query ¶
func (req MessageListRequest) Query() url.Values
func (MessageListRequest) String ¶
func (r MessageListRequest) String() string
type Model ¶
type Model struct {
Name string `json:"name,omitzero"`
Description string `json:"description,omitzero"`
Created time.Time `json:"created,omitzero"`
OwnedBy string `json:"owned_by,omitzero"` // Model provider
Aliases []string `json:"aliases,omitzero"` // Model aliases
Meta map[string]any `json:"meta,omitzero"` // Provider-specific metadata
InputTokenLimit *uint `json:"input_token_limit,omitzero"` // Input token limit (optional)
OutputTokenLimit *uint `json:"output_token_limit,omitzero"` // Output token limit (optional)
Cap ModelCap `json:"capabilities,omitzero"` // Model capabilities (optional)
}
Represents an LLM model
type ModelList ¶
type ModelList struct {
ModelListRequest
Provider []string `json:"provider,omitempty"`
Count uint `json:"count"`
Body []Model `json:"body,omitzero"`
}
ModelList represents a response containing a list of models and providers
type ModelListRequest ¶
type ModelListRequest struct {
pg.OffsetLimit
Provider string `json:"provider,omitempty" help:"Filter by provider name" optional:""`
}
ModelListRequest represents a request to list models
func (ModelListRequest) Query ¶
func (r ModelListRequest) Query() url.Values
func (ModelListRequest) String ¶
func (r ModelListRequest) String() string
type ModelNameSelector ¶
type ModelNameSelector struct {
Name string `json:"name" help:"Model name"`
}
ModelNameSelector selects a model by name for path-based GET operations.
type ModelProviderSelector ¶
type ModelProviderSelector struct {
Provider string `json:"provider" help:"Provider name"`
Name string `json:"name" help:"Model name"`
}
ModelProviderSelector selects a model by provider and name for path-based GET operations.
type MultipartAskRequest ¶
type MultipartAskRequest struct {
AskRequest
File types.File `json:"file,omitempty" help:"File attachment (multipart upload)" optional:""`
}
MultipartAskRequest is the HTTP-layer request type supporting both JSON (with base64 attachments) and multipart/form-data file uploads.
func (*MultipartAskRequest) FileAttachment ¶
func (r *MultipartAskRequest) FileAttachment() (*Attachment, error)
FileAttachment reads the multipart file (if present) and returns it as an Attachment with auto-detected MIME type. Returns nil if no file was uploaded.
type OAuthCredentials ¶
type OAuthCredentials struct {
*oauth2.Token
// ClientID is the OAuth client ID used to obtain this token.
ClientID string `json:"client_id"`
// ClientSecret is the OAuth client secret, if any (for confidential clients).
// Needed for token refresh with servers that require client authentication.
ClientSecret string `json:"client_secret,omitempty"`
// Endpoint is the MCP/OAuth server endpoint (used for discovery).
Endpoint string `json:"endpoint"`
// TokenURL is the OAuth token endpoint URL (used for refresh without re-discovery).
TokenURL string `json:"token_url"`
}
OAuthCredentials bundles an OAuth token with the metadata needed to refresh or reuse it later without re-discovering or re-registering.
type ProgressEvent ¶
ProgressEvent is sent during a streaming model download.
type Provider ¶
type Provider struct {
Name string `json:"name" help:"Unique provider name"`
Provider string `json:"provider" help:"Provider identifier"`
CreatedAt time.Time `json:"created_at" help:"Creation timestamp"`
ModifiedAt *time.Time `json:"modified_at,omitempty" help:"Last modification timestamp" optional:""`
ProviderMeta
}
Provider is the persisted representation of a provider row.
type ProviderCredentials ¶
type ProviderCredentials struct {
APIKey string `json:"api_key,omitempty" name:"api-key" help:"Provider API key" optional:"" env:"LLM_PROVIDER_API_KEY"`
}
ProviderCredentials contains the secret material used to access a provider.
func (ProviderCredentials) String ¶
func (p ProviderCredentials) String() string
type ProviderGroupList ¶
type ProviderGroupList []string
ProviderGroupList is a list of auth group identifiers associated with a provider.
type ProviderGroupRef ¶
ProviderGroupRef represents a single provider-to-group link.
type ProviderGroupSelector ¶
ProviderGroupSelector selects provider_group rows for a provider, optionally scoped to a single group.
type ProviderInsert ¶
type ProviderInsert struct {
Name string `json:"name" arg:"" name:"name" help:"Unique provider name"`
Provider string `json:"provider" name:"provider" help:"Provider identifier"`
ProviderMeta
ProviderCredentials
}
ProviderInsert contains the fields required to insert a new provider row.
func (ProviderInsert) Insert ¶
func (p ProviderInsert) Insert(bind *pg.Bind) (string, error)
Insert binds all required provider fields for an INSERT and returns the named query.
func (ProviderInsert) String ¶
func (p ProviderInsert) String() string
type ProviderList ¶
type ProviderList struct {
ProviderListRequest
Count uint64 `json:"count" readonly:""`
Body []*Provider `json:"body,omitempty"`
}
ProviderList represents a paginated list of providers.
func (ProviderList) String ¶
func (p ProviderList) String() string
type ProviderListRequest ¶
type ProviderListRequest struct {
pg.OffsetLimit
Name string `json:"name,omitempty" name:"name" help:"Filter by provider name" optional:""`
Provider string `json:"provider,omitempty" name:"provider" help:"Filter by provider identifier" optional:""`
Enabled *bool `json:"enabled,omitempty" name:"enabled" help:"Filter by enabled state" negatable:""`
Groups []string `json:"groups,omitempty" name:"groups" help:"Filter by accessible groups" optional:""`
}
ProviderListRequest contains pagination for listing providers.
func (ProviderListRequest) Query ¶
func (req ProviderListRequest) Query() url.Values
func (ProviderListRequest) String ¶
func (p ProviderListRequest) String() string
type ProviderMeta ¶
type ProviderMeta struct {
URL *string `json:"url,omitempty" name:"url" help:"Provider endpoint URL" optional:""`
Enabled *bool `json:"enabled,omitempty" name:"enabled" help:"Enable the provider" negatable:""`
Include []string `json:"include,omitempty" name:"include" help:"List of models to include (regular expressions)" optional:""`
Exclude []string `json:"exclude,omitempty" name:"exclude" help:"List of models to exclude (regular expressions)" optional:""`
Groups []string `json:"groups,omitempty" name:"groups" help:"Groups with access to this provider" optional:""`
Meta ProviderMetaMap `json:"meta,omitempty" name:"meta" help:"Provider metadata as a JSON object" optional:""`
}
ProviderMeta contains the user-writable fields for an existing provider row. The provider kind itself is immutable after creation and is stored on Provider.
func (ProviderMeta) HasTableUpdates ¶
func (p ProviderMeta) HasTableUpdates() bool
HasTableUpdates reports whether ProviderMeta includes fields stored on the provider table itself.
func (ProviderMeta) Insert ¶
func (p ProviderMeta) Insert(_ *pg.Bind) (string, error)
Insert is not supported for ProviderMeta.
func (ProviderMeta) String ¶
func (p ProviderMeta) String() string
type ProviderMetaMap ¶
func (*ProviderMetaMap) UnmarshalJSON ¶
func (m *ProviderMetaMap) UnmarshalJSON(data []byte) error
func (*ProviderMetaMap) UnmarshalText ¶
func (m *ProviderMetaMap) UnmarshalText(text []byte) error
type ProviderNameSelector ¶
type ProviderNameSelector string
ProviderNameSelector selects a provider by name for get, update, and delete operations.
type ResultType ¶
type ResultType uint
The result of generating a message (stopped, error, etc.)
const ( ResultStop ResultType = iota // Normal completion ResultMaxTokens // Truncated due to max tokens ResultBlocked // Blocked by safety, recitation, or content filter ResultToolCall // Model requested a tool call ResultError // Generation error ResultOther // Other/unknown finish reason ResultMaxIterations // Tool-calling loop exhausted max iterations )
func (ResultType) MarshalJSON ¶
func (r ResultType) MarshalJSON() ([]byte, error)
func (ResultType) String ¶
func (r ResultType) String() string
func (*ResultType) UnmarshalJSON ¶
func (r *ResultType) UnmarshalJSON(data []byte) error
type Session ¶
type Session struct {
ID uuid.UUID `json:"id"`
User uuid.UUID `json:"user" help:"User owning the session"`
SessionInsert
Input uint `json:"input,omitempty" help:"Cumulative input message tokens for the session"`
Output uint `json:"output,omitempty" help:"Cumulative output message tokens for the session"`
Overhead uint `json:"overhead,omitempty" help:"Cumulative non-message input token cost observed across the session"`
CreatedAt time.Time `json:"created_at" help:"Creation timestamp"`
ModifiedAt *time.Time `json:"modified_at,omitempty" help:"Last modification timestamp" optional:""`
}
Session represents a stored conversation with an LLM.
func (Session) Generator ¶
func (s Session) Generator() GeneratorMeta
Generator returns the session generator settings.
func (Session) MarshalJSON ¶
MarshalJSON omits User and Parent when they are the zero UUID.
func (*Session) Scan ¶
Expected column order: id, parent, user, title, input, output, overhead, meta, tags, created_at, modified_at.
type SessionChannelRequest ¶
type SessionChannelRequest struct {
Text string `json:"text" arg:"" help:"User input text"`
Tools []string `json:"tools,omitzero" help:"Tool names to include (nil means all, empty means none)" optional:""`
MaxIterations uint `json:"max_iterations,omitempty" help:"Maximum tool-calling iterations (0 uses default)" optional:""`
SystemPrompt string `json:"system_prompt,omitempty" help:"Per-request system prompt appended to the session prompt" optional:""`
}
SessionChannelRequest represents one inbound channel frame for a session. The session is selected by the path parameter, not the frame body.
func (SessionChannelRequest) String ¶
func (r SessionChannelRequest) String() string
type SessionIDSelector ¶
SessionIDSelector selects a session by ID for get, update, and delete operations.
type SessionInsert ¶
type SessionInsert struct {
Parent uuid.UUID `json:"parent,omitempty" help:"Parent session for threading" optional:""`
SessionMeta
}
func (SessionInsert) String ¶
func (s SessionInsert) String() string
type SessionList ¶
type SessionList struct {
SessionListRequest
Count uint `json:"count"`
Body []*Session `json:"body,omitzero"`
}
SessionList represents a response containing a list of sessions.
func (SessionList) String ¶
func (s SessionList) String() string
type SessionListRequest ¶
type SessionListRequest struct {
pg.OffsetLimit
Parent *uuid.UUID `json:"parent,omitzero" help:"Filter by parent session ID" optional:""`
User *uuid.UUID `json:"user,omitzero" help:"Filter by user ID" optional:""`
Title *string `json:"title,omitempty" help:"Filter by session title (partial match)" optional:""`
Tags []string `json:"tags,omitempty" help:"Filter by tags (sessions must contain all specified tags)" optional:""`
}
SessionListRequest represents a request to list sessions.
func (SessionListRequest) Query ¶
func (req SessionListRequest) Query() url.Values
func (SessionListRequest) String ¶
func (s SessionListRequest) String() string
type SessionMeta ¶
type SessionMeta struct {
GeneratorMeta
Title *string `json:"title,omitempty" help:"Session title" optional:""`
Tags []string `json:"tags,omitempty" help:"User-defined tags" optional:""`
}
SessionMeta represents the metadata for a session.
func (SessionMeta) Generator ¶
func (s SessionMeta) Generator() GeneratorMeta
Generator returns the session generator settings.
func (SessionMeta) String ¶
func (s SessionMeta) String() string
type SessionOverheadSelector ¶
SessionOverheadSelector selects a session row for overhead-only updates.
type SessionOverheadUpdate ¶
type SessionOverheadUpdate struct {
Increment uint `json:"increment,omitempty"`
}
SessionOverheadUpdate increments the cumulative session overhead.
type StreamDelta ¶
StreamDelta represents a single streamed text chunk in an SSE stream.
type StreamError ¶
type StreamError struct {
Error string `json:"error"`
}
StreamError represents an error event in an SSE stream.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id,omitempty" help:"Provider-assigned tool call identifier" example:"call_123"`
Name string `json:"name" help:"Tool name to invoke" example:"get_weather"`
Input json.RawMessage `json:"input,omitempty" help:"JSON-encoded arguments passed to the tool" example:"{\"city\":\"London\"}"`
Meta map[string]any `json:"meta,omitempty" help:"Provider-specific metadata associated with the tool call" example:"{\"provider\":\"demo\"}"`
}
ToolCall represents a tool invocation requested by the model
type ToolList ¶
type ToolList struct {
ToolListRequest
Count uint `json:"count" help:"Total number of matching tools" example:"2"`
Body []*ToolMeta `` /* 144-byte string literal not displayed */
}
ToolList represents a response containing a list of tools.
type ToolListRequest ¶
type ToolListRequest struct {
pg.OffsetLimit
// Namespace restricts results to a single namespace.
// Use BuiltinNamespace for locally-implemented tools, a connector URL for
// remote tools, or leave empty to include all namespaces.
Namespace string `json:"namespace,omitempty" help:"Restrict results to a single namespace" example:"builtin"`
// Name restricts results to tools whose names appear in this list.
// An empty slice means no name filter — all names are included.
Name []string `` /* 128-byte string literal not displayed */
}
ToolListRequest represents a request to list tools
func (ToolListRequest) Query ¶
func (r ToolListRequest) Query() url.Values
func (ToolListRequest) String ¶
func (r ToolListRequest) String() string
type ToolMeta ¶
type ToolMeta struct {
Name string `json:"name" help:"Fully-qualified tool name" example:"builtin.search_docs"`
Title string `json:"title,omitempty" help:"Human-readable tool title" example:"Search Docs"`
Description string `` /* 126-byte string literal not displayed */
Input JSONSchema `` /* 148-byte string literal not displayed */
Output JSONSchema `` /* 151-byte string literal not displayed */
Hints []string `json:"hints,omitempty" help:"Additional usage hints for the tool" example:"[\"read_only\"]"`
}
ToolMeta represents a tool's metadata.
type ToolResult ¶
type ToolResult struct {
ID string `json:"id,omitempty" help:"Tool call identifier this result belongs to" example:"call_123"`
Name string `json:"name,omitempty" help:"Tool name that produced this result" example:"get_weather"`
Content json.RawMessage `json:"content,omitempty" help:"JSON-encoded tool output content" example:"{\"temperature_c\":18}"`
IsError bool `json:"is_error,omitempty" help:"Whether the tool result represents an error" example:"false"`
}
ToolResult represents the result of running a tool
type Usage ¶
type Usage struct {
ID uint64 `json:"id,omitempty" help:"Usage record identifier" readonly:""`
UsageInsert `embed:""`
CreatedAt time.Time `json:"created_at,omitempty" help:"Creation timestamp" readonly:""`
}
type UsageInsert ¶
type UsageInsert struct {
Type UsageType `json:"type,omitempty" help:"Usage category" example:"ask"`
Batch *string `json:"batch,omitempty" help:"Optional batch identifier for batch operations" optional:""`
User uuid.UUID `json:"user,omitempty" help:"Optional user ID for attribution" optional:""`
Session uuid.UUID `json:"session,omitempty" help:"Optional session ID for chat interactions" optional:""`
Provider *string `json:"provider,omitempty" help:"Optional provider name for attribution" optional:""`
Model string `json:"model,omitempty" help:"Model name associated with the usage record" example:"gemini-2.5-pro"`
UsageMeta `embed:""`
}
type UsageMeta ¶
type UsageMeta struct {
InputTokens uint `json:"input_tokens,omitempty" help:"Number of input tokens consumed by the request" example:"18"`
OutputTokens uint `json:"output_tokens,omitempty" help:"Number of output tokens generated by the model" example:"12"`
CacheReadTokens uint `json:"cache_read_tokens,omitempty" help:"Number of tokens read from cache" example:"5"`
CacheWriteTokens uint `json:"cache_write_tokens,omitempty" help:"Number of tokens written to cache" example:"3"`
ReasoningTokens uint `json:"reasoning_tokens,omitempty" help:"Number of tokens used for reasoning" example:"2"`
Meta ProviderMetaMap `json:"meta,omitempty" help:"Optional provider-specific metadata for usage records" optional:""`
}