model

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LlamaBackend        = "llama"
	LlamaStableBackend  = "llama-stable"
	LLamaCPP            = "llama-cpp"
	StarcoderBackend    = "starcoder"
	GPTJBackend         = "gptj"
	DollyBackend        = "dolly"
	MPTBackend          = "mpt"
	GPTNeoXBackend      = "gptneox"
	ReplitBackend       = "replit"
	Gpt2Backend         = "gpt2"
	Gpt4AllLlamaBackend = "gpt4all-llama"
	Gpt4AllMptBackend   = "gpt4all-mpt"
	Gpt4AllJBackend     = "gpt4all-j"
	Gpt4All             = "gpt4all"
	FalconGGMLBackend   = "falcon-ggml"

	BertEmbeddingsBackend  = "bert-embeddings"
	RwkvBackend            = "rwkv"
	WhisperBackend         = "whisper"
	StableDiffusionBackend = "stablediffusion"
	PiperBackend           = "piper"
	LCHuggingFaceBackend   = "langchain-huggingface"
)

Variables

Functions

This section is empty.

Types

type ChatMessageTemplateData added in v1.22.0

type ChatMessageTemplateData struct {
	SystemPrompt string
	Role         string
	RoleName     string
	Content      string
	MessageIndex int
}

TODO: Ask mudler about FunctionCall stuff being useful at the message level?

type GRPCProcessFilter added in v1.25.0

type GRPCProcessFilter = func(id string, p *process.Process) bool

type ModelLoader

type ModelLoader struct {
	ModelPath string
	// contains filtered or unexported fields
}

TODO: Split ModelLoader and TemplateLoader? Just to keep things more organized. Left together to share a mutex until I look into that. Would split if we seperate directories for .bin/.yaml and .tmpl

func NewModelLoader

func NewModelLoader(modelPath string) *ModelLoader

func (*ModelLoader) BackendLoader added in v1.7.0

func (ml *ModelLoader) BackendLoader(opts ...Option) (model *grpc.Client, err error)

func (*ModelLoader) CheckIsLoaded added in v1.25.0

func (ml *ModelLoader) CheckIsLoaded(s string) *grpc.Client

func (*ModelLoader) EvaluateTemplateForChatMessage added in v1.22.0

func (ml *ModelLoader) EvaluateTemplateForChatMessage(templateName string, messageData ChatMessageTemplateData) (string, error)

func (*ModelLoader) EvaluateTemplateForPrompt added in v1.22.0

func (ml *ModelLoader) EvaluateTemplateForPrompt(templateType TemplateType, templateName string, in PromptTemplateData) (string, error)

func (*ModelLoader) ExistsInModelPath

func (ml *ModelLoader) ExistsInModelPath(s string) bool

func (*ModelLoader) GetGRPCPID added in v1.25.0

func (ml *ModelLoader) GetGRPCPID(id string) (int, error)

func (*ModelLoader) GreedyLoader added in v1.7.0

func (ml *ModelLoader) GreedyLoader(opts ...Option) (*grpc.Client, error)

func (*ModelLoader) ListModels

func (ml *ModelLoader) ListModels() ([]string, error)

func (*ModelLoader) LoadModel added in v1.9.0

func (ml *ModelLoader) LoadModel(modelName string, loader func(string, string) (*grpc.Client, error)) (*grpc.Client, error)

func (*ModelLoader) ShutdownModel added in v1.25.0

func (ml *ModelLoader) ShutdownModel(modelName string) error

func (*ModelLoader) StopAllExcept added in v1.25.0

func (ml *ModelLoader) StopAllExcept(s string)

func (*ModelLoader) StopAllGRPC added in v1.25.0

func (ml *ModelLoader) StopAllGRPC()

func (*ModelLoader) StopGRPC added in v1.21.0

func (ml *ModelLoader) StopGRPC(filter GRPCProcessFilter)

type Option added in v1.21.0

type Option func(*Options)

func WithAssetDir added in v1.21.0

func WithAssetDir(assetDir string) Option

func WithBackendString added in v1.21.0

func WithBackendString(backend string) Option

func WithContext added in v1.21.0

func WithContext(ctx context.Context) Option

func WithExternalBackend added in v1.22.0

func WithExternalBackend(name string, uri string) Option

func WithGRPCAttempts added in v1.25.0

func WithGRPCAttempts(attempts int) Option

func WithGRPCAttemptsDelay added in v1.25.0

func WithGRPCAttemptsDelay(delay int) Option

func WithLoadGRPCLoadModelOpts added in v1.24.1

func WithLoadGRPCLoadModelOpts(opts *pb.ModelOptions) Option

func WithModel added in v1.24.1

func WithModel(modelFile string) Option

func WithSingleActiveBackend added in v1.25.0

func WithSingleActiveBackend() Option

func WithThreads added in v1.21.0

func WithThreads(threads uint32) Option

type Options added in v1.21.0

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

func NewOptions added in v1.21.0

func NewOptions(opts ...Option) *Options

type PromptTemplateData added in v1.22.0

type PromptTemplateData struct {
	SystemPrompt         string
	SuppressSystemPrompt bool // used by chat specifically to indicate that SystemPrompt above should be _ignored_
	Input                string
	Instruction          string
	Functions            []grammar.Function
	MessageIndex         int
}

Rather than pass an interface{} to the prompt template: These are the definitions of all possible variables LocalAI will currently populate for use in a prompt template file Please note: Not all of these are populated on every endpoint - your template should either be tested for each endpoint you map it to, or tolerant of zero values.

type TemplateType added in v1.22.0

type TemplateType int

Keep this in sync with config.TemplateConfig. Is there a more idiomatic way to accomplish this in go? Technically, order doesn't _really_ matter, but the count must stay in sync, see tests/integration/reflect_test.go

const (
	ChatPromptTemplate TemplateType = iota
	ChatMessageTemplate
	CompletionPromptTemplate
	EditPromptTemplate
	FunctionsPromptTemplate

	// The following TemplateType is **NOT** a valid value and MUST be last. It exists to make the sanity integration tests simpler!
	IntegrationTestTemplate
)

Jump to

Keyboard shortcuts

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