Documentation
¶
Overview ¶
Package llmproxyclient provides an HTTP client for llm-proxy v2 JSON POST requests.
Index ¶
- Variables
- type Asset
- type AssetUploadInput
- type AudioAssetAttachmentInput
- type AudioAttachmentInput
- type Client
- type Config
- type ConfigInput
- type HTTPDoer
- type HTTPFailure
- type ImageAssetAttachmentInput
- type ImageAttachmentInput
- type MessageAttachment
- func NewAudioAssetAttachment(input AudioAssetAttachmentInput) (MessageAttachment, error)
- func NewAudioAttachment(input AudioAttachmentInput) (MessageAttachment, error)
- func NewImageAssetAttachment(input ImageAssetAttachmentInput) (MessageAttachment, error)
- func NewImageAttachment(input ImageAttachmentInput) (MessageAttachment, error)
- type MessageInput
- type MessagesRequest
- type MessagesRequestInput
- type ModelProfileReader
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidClientConfig reports invalid llm-proxy client configuration. ErrInvalidClientConfig = errors.New("llm_proxy_client_invalid_config") // ErrInvalidClientRequest reports invalid llm-proxy request input. ErrInvalidClientRequest = errors.New("llm_proxy_client_invalid_request") // ErrInvalidModelProfile reports an unreadable or invalid model-profile document. ErrInvalidModelProfile = errors.New("llm_proxy_client_invalid_model_profile") // ErrClientHTTPFailure reports an unsuccessful llm-proxy HTTP response. ErrClientHTTPFailure = errors.New("llm_proxy_client_http_failure") )
Functions ¶
This section is empty.
Types ¶
type Asset ¶ added in v1.0.0
type Asset struct {
AssetID string `json:"asset_id"`
MIMEType string `json:"mime_type"`
SizeBytes int64 `json:"size_bytes"`
SHA256 string `json:"sha256"`
State string `json:"state"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt time.Time `json:"expires_at"`
}
Asset is a hash-bound tenant asset returned by llm-proxy.
type AssetUploadInput ¶ added in v1.0.0
AssetUploadInput is the exact media content supplied to UploadAsset.
type AudioAssetAttachmentInput ¶ added in v1.0.0
AudioAssetAttachmentInput is an existing tenant audio asset supplied to NewAudioAssetAttachment.
type AudioAttachmentInput ¶ added in v0.2.55
AudioAttachmentInput is unvalidated audio input supplied to NewAudioAttachment.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client calls llm-proxy using a configured HTTP transport.
func (Client) PostMessages ¶ added in v0.2.16
func (client Client) PostMessages(contextValue context.Context, request MessagesRequest) (string, error)
PostMessages sends a v2 JSON POST messages request and returns the response text.
func (Client) UploadAsset ¶ added in v1.0.0
func (client Client) UploadAsset(contextValue context.Context, input AssetUploadInput) (Asset, error)
UploadAsset stores exact media bytes for later hash-bound attachment references.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is validated llm-proxy client configuration.
func NewConfig ¶
func NewConfig(input ConfigInput) (Config, error)
NewConfig validates external client configuration.
func (Config) AssetUploadURL ¶ added in v1.0.0
AssetUploadURL builds the authenticated tenant asset upload URL for this config.
func (Config) MessagesPostURL ¶ added in v0.2.16
MessagesPostURL builds the authenticated v2 JSON POST URL for this config.
type ConfigInput ¶
type ConfigInput struct {
BaseURL string
Secret string
Provider string
ModelProfilePath string
ModelProfileReader ModelProfileReader
}
ConfigInput is the unvalidated external configuration for an llm-proxy client.
type HTTPFailure ¶ added in v0.4.0
type HTTPFailure struct {
// contains filtered or unexported fields
}
HTTPFailure is a completed non-2xx llm-proxy response. It exposes only the safe status and recognized stable proxy error code; the raw response body is deliberately unavailable.
func (*HTTPFailure) Error ¶ added in v0.4.0
func (failure *HTTPFailure) Error() string
Error reports the sanitized completed-response failure.
func (*HTTPFailure) ProxyErrorCode ¶ added in v0.4.0
func (failure *HTTPFailure) ProxyErrorCode() string
ProxyErrorCode returns the recognized stable proxy error code, or an empty string when the response has no recognized structured error code.
func (*HTTPFailure) StatusCode ¶ added in v0.4.0
func (failure *HTTPFailure) StatusCode() int
StatusCode returns the proxy HTTP response status.
func (*HTTPFailure) Unwrap ¶ added in v0.4.0
func (failure *HTTPFailure) Unwrap() error
Unwrap preserves errors.Is(error, ErrClientHTTPFailure).
type ImageAssetAttachmentInput ¶ added in v1.0.0
ImageAssetAttachmentInput is an existing tenant image asset supplied to NewImageAssetAttachment.
type ImageAttachmentInput ¶ added in v0.2.55
ImageAttachmentInput is unvalidated image input supplied to NewImageAttachment.
type MessageAttachment ¶ added in v0.2.55
type MessageAttachment interface {
// contains filtered or unexported methods
}
MessageAttachment is one validated provider-neutral media attachment.
func NewAudioAssetAttachment ¶ added in v1.0.0
func NewAudioAssetAttachment(input AudioAssetAttachmentInput) (MessageAttachment, error)
NewAudioAssetAttachment validates a hash-bound tenant audio asset reference.
func NewAudioAttachment ¶ added in v0.2.55
func NewAudioAttachment(input AudioAttachmentInput) (MessageAttachment, error)
NewAudioAttachment validates and hash-binds exact audio bytes.
func NewImageAssetAttachment ¶ added in v1.0.0
func NewImageAssetAttachment(input ImageAssetAttachmentInput) (MessageAttachment, error)
NewImageAssetAttachment validates a hash-bound tenant image asset reference.
func NewImageAttachment ¶ added in v0.2.55
func NewImageAttachment(input ImageAttachmentInput) (MessageAttachment, error)
NewImageAttachment validates and hash-binds exact image bytes.
type MessageInput ¶ added in v0.2.16
type MessageInput struct {
Role string
Content string
Attachments []MessageAttachment
// Order is optional; when any message sets it, every message in the request must set a unique non-negative value.
Order *int
}
MessageInput is an unvalidated chat message for a v2 JSON POST request.
type MessagesRequest ¶ added in v0.2.16
type MessagesRequest struct {
// contains filtered or unexported fields
}
MessagesRequest is a validated v2 messages-only JSON POST request.
func NewMessagesRequest ¶ added in v0.2.16
func NewMessagesRequest(input MessagesRequestInput) (MessagesRequest, error)
NewMessagesRequest validates v2 messages-only request input.
type MessagesRequestInput ¶ added in v0.2.16
type MessagesRequestInput struct {
Messages []MessageInput
Model string
// WebSearch is serialized as the native JSON boolean web_search field.
WebSearch bool
MaxTokens *int
ReasoningEffort *string
// RequestTimeoutSeconds optionally selects the proxy-owned wall-clock work budget.
RequestTimeoutSeconds *int
}
MessagesRequestInput is the unvalidated external input for a v2 messages-only JSON POST request.
type ModelProfileReader ¶ added in v0.2.34
ModelProfileReader reads the current JSON model-profile document from a configured path.