Documentation
¶
Overview ¶
Package httpjson is the shared HTTP-JSON plumbing for lore's provider adapters (the OpenAI-compatible embed/chat client and the Cohere-style reranker): a POST of a JSON body, decode of a 2xx JSON response, bearer or api-key auth, and automatic retry of transient 429/503 responses honoring Retry-After. It carries no provider-specific knowledge.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Auth ¶
type Auth int
Auth selects how the API key is presented. AuthBearer (Authorization: Bearer <key>) is the OpenAI/Cohere default; AuthAPIKey (api-key: <key>) is Azure OpenAI's scheme.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the shared HTTP plumbing for a JSON-over-HTTP endpoint.
func (*Client) Post ¶
Post marshals in as JSON to baseURL+path, then decodes a 2xx response into out. It retries transient rate-limit/availability responses (429, 503), honoring the Retry-After header and backing off, up to maxRetries; other non-2xx responses become an error carrying the status and a body snippet. The context governs the request lifetime and cancels any backoff.
func (*Client) PostStream ¶
PostStream marshals in as JSON and returns the raw body of a 2xx response for the caller to stream (e.g. server-sent events). It applies the same auth and transient-retry policy as Post — but only up to the point a response status is known; once streaming begins the body is the caller's, who MUST Close it. A non-2xx response is drained and returned as an error carrying a body snippet.