httpclient

package
v1.3.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: 12 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 httpclient is a client of the registry's HTTP API

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*client.Client
}

Client is a client of the registry's HTTP API, which wraps the base HTTP client, with typed methods for its requests

func New

func New(url string, opts ...client.ClientOpt) (*Client, error)

New returns a client of the registry's API, at the URL, which is the server's API endpoint, such as http://localhost:8084/api, with the options. Each method adds its own path, such as llm/provider, as the registry's handlers register them.

func (*Client) Ask

Ask returns the reply of the request's model to its messages, with the tools it called, for the caller to run, the reply's result, when the request has a schema, and the tokens used. When the stream function isn't nil, the reply is streamed, and the function is called with each piece of its text and thinking as it's generated. The request isn't timed out, as a model can take a while to reply, but is cancelled with the context.

func (*Client) Chat added in v0.6.0

Chat adds the messages to the session with the identifier, which its model replies to, running the tools it calls, and returns what was added, with the model's reply, and the tokens used. When the stream function isn't nil, the reply is streamed, and the function is called with each piece of its text and thinking, and the tools' log lines, as they're generated. The request isn't timed out, as a model can take a while to reply, but is cancelled with the context.

func (*Client) CreateAgent added in v0.6.0

func (c *Client) CreateAgent(ctx context.Context, meta schema.AgentMeta) (*schema.Agent, error)

CreateAgent creates an agent with the definition, and returns it

func (*Client) CreateProvider

func (c *Client) CreateProvider(ctx context.Context, provider schema.Provider) (*schema.ProviderStatus, error)

CreateProvider creates a provider of the type, with its name, endpoint and API key, which can be a credential's placeholder, such as ${OPENAI_KEY}, and returns it, once it's reached

func (*Client) CreateSession added in v0.6.0

func (c *Client) CreateSession(ctx context.Context, meta schema.SessionMeta) (*schema.Session, error)

CreateSession creates a session with the settings, and no messages, and returns it

func (*Client) DeleteAgent added in v0.6.0

func (c *Client) DeleteAgent(ctx context.Context, name string) (*schema.Agent, error)

DeleteAgent deletes the agent with the name, and returns it, as it was

func (*Client) DeleteEvent added in v1.2.0

func (c *Client) DeleteEvent(ctx context.Context, id uuid.UUID) (*schema.Event, error)

DeleteEvent deletes the outcome of the event with the identifier, and returns it, as it was

func (*Client) DeleteModel

func (c *Client) DeleteModel(ctx context.Context, name string) (*schema.Model, error)

DeleteModel deletes the model with the name, or alias, or provider and name, such as my-ollama:gemma:latest, from its provider's storage, and returns it

func (*Client) DeleteProvider

func (c *Client) DeleteProvider(ctx context.Context, name string) (*schema.ProviderStatus, error)

DeleteProvider deletes the provider with the name from the registry, and returns it

func (*Client) DeleteSession added in v0.6.0

func (c *Client) DeleteSession(ctx context.Context, id uuid.UUID) (*schema.Session, error)

DeleteSession deletes the session with the identifier, and returns it

func (*Client) Embed

Embed returns a vector for each of the messages in the request, in the same order, from its model, with the model's canonical name, and the tokens used. A model is its name, or the provider and name separated by ":", such as "ollama:embeddinggemma-2:latest". The request isn't timed out, as a model can take a while to load, but is cancelled with the context.

func (*Client) ForgetSessionMessages added in v1.0.0

func (c *Client) ForgetSessionMessages(ctx context.Context, id uuid.UUID) (*schema.Session, error)

ForgetSessionMessages forgets the messages of the session with the identifier, keeping its settings, and returns it

func (*Client) GetAgent added in v0.6.0

func (c *Client) GetAgent(ctx context.Context, name string) (*schema.Agent, error)

GetAgent returns the agent with the name

func (*Client) GetEvent added in v1.2.0

func (c *Client) GetEvent(ctx context.Context, id uuid.UUID) (*schema.Event, error)

GetEvent returns the outcome of the event with the identifier

func (*Client) GetModel

func (c *Client) GetModel(ctx context.Context, name string) (*schema.Model, error)

GetModel returns the model with the name, or alias, or provider and name, separated by a colon, such as my-ollama:llama3.2:latest. The name is one segment of the path, so a "/" in it is escaped.

func (*Client) GetProvider

func (c *Client) GetProvider(ctx context.Context, name string) (*schema.ProviderStatus, error)

GetProvider returns the provider with the name, with whether it can be reached

func (*Client) GetSession added in v0.6.0

func (c *Client) GetSession(ctx context.Context, id uuid.UUID) (*schema.Session, error)

GetSession returns the session with the identifier, without its messages, which ListSessionMessages lists

func (*Client) ListAgents added in v0.6.0

func (c *Client) ListAgents(ctx context.Context, req schema.AgentListRequest) (*schema.AgentList, error)

ListAgents returns the agents, in the server's order, as the request selects, and how many there are

func (*Client) ListEvents added in v1.2.0

func (c *Client) ListEvents(ctx context.Context, req schema.EventListRequest) (*schema.EventList, error)

ListEvents returns the outcomes of events, the most recent first, as the request selects, and how many there are

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, req schema.ModelListRequest) (*schema.ModelList, error)

