llamafile

package
v0.1.11-pre.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2024 License: MIT Imports: 5 Imported by: 1

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 llamafile LLM implementation.

func New

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

New creates a new llamafile 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, texts []string) ([][]float32, error)

func (*LLM) GenerateContent

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

GenerateContent implements the Model interface. nolint: goerr113

type Option

type Option func(*llamafileclient.GenerationSettings)

func WithEmbeddingSize

func WithEmbeddingSize(val int) Option

set size of embeddings.

func WithFrequencyPenalty

func WithFrequencyPenalty(val float64) Option

/ WithFrequencyPenalty sets the frequency penalty.

func WithGrammar

func WithGrammar(val string) Option

WithGrammar sets the grammar.

func WithIgnoreEOS

func WithIgnoreEOS(val bool) Option

WithIgnoreEOS sets the ignore EOS flag.

func WithLogitBias

func WithLogitBias(val []interface{}) Option

WithLogitBias sets the logit bias.

func WithMinP

func WithMinP(val float64) Option

WithMinP sets the minimum probability.

func WithMirostat

func WithMirostat(val int) Option

WithMirostat sets the mirostat.

func WithMirostatEta

func WithMirostatEta(val float64) Option

WithMirostatEta sets the mirostat eta.

func WithMirostatTau

func WithMirostatTau(val float64) Option

WithMirostatTau sets the mirostat tau.

func WithModel

func WithModel(val string) Option

WithModel sets the model.

func WithNCtx

func WithNCtx(val int) Option

WithNCtx sets the context number.

func WithNKeep

func WithNKeep(val int) Option

WithNKeep sets the number of items to keep.

func WithNPredict

func WithNPredict(val int) Option

WithNPredict sets the number of predictions.

func WithNProbs

func WithNProbs(val int) Option

WithNProbs sets the number of probabilities.

func WithPenalizeNL

func WithPenalizeNL(val bool) Option

WithPenalizeNL sets the penalize newline option.

func WithPenaltyPromptTokens

func WithPenaltyPromptTokens(val []interface{}) Option

WithPenaltyPromptTokens sets the penalty prompt tokens.

func WithPresencePenalty

func WithPresencePenalty(val float64) Option

WithPresencePenalty sets the presence penalty.

func WithRepeatLastN

func WithRepeatLastN(val int) Option

WithRepeatLastN sets the repeat last N.

func WithRepeatPenalty

func WithRepeatPenalty(val float64) Option

WithRepeatPenalty sets the repeat penalty.

func WithSeed

func WithSeed(val uint32) Option

WithSeed sets the seed.

func WithStop

func WithStop(val []string) Option

WithStop sets the stop tokens.

func WithStream

func WithStream(val bool) Option

WithStream sets the stream mode.

func WithTemperature

func WithTemperature(val float64) Option

WithTemperature sets the temperature.

func WithTfsZ

func WithTfsZ(val float64) Option

WithTfsZ sets the TfsZ.

func WithTopK

func WithTopK(val int) Option

WithTopK sets the top K.

func WithTopP

func WithTopP(val float64) Option

WithTopP sets the top P.

func WithTypicalP

func WithTypicalP(val float64) Option

WithTypicalP sets the typical P.

func WithUsePenaltyPromptTokens

func WithUsePenaltyPromptTokens(val bool) Option

WithUsePenaltyPromptTokens sets the use penalty prompt tokens flag.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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