httpclient

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: Apache-2.0 Imports: 10 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) 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) WatchEvents

func (c *Client) WatchEvents(ctx context.Context, fn func(providerschema.Event) error) error

WatchEvents calls the function with each of the registry's events, as the server streams them, such as when a provider is created, updated or deleted, until the context is cancelled, when it returns nil, or the function returns an error, which it returns, or the stream ends. When the server stops, it returns ErrServiceUnavailable.

Jump to

Keyboard shortcuts

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