config

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Version = "0.1.0"

Functions

This section is empty.

Types

type Config

type Config struct {
	LogLevel string `yaml:"log_level" env:"LOG_LEVEL,default=warn"`
	// Logging allows for scoped logging, e.g. server=warn; scopes will be 1:1 with packages, e.g. server, store, etc.
	Logging          map[string]string `yaml:"logging" env:"MNEMONIC_LOGGING,separator=="`
	ClientTimeoutSec int               `yaml:"client_timeout_sec" env:"MNEMONIC_CLIENT_TIMEOUT_SEC,default=5"`
	ServerAddr       string            `yaml:"server_addr" env:"MNEMONIC_SERVER_ADDR,default=localhost:20001"`
	SocketPathRaw    string            `yaml:"socket_path" env:"MNEMONIC_SOCKET_PATH,default=~/.mnemonic/mnemonic.sock"`
	// AuthToken, if non-empty, requires all TCP HTTP requests to present "Authorization: Bearer <token>".
	AuthToken string `yaml:"auth_token" env:"MNEMONIC_AUTH_TOKEN"`
	// AllowedOrigins enables CORS for the listed origins. Use "*" to permit any origin.
	AllowedOrigins []string `yaml:"allowed_origins" env:"MNEMONIC_ALLOWED_ORIGINS"`
	// UnauthenticatedStatus exempts GET /api/status from bearer-token enforcement on TCP.
	UnauthenticatedStatus bool       `yaml:"unauthenticated_status" env:"MNEMONIC_UNAUTHENTICATED_STATUS"`
	Embeddings            Embeddings `yaml:"embeddings" env:", prefix=MNEMONIC_EMBEDDINGS_"`
	Index                 Index      `yaml:"index" env:", prefix=MNEMONIC_INDEX_"`
}

func Load

func Load(paths ...string) (Config, error)

Load reads config from the given YAML file paths (later paths win) and then overlays environment variables on top. Environment variables always take precedence over file values.

func (*Config) ApplyOverrides

func (c *Config) ApplyOverrides(overrides Config)

ApplyOverrides merges non-empty/non-zero fields from overrides into c. Use this to apply CLI flags or other sources that should take precedence.

func (*Config) AsMap

func (c *Config) AsMap() map[string]string

func (*Config) ClientTimeout

func (c *Config) ClientTimeout() int

func (*Config) LogLevelFor

func (c *Config) LogLevelFor(scope string) string

func (*Config) SocketPath

func (c *Config) SocketPath() string

SocketPath returns the expanded Unix socket path for daemon IPC.

type Embeddings

type Embeddings struct {
	Endpoint  string `yaml:"endpoint" env:"ENDPOINT,default=http://127.0.0.1:1234/v1/embeddings"`
	Model     string `yaml:"model" env:"MODEL,default=nomic-ai/nomic-embed-text-v1.5"`
	AuthToken string `yaml:"auth_token" env:"AUTH_TOKEN"`
	// SkipPreflight is a boolean flag to skip the preflight check before building the index.
	// This is useful for testing or if the user is confident that the embedding endpoint is working correctly.
	SkipPreflight bool `yaml:"skip_preflight" env:"SKIP_PREFLIGHT"`
}

Embeddings holds configuration for the embedding endpoint and model. Defaults are LM Studio specifics.

type Index

type Index struct {
	Dimensions  int     `yaml:"dimensions" env:"DIMENSIONS,default=768"`
	Connections int     `yaml:"connections" env:"CONNECTIONS,default=16"`
	LevelFactor float64 `yaml:"level_factor" env:"LEVEL_FACTOR,default=0.25"`
	EfSearch    int     `yaml:"ef_search" env:"EF_SEARCH,default=50"`
}

Index holds configuration for the HNSW index parameters (expects simplified interface of github.com/coder/hnsw).

Jump to

Keyboard shortcuts

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