model_runtime

package
v1.3.2-beta Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParameterTypeInt   = "int"
	ParameterTypeStr   = "string"
	ParameterTypeFloat = "float"
	ParameterTypeBool  = "bool"
)
View Source
const (
	DirAssets = "assets"
)
View Source
const (
	ModelTypeLLM = "llm"
)

Variables

This section is empty.

Functions

func Load

func Load() error

func LoadProvider

func LoadProvider(name string) error

func ReadFile

func ReadFile(dir embed.FS, name string) (eosc.Untyped[string, string], error)

func Register

func Register(name string, driver IProvider)

Types

type Config

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

func NewConfig

func NewConfig(cfg string, validator IParamValidator) *Config

func (*Config) Check

func (c *Config) Check(cfg string) error

func (*Config) DefaultConfig

func (c *Config) DefaultConfig() string

func (*Config) GenConfig

func (c *Config) GenConfig(target string, origin string) (string, error)

type IConfig

type IConfig interface {
	Check(cfg string) error
	GenConfig(target string, origin string) (string, error)
	DefaultConfig() string
}

type IModel

type IModel interface {
	ID() string
	IConfig
}

func NewModel

func NewModel(data string, logo string) (IModel, error)

type IParamValidator

type IParamValidator interface {
	Valid(map[string]interface{}) error
	GenConfig(target map[string]interface{}, origin map[string]interface{}) (string, error)
}

type IProvider

type IProvider interface {
	IProviderInfo
	GetModel(name string) (IModel, bool)
	Models() []IModel
	ModelsByType(modelType string) ([]IModel, bool)
	IConfig
	MaskConfig(cfg string) string
	Sort() int
	Recommend() bool
}

func GetProvider

func GetProvider(name string) (IProvider, bool)

func NewProvider

func NewProvider(providerData string, modelContents map[string]eosc.Untyped[string, string]) (IProvider, error)

func Providers

func Providers() []IProvider

type IProviderInfo

type IProviderInfo interface {
	ID() string
	Name() string
	DefaultModel(modelType string) (IModel, bool)
	HelpUrl() string
	URI() IProviderURI
}

type IProviderURI

type IProviderURI interface {
	Scheme() string
	Host() string
	Path() string
}

type Manager

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

func NewManager

func NewManager() *Manager

func (*Manager) Del

func (m *Manager) Del(name string)

func (*Manager) Get

func (m *Manager) Get(name string) (IProvider, bool)

func (*Manager) List

func (m *Manager) List() []IProvider

func (*Manager) Set

func (m *Manager) Set(name string, driver IProvider)

type Model

type Model struct {

	//defaultConfig string
	IConfig
	// contains filtered or unexported fields
}

func (*Model) ID

func (m *Model) ID() string
func (m *Model) Logo() string

type Param

type Param struct {
	Name     string      `json:"name" yaml:"name"`
	Default  interface{} `json:"default" yaml:"default"`
	Type     string      `json:"type" yaml:"type"`
	Min      float64     `json:"min" yaml:"min"`
	Max      float64     `json:"max" yaml:"max"`
	Required bool        `json:"required" yaml:"required"`
	Secret   bool        `json:"secret" yaml:"secret"`
}

type ParamValidator

type ParamValidator []Param

func (ParamValidator) GenConfig

func (p ParamValidator) GenConfig(target map[string]interface{}, origin map[string]interface{}) (string, error)

func (ParamValidator) Valid

func (p ParamValidator) Valid(params map[string]interface{}) error

type Provider

type Provider struct {
	IConfig
	// contains filtered or unexported fields
}

func (*Provider) DefaultModel

func (p *Provider) DefaultModel(modelType string) (IModel, bool)

func (*Provider) GetModel

func (p *Provider) GetModel(name string) (IModel, bool)

func (*Provider) HelpUrl

func (p *Provider) HelpUrl() string

func (*Provider) ID

func (p *Provider) ID() string
func (p *Provider) Logo() string

func (*Provider) MaskConfig

func (p *Provider) MaskConfig(cfg string) string

func (*Provider) Models

func (p *Provider) Models() []IModel

func (*Provider) ModelsByType

func (p *Provider) ModelsByType(modelType string) ([]IModel, bool)

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) Recommend

func (p *Provider) Recommend() bool

func (*Provider) SetDefaultModel

func (p *Provider) SetDefaultModel(modelType string, model IModel)

func (*Provider) SetModel

func (p *Provider) SetModel(id string, model IModel)

func (*Provider) SetModelsByType

func (p *Provider) SetModelsByType(modelType string, models []IModel)

func (*Provider) Sort

func (p *Provider) Sort() int

func (*Provider) URI

func (p *Provider) URI() IProviderURI

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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