config

package
v0.0.0-...-f8036e4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2025 License: Unlicense Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BATCH_SIZE_DATABASE = 1_000
	BATCH_SIZE_CACHE    = 10_000
	CENTROID_SIZE       = 10_000

	SAMPLE_SIZE             = 5 * BATCH_SIZE_CACHE
	SPLIT_SIZE              = 5
	SUPERSET_MUL            = 5
	KMEANS_ITTERATION_LIMIT = 1_000

	CACHE_DURATION = 5 * time.Second
	CACHE_CLEANUP  = 15 * time.Second

	HTTP_CLIENT_MAX_REQUESTS uint64 = 500
)

Variables

This section is empty.

Functions

func CreateSample

func CreateSample(path string) error

CreateSample creates a sample configuration file.

Types

type AI

type AI struct {
	Embed    *Provider `json:"embed"`
	Generate *Provider `json:"generate"`
	Chat     *Provider `json:"chat"`
}

type Config

type Config struct {
	Server   ConfigServer `json:"server"`
	TLS      ConfigTLS    `json:"tls"`
	Database Database     `json:"database"`
	Ollama   AI           `json:"ollama"`
	OpenAI   AI           `json:"openai"`
	LogLevel LogLevel     `json:"log_level"`
}

func ParseConfig

func ParseConfig(raw []byte) (config Config, err error)

ParseConfig parses the raw JSON configuration.

type ConfigServer

type ConfigServer struct {
	HttpAddress  string `json:"http_address"`
	HttpsAddress string `json:"https_address"`
}

type ConfigTLS

type ConfigTLS struct {
	DomainNameServer []string         `json:"dns"`
	IP               []string         `json:"ip"`
	Certificates     []*ConfigTLSPath `json:"certificates"`
	// contains filtered or unexported fields
}

func (*ConfigTLS) Configurate

func (t *ConfigTLS) Configurate() error

Configurate initialize the tls configuration.

func (*ConfigTLS) GetCertificate

func (t *ConfigTLS) GetCertificate(clientHello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns the first client supported certificate.

type ConfigTLSPath

type ConfigTLSPath struct {
	// config
	CertPath string `json:"cert_path"`
	KeyPath  string `json:"key_path"`
	// contains filtered or unexported fields
}

type Database

type Database struct {
	Sqlite           string                `json:"sqlite"`
	Postgres         SingleOrSlice[string] `json:"postgres"`
	PostgresReadOnly SingleOrSlice[string] `json:"postgres_readonly"`
	LogLevel         LogLevel              `json:"log_level"` // 0: Silent, 1: Error, 2: Warn, 3: Info, 4: Debug
	Cache            string                `json:"cache"`
}

func (Database) GetDialectors

func (c Database) GetDialectors() (readwrite, readonly []gorm.Dialector, dbProvider DatabaseProvider)

type DatabaseProvider

type DatabaseProvider uint8
const (
	DatabaseProvider_Sqlite DatabaseProvider = iota + 1
	DatabaseProvider_PostgreSQL
)

type LogLevel

type LogLevel string
const (
	LogLevelDebug LogLevel = "debug"
	LogLevelInfo  LogLevel = "info"
	LogLevelWarn  LogLevel = "warn"
	LogLevelError LogLevel = "error"
	LogLevelFatal LogLevel = "fatal"
	LogLevelPanic LogLevel = "panic"
)

func (LogLevel) GORM

func (c LogLevel) GORM() (level logger.LogLevel)

func (LogLevel) String

func (l LogLevel) String() string

func (LogLevel) Zap

func (l LogLevel) Zap() zap.AtomicLevel

type Provider

type Provider struct {
	Model              string                `json:"model"`
	ApiBase            SingleOrSlice[string] `json:"api_base"`
	ApiKey             string                `json:"api_key"`
	NumCtx             int                   `json:"num_ctx"`
	RequestCompression bool                  `json:"request_compression"`
}

func (Provider) GetNumCtx

func (c Provider) GetNumCtx() int

type SingleOrSlice

type SingleOrSlice[T any] []T

SingleOrSlice allows for a configuration field to be either a single value or a slice of values.

func (SingleOrSlice[T]) MarshalJSON

func (s SingleOrSlice[T]) MarshalJSON() ([]byte, error)

MarshalJSON ensures that the field is marshaled correctly whether it's a single value or a slice.

func (*SingleOrSlice[T]) UnmarshalJSON

func (s *SingleOrSlice[T]) UnmarshalJSON(data []byte) error

UnmarshalJSON handles both single values and slices for the field.

Jump to

Keyboard shortcuts

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