httpclient

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithLabel

func WithLabel(key, value string) opt.Opt

WithLabel adds a label filter (key:value) for listing sessions. The key must be a valid identifier. Multiple calls accumulate filters.

func WithLimit

func WithLimit(limit *uint) opt.Opt

WithLimit sets the maximum number of results to return. If limit is nil, any existing limit is removed.

func WithName added in v0.3.0

func WithName(name string) opt.Opt

WithName filters results by name.

func WithOffset

func WithOffset(offset uint) opt.Opt

WithOffset sets the pagination offset. If offset is 0, any existing offset is removed.

func WithProvider

func WithProvider(provider string) opt.Opt

WithProvider filters results by provider name.

func WithVersion added in v0.3.0

func WithVersion(version uint) opt.Opt

WithVersion filters results by version number.

Types

type AskOpt

type AskOpt func(*askOptions)

AskOpt is a functional option for the Ask method.

func WithFile

func WithFile(filename string, r io.Reader) AskOpt

///////////////////////////////////////////////////////////////////////////// OPTIONS is the only attachment, it is sent via streaming multipart/form-data.

func WithURL

func WithURL(u string) AskOpt

WithURL adds a URL-referenced attachment to the request.

type ChatOpt

type ChatOpt func(*chatOptions)

ChatOpt is a functional option for the Chat method.

func WithChatFile

func WithChatFile(filename string, r io.Reader) ChatOpt

WithChatFile adds a file attachment to the chat request.

func WithChatStream

func WithChatStream(fn opt.StreamFn) ChatOpt

WithChatStream enables SSE streaming for the chat request. The callback receives streamed text chunks as they arrive (role and text).

func WithChatURL

func WithChatURL(u string) ChatOpt

WithChatURL adds a URL-referenced attachment to the chat request.

type Client

type Client struct {
	*client.Client
}

Client is an LLM HTTP client that wraps the base HTTP client and provides typed methods for interacting with the LLM API.

func New

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

New creates a new LLM HTTP client with the given base URL and options. The url parameter should point to the LLM API endpoint, e.g. "http://localhost:8084/api".

func (*Client) Ask

func (c *Client) Ask(ctx context.Context, req schema.AskRequest, opts ...AskOpt) (*schema.AskResponse, error)

Ask sends a stateless text request with zero or more attachments. Use WithFile to attach file uploads and WithURL to attach URL references. A single file with no other attachments uses streaming multipart/form-data; all other cases use JSON with base64-encoded file data.

func (*Client) Chat

func (c *Client) Chat(ctx context.Context, req schema.ChatRequest, opts ...ChatOpt) (*schema.ChatResponse, error)

Chat sends a message within a session with zero or more attachments. Use WithChatFile to attach file uploads and WithChatURL to attach URL references. A single file with no other attachments uses streaming multipart/form-data; all other cases use JSON with base64-encoded file data.

func (*Client) CreateAgent added in v0.3.0

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

CreateAgent creates a new agent with the given metadata (sent as JSON).

func (*Client) CreateAgentSession added in v0.3.0

func (c *Client) CreateAgentSession(ctx context.Context, agentID string, request schema.CreateAgentSessionRequest) (*schema.CreateAgentSessionResponse, error)

CreateAgentSession creates a new session from an agent definition. The agentID can be an agent ID or name.

func (*Client) CreateSession

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

CreateSession creates a new session with the given metadata.

func (*Client) DeleteAgent added in v0.3.0

func (c *Client) DeleteAgent(ctx context.Context, id string) error

DeleteAgent deletes an agent by ID or name.

func (*Client) DeleteSession

func (c *Client) DeleteSession(ctx context.Context, id string) error

DeleteSession deletes a session by ID.

func (*Client) Embedding

Embedding generates embedding vectors for the given text inputs.

func (*Client) GetAgent added in v0.3.0

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

GetAgent retrieves an agent by ID or name.

func (*Client) GetModel

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

GetModel retrieves a specific model by name, optionally scoped to a provider. If provider is empty, the model is looked up across all providers.

func (*Client) GetSession

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

GetSession retrieves a session by ID.

func (*Client) GetTool

func (c *Client) GetTool(ctx context.Context, name string) (*schema.ToolMeta, error)

GetTool retrieves a specific tool by name.

func (*Client) ListAgents added in v0.3.0

func (c *Client) ListAgents(ctx context.Context, opts ...opt.Opt) (*schema.ListAgentResponse, error)

ListAgents returns a list of all agents. Use WithLimit, WithOffset and WithName to filter and paginate results.

func (*Client) ListModels

func (c *Client) ListModels(ctx context.Context, opts ...opt.Opt) (*schema.ListModelsResponse, error)

ListModels returns a list of all available models. Use WithLimit, WithOffset and WithProvider to paginate and filter results.

func (*Client) ListSessions

func (c *Client) ListSessions(ctx context.Context, opts ...opt.Opt) (*schema.ListSessionResponse, error)

ListSessions returns a list of all sessions. Use WithLimit and WithOffset to paginate results.

func (*Client) ListTools

func (c *Client) ListTools(ctx context.Context, opts ...opt.Opt) (*schema.ListToolResponse, error)

ListTools returns a list of all available tools. Use WithLimit and WithOffset to paginate results.

func (*Client) UpdateAgent added in v0.3.0

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

UpdateAgent updates an existing agent by name (sent as JSON). The agent name in the metadata is used to look up the existing agent.

func (*Client) UpdateSession

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

UpdateSession updates a session's metadata by ID.

Jump to

Keyboard shortcuts

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