cloudflare

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyResponse       = errors.New("no response")
	ErrIncompleteEmbedding = errors.New("not all input got embedded")
)

Functions

This section is empty.

Types

type LLM

type LLM struct {
	CallbacksHandler callbacks.Handler
	// contains filtered or unexported fields
}

LLM is a cloudflare LLM implementation.

func New

func New(opts ...Option) (*LLM, error)

New creates a new cloudflare LLM implementation.

func (*LLM) Call

func (o *LLM) Call(ctx context.Context, prompt string, options ...llms.CallOption) (string, error)

Call Implement the call interface for LLM.

func (*LLM) CreateEmbedding

func (o *LLM) CreateEmbedding(ctx context.Context, inputTexts []string) ([][]float32, error)

CreateEmbedding creates embeddings for the given input texts.

func (*LLM) GenerateContent

func (o *LLM) GenerateContent(ctx context.Context, messages []llms.MessageContent, options ...llms.CallOption) (*llms.ContentResponse, error)

GenerateContent implements the Model interface.

type Option

type Option func(*options)

func WithAccountID

func WithAccountID(accountID string) Option

WithAccountID Set the Account Id of the cloudflare account to use.

func WithEmbeddingModel

func WithEmbeddingModel(model string) Option

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient Set custom http client.

func WithModel

func WithModel(model string) Option

WithModel Set the model to use.

func WithServerURL

func WithServerURL(rawURL string) Option

WithServerURL Set the URL of the cloudflare Workers AI service.

func WithSystemPrompt

func WithSystemPrompt(p string) Option

WithSystemPrompt Set the system prompt. This is only valid if WithCustomTemplate is not set and the cloudflare model use .System in its model template OR if WithCustomTemplate is set using {{.System}}.

func WithToken

func WithToken(token string) Option

WithToken Set the token to use.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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