config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigFilename = ".projectmemoryconfig"
	DefaultSQLitePath     = ".projectmemory.db"
	DefaultLogLevel       = "info"
	DefaultLogFormat      = "text"
)

Default configuration values

Variables

This section is empty.

Functions

func GetLoggerFromConfig

func GetLoggerFromConfig(cfg *Config) *slog.Logger

GetLoggerFromConfig creates a slog.Logger based on the configuration

Types

type Config

type Config struct {
	// Store contains storage-related configuration.
	Store struct {
		// SQLitePath is the path to the SQLite database file.
		SQLitePath string `json:"sqlite_path" env:"SQLITE_PATH" validate:"required"`
	} `json:"store"`

	// Summarizer contains summarization-related configuration.
	Summarizer struct {
		// Provider is the name of the summarization provider to use.
		Provider string `json:"provider" env:"SUMMARIZER_PROVIDER"`

		// ApiKey is the API key for the summarization provider.
		ApiKey string `json:"api_key" env:"SUMMARIZER_API_KEY"`
	} `json:"summarizer"`

	// Embedder contains embedding-related configuration.
	Embedder struct {
		// Provider is the name of the embedding provider to use.
		Provider string `json:"provider" env:"EMBEDDER_PROVIDER"`

		// Dimensions is the number of dimensions for the embeddings.
		Dimensions int `json:"dimensions" env:"EMBEDDER_DIMENSIONS" validate:"min:1"`

		// ApiKey is the API key for the embedding provider.
		ApiKey string `json:"api_key" env:"EMBEDDER_API_KEY"`
	} `json:"embedder"`

	// Logging contains logging-related configuration.
	Logging struct {
		// Level is the minimum log level to display ("debug", "info", "warn", "error").
		Level string `json:"level" env:"LOG_LEVEL" validate:"required"`

		// Format is the log format to use ("text", "json").
		Format string `json:"format" env:"LOG_FORMAT"`
	} `json:"logging"`
	// contains filtered or unexported fields
}

Config represents the ProjectMemory configuration

var (
	// Global is the global configuration instance
	Global *Config
)

Global configuration instance

func InitGlobal

func InitGlobal(configPath string) (*Config, error)

InitGlobal initializes the global configuration

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from the default path

func LoadConfigWithPath

func LoadConfigWithPath(configPath string) (*Config, error)

LoadConfigWithPath loads the configuration from a specific path

func NewConfig

func NewConfig() *Config

NewConfig creates a new Config instance with default values

func (*Config) GetConfigPath

func (c *Config) GetConfigPath() string

GetConfigPath returns the path of the currently loaded configuration file

func (*Config) Save

func (c *Config) Save() error

Save saves the configuration to the last used file path

func (*Config) SaveToFile

func (c *Config) SaveToFile(path string) error

SaveToFile saves the configuration to the specified file

Jump to

Keyboard shortcuts

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