Documentation
¶
Index ¶
Constants ¶
View Source
const ( EmbeddingEncodingFormatFloat = openai.EmbeddingEncodingFormatFloat EmbeddingEncodingFormatBase64 = openai.EmbeddingEncodingFormatBase64 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Embedder ¶
type Embedder struct {
// contains filtered or unexported fields
}
func NewEmbedder ¶
func NewEmbedder(ctx context.Context, config *EmbeddingConfig) (*Embedder, error)
func (*Embedder) EmbedStrings ¶
func (*Embedder) IsCallbacksEnabled ¶
type EmbeddingConfig ¶
type EmbeddingConfig struct {
// Timeout specifies the maximum duration to wait for API responses
// If HTTPClient is set, Timeout will not be used.
// Optional. Default: no timeout
Timeout time.Duration `json:"timeout"`
// HTTPClient specifies the client to send HTTP requests.
// If HTTPClient is set, Timeout will not be used.
// Optional. Default &http.Client{Timeout: Timeout}
HTTPClient *http.Client `json:"http_client"`
// APIKey is your authentication key
// Use OpenAI API key or Azure API key depending on the service
// Required
APIKey string `json:"api_key"`
// ByAzure indicates whether to use Azure OpenAI Service
// Required for Azure
ByAzure bool `json:"by_azure"`
// BaseURL is the Azure OpenAI endpoint URL
// Format: https://{YOUR_RESOURCE_NAME}.openai.azure.com. YOUR_RESOURCE_NAME is the name of your resource that you have created on Azure.
// Required for Azure
BaseURL string `json:"base_url"`
// APIVersion specifies the Azure OpenAI API version
// Required for Azure
APIVersion string `json:"api_version"`
// Model specifies the ID of the model to use for embedding generation
// Required
Model string `json:"model"`
// EncodingFormat specifies the format of the embeddings output
// Optional. Default: EmbeddingEncodingFormatFloat
EncodingFormat *EmbeddingEncodingFormat `json:"encoding_format,omitempty"`
// Dimensions specifies the number of dimensions the resulting output embeddings should have
// Optional. Only supported in text-embedding-3 and later models
Dimensions *int `json:"dimensions,omitempty"`
// User is a unique identifier representing your end-user
// Optional. Helps OpenAI monitor and detect abuse
User *string `json:"user,omitempty"`
}
type EmbeddingEncodingFormat ¶
type EmbeddingEncodingFormat = openai.EmbeddingEncodingFormat
Click to show internal directories.
Click to hide internal directories.