Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
Embedder
UsageListener
}
type ClientOption ¶
type ClientOption func(*Config)
ClientOption mutates Config. Each provider may alias this type so that its constructor accepts a consistent set of generic options alongside any provider-specific ones.
func WithBaseURL ¶
func WithBaseURL(baseURL string) ClientOption
WithBaseURL overrides the default endpoint URL.
func WithHTTPClient ¶
func WithHTTPClient(httpClient *http.Client) ClientOption
WithHTTPClient injects a custom *http.Client* (for timeouts, transport, …).
type Config ¶
type Config struct {
// BaseURL is the root URL of the remote embedding service (e.g. https://api.openai.com).
BaseURL string
// HTTPClient performs the underlying HTTP calls. When nil the provider
// should fall back to *http.DefaultClient* or create its own with sensible
// timeout.
HTTPClient *http.Client
// Model identifies the embedding model (e.g. "text-embedding-3-small") to
// be used by the provider. The concrete provider may fall back to its own
// default if Model is left empty.
Model string
}
Config groups the fields that are common to every embedder provider Client.
Several provider implementations (OpenAI, Ollama, VertexAI, …) were declaring the same set of fields (BaseURL, HTTPClient, Model) independently in their dedicated client structs and duplicating functional-option helpers to mutate them. Config centralises those shared attributes so that every provider can embed *base.Config* and inherit the fields automatically. Generic functional-options defined in this package operate on Config and therefore can be reused by all providers, eliminating the previous boiler-plate.