ListModels returns the models of the providers, or of the provider which the request selects, in order of their providers' names, and then their names

func (*Client) ListProviders

func (c *Client) ListProviders(ctx context.Context, req schema.ProviderListRequest) (*schema.ProviderList, error)

ListProviders returns the providers, in order of their names, of the type which the request selects, or every type, with whether each can be reached

func (*Client) ListSessionMessages added in v0.6.0

func (c *Client) ListSessionMessages(ctx context.Context, id uuid.UUID, req schema.MessageListRequest) (*schema.MessageList, error)

ListSessionMessages returns the messages of the session with the identifier, oldest first, as the request selects, and how many there are

func (*Client) ListSessions added in v0.6.0

func (c *Client) ListSessions(ctx context.Context, req schema.SessionListRequest) (*schema.SessionList, error)

ListSessions returns the sessions, without their messages, most recently modified first, as the request selects, and how many there are

func (*Client) LoadModel

func (c *Client) LoadModel(ctx context.Context, req schema.LoadModelRequest, progress llm.DownloadProgressFn) (*schema.Model, error)

LoadModel loads the model in the request, with its provider, or the one provider which loads models, which downloads it when it isn't stored, and returns it. Loading isn't timed out, as models can be large, but is cancelled with the context. When the progress function isn't nil, the download's progress is streamed, and the function is called with each progress event.

func (*Client) ReadAgentYAML added in v0.6.0

func (c *Client) ReadAgentYAML(ctx context.Context, name string, w io.Writer) error

ReadAgentYAML writes the definition of the agent with the name to the writer, as YAML, as a file of it is, which WriteAgentYAML can create again

func (*Client) Recognize

Recognize returns the text in the image or document of the request, as a message with a text block for each page, in order, from its model, with the model's canonical name, and the pages and tokens used. A model is its name, or the provider and name separated by ":", such as "mistral:mistral-ocr-latest". The request isn't timed out, as a document can take a while, but is cancelled with the context.

func (*Client) SetSessionStatus added in v0.6.0

func (c *Client) SetSessionStatus(ctx context.Context, id uuid.UUID, status schema.SessionStatus) (*schema.Session, error)

SetSessionStatus sets the status of the session with the identifier, to typing, as someone types a message, which it is for a while after, or idle, when they stop, and returns the session, with its status

func (*Client) Speak added in v1.3.0

Speak writes the request's text, spoken by its model, which is found by its name, or the provider and name separated by ":", such as "ollama:phonon:latest", as audio, to the writer, as it's read, and returns its type, such as audio/wav, and the model which spoke it, and the usage. The request isn't timed out, as speaking a long text can take a while.

func (*Client) Transcribe

Transcribe returns the speech in the audio of the request, as text, in the language it was spoken in, and its segments, when they're asked for, from its model, with the model's canonical name, and the seconds and tokens used. A model is its name, or the provider and name separated by ":", such as "openai:whisper-1". When the stream function isn't nil, the transcript is streamed, and the function is called with each piece of its text, and each segment, when they're asked for. The request isn't timed out, as audio can take a while, but is cancelled with the context.

func (*Client) Translate

Translate returns the speech in the audio of the request, in any language, as English text, as Transcribe does

func (*Client) TriggerEvent added in v1.2.0

func (c *Client) TriggerEvent(ctx context.Context, req schema.EventRequest) (*schema.TriggerEventResponse, error)

TriggerEvent schedules the event, from a source other than a heartbeat, such as a file which changed, to run, and returns whether it's scheduled, rather than an event of its source, which is already, and its outcome, which is scheduled, until it's run

func (*Client) UnloadModel

func (c *Client) UnloadModel(ctx context.Context, name string) (*schema.Model, error)

UnloadModel unloads the model with the name, or alias, or provider and name, such as my-ollama:gemma:latest, from its provider's memory, keeping it stored, and returns it. The name is one segment of the path, so a "/" in it is escaped.

func (*Client) UpdateAgent added in v0.6.0

func (c *Client) UpdateAgent(ctx context.Context, name string, meta schema.AgentMeta) (*schema.Agent, error)

UpdateAgent changes the definition of the agent with the name: what the update sets is changed, and the rest kept. Returns the agent.

func (*Client) UpdateProvider

func (c *Client) UpdateProvider(ctx context.Context, name string, meta schema.ProviderMeta) (*schema.ProviderStatus, error)

UpdateProvider replaces the fields of the provider with the name with the meta, keeping its API key when the meta has none, and returns it

func (*Client) UpdateSession added in v0.6.0

func (c *Client) UpdateSession(ctx context.Context, id uuid.UUID, meta schema.SessionMeta) (*schema.Session, error)

UpdateSession changes the settings of the session with the identifier, as SessionMeta.Merge does, so what the update doesn't set is kept, and returns it

func (*Client) WriteAgentYAML added in v0.6.0

func (c *Client) WriteAgentYAML(ctx context.Context, r io.Reader) (*schema.Agent, error)

WriteAgentYAML creates an agent with the definition which is read from the reader, which is YAML, such as a file of an agent's definition, which the server parses, and returns it

Jump to

Keyboard shortcuts

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