Documentation
¶
Index ¶
- func WithLabel(key, value string) opt.Opt
- func WithLimit(limit *uint) opt.Opt
- func WithOffset(offset uint) opt.Opt
- func WithProvider(provider string) opt.Opt
- type AskOpt
- type ChatOpt
- type Client
- func (c *Client) Ask(ctx context.Context, req schema.AskRequest, opts ...AskOpt) (*schema.AskResponse, error)
- func (c *Client) Chat(ctx context.Context, req schema.ChatRequest, opts ...ChatOpt) (*schema.ChatResponse, error)
- func (c *Client) CreateSession(ctx context.Context, meta schema.SessionMeta) (*schema.Session, error)
- func (c *Client) DeleteSession(ctx context.Context, id string) error
- func (c *Client) Embedding(ctx context.Context, req schema.EmbeddingRequest) (*schema.EmbeddingResponse, error)
- func (c *Client) GetModel(ctx context.Context, name string, opts ...opt.Opt) (*schema.Model, error)
- func (c *Client) GetSession(ctx context.Context, id string) (*schema.Session, error)
- func (c *Client) GetTool(ctx context.Context, name string) (*schema.ToolMeta, error)
- func (c *Client) ListModels(ctx context.Context, opts ...opt.Opt) (*schema.ListModelsResponse, error)
- func (c *Client) ListSessions(ctx context.Context, opts ...opt.Opt) (*schema.ListSessionResponse, error)
- func (c *Client) ListTools(ctx context.Context, opts ...opt.Opt) (*schema.ListToolResponse, error)
- func (c *Client) UpdateSession(ctx context.Context, id string, meta schema.SessionMeta) (*schema.Session, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithLabel ¶
WithLabel adds a label filter (key:value) for listing sessions. The key must be a valid identifier. Multiple calls accumulate filters.
func WithLimit ¶
WithLimit sets the maximum number of results to return. If limit is nil, any existing limit is removed.
func WithOffset ¶
WithOffset sets the pagination offset. If offset is 0, any existing offset is removed.
func WithProvider ¶
WithProvider filters results by provider name.
Types ¶
type AskOpt ¶
type AskOpt func(*askOptions)
AskOpt is a functional option for the Ask method.
type ChatOpt ¶
type ChatOpt func(*chatOptions)
ChatOpt is a functional option for the Chat method.
func WithChatFile ¶
WithChatFile adds a file attachment to the chat request.
func WithChatStream ¶
WithChatStream enables SSE streaming for the chat request. The callback receives streamed text chunks as they arrive (role and text).
func WithChatURL ¶
WithChatURL adds a URL-referenced attachment to the chat request.
type 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 ¶
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) 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) DeleteSession ¶
DeleteSession deletes a session by ID.
func (*Client) Embedding ¶
func (c *Client) Embedding(ctx context.Context, req schema.EmbeddingRequest) (*schema.EmbeddingResponse, error)
Embedding generates embedding vectors for the given text inputs.
func (*Client) GetModel ¶
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 ¶
GetSession retrieves a session by ID.
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.