cloudflare

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloudflareClient

type CloudflareClient struct {
	BaseAPI string

	APIToken       string
	AccountID      string
	DefaultModel   string
	IsGateway      bool
	MaxBatchSize   int
	DefaultHeaders map[string]string
	Client         *http.Client
	// contains filtered or unexported fields
}

func NewCloudflareClient

func NewCloudflareClient(opts ...Option) (*CloudflareClient, error)

func (*CloudflareClient) CreateEmbedding

type CloudflareEmbeddingFunction

type CloudflareEmbeddingFunction struct {
	// contains filtered or unexported fields
}

func NewCloudflareEmbeddingFunction

func NewCloudflareEmbeddingFunction(opts ...Option) (*CloudflareEmbeddingFunction, error)

func (*CloudflareEmbeddingFunction) EmbedDocuments

func (e *CloudflareEmbeddingFunction) EmbedDocuments(ctx context.Context, documents []string) ([]*types.Embedding, error)

func (*CloudflareEmbeddingFunction) EmbedQuery

func (e *CloudflareEmbeddingFunction) EmbedQuery(ctx context.Context, document string) (*types.Embedding, error)

func (*CloudflareEmbeddingFunction) EmbedRecords

func (e *CloudflareEmbeddingFunction) EmbedRecords(ctx context.Context, records []*types.Record, force bool) error

type CreateEmbeddingRequest

type CreateEmbeddingRequest struct {
	Text []string `json:"text"`
}

func (*CreateEmbeddingRequest) JSON

func (c *CreateEmbeddingRequest) JSON() (string, error)

type CreateEmbeddingResponse

type CreateEmbeddingResponse struct {
	Success  bool   `json:"success"`
	Messages []any  `json:"messages"`
	Errors   []any  `json:"errors"`
	Result   Result `json:"result"`
}

type Option

type Option func(p *CloudflareClient) error

func WithAPIToken

func WithAPIToken(apiToken string) Option

func WithAccountID

func WithAccountID(accountID string) Option

func WithDefaultHeaders

func WithDefaultHeaders(headers map[string]string) Option

func WithDefaultModel

func WithDefaultModel(model string) Option

func WithEnvAPIToken

func WithEnvAPIToken() Option

func WithEnvAccountID

func WithEnvAccountID() Option

func WithEnvGatewayEndpoint

func WithEnvGatewayEndpoint() Option

func WithGatewayEndpoint

func WithGatewayEndpoint(endpoint string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

func WithMaxBatchSize

func WithMaxBatchSize(size int) Option

type Result

type Result struct {
	Shape []int       `json:"shape"`
	Data  [][]float32 `json:"data"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL