model

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LlamaBackend        = "llama"
	BloomzBackend       = "bloomz"
	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"
	FalconBackend       = "falcon"
	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 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) 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) 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) (*grpc.Client, error)) (*grpc.Client, error)

func (*ModelLoader) StopGRPC added in v1.21.0

func (ml *ModelLoader) StopGRPC()

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 WithLoadGRPCLLMModelOpts added in v1.21.0

func WithLoadGRPCLLMModelOpts(opts *pb.ModelOptions) Option

func WithModelFile added in v1.21.0

func WithModelFile(modelFile string) 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 {
	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