config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BM25

type BM25 struct {
	// K1 is usually chosen in range [1.2, 2.0]
	// (in absence of advanced optimization)
	K1 float32 `yaml:"k1"`
	// B is usually set to 0.75 (in absence of advanced optimization)
	B float32 `yaml:"b"`
}

BM25 holds parameters for BM25 ranking function.

type Config

type Config struct {
	DB          DB         `yaml:"db"`
	HNSW        HNSW       `yaml:"hnsw"`
	TermService GRPCServer `yaml:"term_service"`
	Embeddings  Embeddings `yaml:"embeddings"`
	BM25        BM25       `yaml:"bm25"`
	Server      Server     `yaml:"server"`
}

Config holds application-wide configuration settings.

func FromYAMLFile

func FromYAMLFile(filename string) (*Config, error)

FromYAMLFile reads a Config object from a YAML file.

Before being decoded, the whole YAML file content is passed through os.ExpandEnv.

type DB

type DB struct {
	// DSN, dbname excluded.
	DSN      string     `yaml:"dsn"`
	DBName   string     `yaml:"dbname"`
	LogLevel DBLogLevel `yaml:"loglevel"`
}

DB holds database settings.

type DBLogLevel

type DBLogLevel gormlogger.LogLevel

DBLogLevel is a redefinition of GORM logger.LogLevel which satisfies encoding.TextUnmarshaler, to be conveniently parsed from YAML.

func (*DBLogLevel) UnmarshalText

func (l *DBLogLevel) UnmarshalText(text []byte) error

UnmarshalText satisfies the encoding.TextUnmarshaler interface, unmarshaling the text to a DBLogLevel.

type Embeddings

type Embeddings struct {
	VectorsFilename string `yaml:"vectors_filename"`
	Size            int    `yaml:"size"`
	DBPath          string `yaml:"db_path"`
}

Embeddings holds settings for the embeddings vectors and store.

type GRPCServer

type GRPCServer struct {
	Target     string `yaml:"target"`
	TLSEnabled bool   `yaml:"tls_enabled"`
}

GRPCServer holds common settings for connecting to a gRPC server.

type HNSW

type HNSW struct {
	Server GRPCServer `yaml:"server"`
	Index  HNSWIndex  `yaml:"index"`
}

HNSW holds settings for connecting to HNSW server and handling vector indices.

type HNSWIndex

type HNSWIndex struct {
	NamePrefix     string        `yaml:"name_prefix"`
	Dim            int32         `yaml:"dim"`
	EfConstruction int32         `yaml:"ef_construction"`
	M              int32         `yaml:"m"`
	MaxElements    int32         `yaml:"max_elements"`
	Seed           int32         `yaml:"seed"`
	SpaceType      HNSWSpaceType `yaml:"space_type"`
}

HNSWIndex holds settings for HNSW vector indices.

type HNSWSpaceType

HNSWSpaceType is a redefinition of HNSW gRPC API CreateIndexRequest_SpaceType which satisfies encoding.TextUnmarshaler, to be conveniently parsed from YAML.

func (*HNSWSpaceType) UnmarshalText

func (hst *HNSWSpaceType) UnmarshalText(text []byte) (err error)

UnmarshalText satisfies the encoding.TextUnmarshaler interface, unmarshaling the text to an HNSW gRPC API CreateIndexRequest_SpaceType.

type LogLevel

type LogLevel zerolog.Level

LogLevel is a redefinition of zerolog.Level which satisfies encoding.TextUnmarshaler, to be conveniently parsed from YAML.

func (*LogLevel) UnmarshalText

func (l *LogLevel) UnmarshalText(text []byte) (err error)

UnmarshalText satisfies the encoding.TextUnmarshaler interface, unmarshaling the text to a LogLevel.

type Server

type Server struct {
	Address        string   `yaml:"address"`
	TLSEnabled     bool     `yaml:"tls_enabled"`
	TLSCert        string   `yaml:"tls_cert"`
	TLSKey         string   `yaml:"tls_key"`
	AllowedOrigins []string `yaml:"allowed_origins"`
	LogLevel       LogLevel `yaml:"loglevel"`
}

Server holds settings for the HTTP and gRPC server.

Jump to

Keyboard shortcuts

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