Documentation
¶
Index ¶
- Constants
- type CloudflareClient
- type CloudflareEmbeddingFunction
- func (e *CloudflareEmbeddingFunction) DefaultSpace() embeddings.DistanceMetric
- func (e *CloudflareEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)
- func (e *CloudflareEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)
- func (e *CloudflareEmbeddingFunction) GetConfig() embeddings.EmbeddingFunctionConfig
- func (e *CloudflareEmbeddingFunction) Name() string
- func (e *CloudflareEmbeddingFunction) SupportedSpaces() []embeddings.DistanceMetric
- type CreateEmbeddingRequest
- type CreateEmbeddingResponse
- type Option
- func WithAPIKeyFromEnvVar(envVar string) Option
- func WithAPIToken(apiToken string) Option
- func WithAccountID(accountID string) Option
- func WithDefaultHeaders(headers map[string]string) Option
- func WithDefaultModel(model embeddings.EmbeddingModel) Option
- func WithEnvAPIToken() Option
- func WithEnvAccountID() Option
- func WithEnvGatewayEndpoint() Option
- func WithGatewayEndpoint(endpoint string) Option
- func WithHTTPClient(client *http.Client) Option
- func WithInsecure() Option
- func WithMaxBatchSize(size int) Option
- type Result
Constants ¶
View Source
const (
APIKeyEnvVar = "CLOUDFLARE_API_TOKEN"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CloudflareClient ¶
type CloudflareClient struct {
BaseAPI string
APIToken embeddings.Secret `json:"-" validate:"required"`
APIKeyEnvVar string
AccountID string `validate:"required_if=IsGateway false"`
DefaultModel embeddings.EmbeddingModel
IsGateway bool
MaxBatchSize int `validate:"gt=0,lte=100"`
DefaultHeaders map[string]string
Client *http.Client
Insecure bool
// contains filtered or unexported fields
}
func NewCloudflareClient ¶
func NewCloudflareClient(opts ...Option) (*CloudflareClient, error)
func (*CloudflareClient) CreateEmbedding ¶
func (c *CloudflareClient) CreateEmbedding(ctx context.Context, req *CreateEmbeddingRequest) (*CreateEmbeddingResponse, error)
type CloudflareEmbeddingFunction ¶
type CloudflareEmbeddingFunction struct {
// contains filtered or unexported fields
}
func NewCloudflareEmbeddingFunction ¶
func NewCloudflareEmbeddingFunction(opts ...Option) (*CloudflareEmbeddingFunction, error)
func NewCloudflareEmbeddingFunctionFromConfig ¶ added in v0.3.0
func NewCloudflareEmbeddingFunctionFromConfig(cfg embeddings.EmbeddingFunctionConfig) (*CloudflareEmbeddingFunction, error)
NewCloudflareEmbeddingFunctionFromConfig creates a Cloudflare embedding function from a config map. Uses schema-compliant field names: api_key_env_var, model_name, account_id, is_gateway, gateway_endpoint, insecure.
func (*CloudflareEmbeddingFunction) DefaultSpace ¶ added in v0.3.0
func (e *CloudflareEmbeddingFunction) DefaultSpace() embeddings.DistanceMetric
func (*CloudflareEmbeddingFunction) EmbedDocuments ¶
func (e *CloudflareEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]embeddings.Embedding, error)
func (*CloudflareEmbeddingFunction) EmbedQuery ¶
func (e *CloudflareEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (embeddings.Embedding, error)
func (*CloudflareEmbeddingFunction) GetConfig ¶ added in v0.3.0
func (e *CloudflareEmbeddingFunction) GetConfig() embeddings.EmbeddingFunctionConfig
func (*CloudflareEmbeddingFunction) Name ¶ added in v0.3.0
func (e *CloudflareEmbeddingFunction) Name() string
func (*CloudflareEmbeddingFunction) SupportedSpaces ¶ added in v0.3.0
func (e *CloudflareEmbeddingFunction) SupportedSpaces() []embeddings.DistanceMetric
type CreateEmbeddingRequest ¶
type CreateEmbeddingRequest struct {
Text []string `json:"text"`
}
func (*CreateEmbeddingRequest) JSON ¶
func (c *CreateEmbeddingRequest) JSON() (string, error)
type CreateEmbeddingResponse ¶
type Option ¶
type Option func(p *CloudflareClient) error
func WithAPIKeyFromEnvVar ¶ added in v0.3.0
WithAPIKeyFromEnvVar sets the API key for the client from a specified environment variable
func WithAPIToken ¶
func WithAccountID ¶
func WithDefaultHeaders ¶
func WithDefaultModel ¶
func WithDefaultModel(model embeddings.EmbeddingModel) Option
func WithEnvAPIToken ¶
func WithEnvAPIToken() Option
func WithEnvAccountID ¶
func WithEnvAccountID() Option
func WithEnvGatewayEndpoint ¶
func WithEnvGatewayEndpoint() Option
func WithGatewayEndpoint ¶
func WithHTTPClient ¶
func WithInsecure ¶ added in v0.3.0
func WithInsecure() Option
WithInsecure allows the client to connect to HTTP endpoints without TLS. This should only be used for local development or testing.
func WithMaxBatchSize ¶
Click to show internal directories.
Click to hide internal directories.