config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDefaultConfigPath

func GetDefaultConfigPath() string

GetDefaultConfigPath returns the default configuration file path

func GetEnv

func GetEnv(key, defaultValue string) string

GetEnv returns the value of an environment variable or the default value

func SanitizeAPIKey

func SanitizeAPIKey(apiKey string) string

SanitizeAPIKey sanitizes API keys for logging

func Validate added in v0.6.0

func Validate(cfg *Config) error

Validate validates the entire configuration

Types

type AnthropicConfig

type AnthropicConfig struct {
	APIKey  string `yaml:"apiKey"`
	Model   string `yaml:"model" default:"claude-3-opus-20240229"`
	BaseURL string `yaml:"baseURL" default:"https://api.anthropic.com/v1"`
}

AnthropicConfig represents Anthropic configuration

type AzureOpenAIConfig

type AzureOpenAIConfig struct {
	APIKey     string `yaml:"apiKey"`
	Model      string `yaml:"model"`
	Endpoint   string `yaml:"endpoint"`
	APIVersion string `yaml:"apiVersion" default:"2024-03-01-preview"`
}

AzureOpenAIConfig represents Azure OpenAI configuration

type CohereConfig added in v0.6.0

type CohereConfig struct {
	APIKey  string `yaml:"apiKey"`
	Model   string `yaml:"model" default:"embed-english-v3.0"`
	BaseURL string `yaml:"baseURL" default:"https://api.cohere.ai/v1"`
}

CohereConfig represents Cohere configuration

type Config

type Config struct {
	RAG         RAGConfig         `yaml:"rag"`
	Embedding   EmbeddingConfig   `yaml:"embedding"`
	LLM         LLMConfig         `yaml:"llm"`
	VectorStore VectorStoreConfig `yaml:"vectorstore"`
	Logging     LoggingConfig     `yaml:"logging"`
}

Config represents the main configuration structure for GoRAG

func (*Config) FromMap

func (c *Config) FromMap(data map[string]interface{}) error

FromMap loads config from a map

func (*Config) SetDefaults

func (c *Config) SetDefaults()

SetDefaults sets default values for configuration

func (*Config) ToMap

func (c *Config) ToMap() map[string]interface{}

ToMap converts the config to a map for use in plugins

func (*Config) Validate

func (c *Config) Validate() error

Validate validates the configuration

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider string       `yaml:"provider" default:"openai"`
	OpenAI   OpenAIConfig `yaml:"openai"`
	Ollama   OllamaConfig `yaml:"ollama"`
	Cohere   CohereConfig `yaml:"cohere"`
	Voyage   VoyageConfig `yaml:"voyage"`
}

EmbeddingConfig represents embedding provider configuration

type LLMConfig

type LLMConfig struct {
	Provider    string            `yaml:"provider" default:"openai"`
	OpenAI      OpenAIConfig      `yaml:"openai"`
	Anthropic   AnthropicConfig   `yaml:"anthropic"`
	Ollama      OllamaConfig      `yaml:"ollama"`
	AzureOpenAI AzureOpenAIConfig `yaml:"azure_openai"`
}

LLMConfig represents LLM client configuration

type Loader

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

Loader represents a configuration loader

func NewLoader

func NewLoader(configPath string) *Loader

NewLoader creates a new configuration loader

func (*Loader) Load

func (l *Loader) Load() (*Config, error)

Load loads the configuration from file and environment variables

type LoggingConfig

type LoggingConfig struct {
	Level  string `yaml:"level" default:"info"`
	Format string `yaml:"format" default:"json"`
}

LoggingConfig represents logging configuration

type MemoryConfig

type MemoryConfig struct {
	MaxSize int `yaml:"maxSize" default:"10000"`
}

MemoryConfig represents memory vector store configuration

type MilvusConfig

type MilvusConfig struct {
	Host     string `yaml:"host" default:"localhost"`
	Port     string `yaml:"port" default:"19530"`
	Username string `yaml:"username"`
	Password string `yaml:"password"`
	Database string `yaml:"database" default:"default"`
}

MilvusConfig represents Milvus vector store configuration

type OllamaConfig

type OllamaConfig struct {
	Model   string `yaml:"model" default:"qwen3:7b"`
	BaseURL string `yaml:"baseURL" default:"http://localhost:11434"`
}

OllamaConfig represents Ollama configuration

type OpenAIConfig

type OpenAIConfig struct {
	APIKey  string `yaml:"apiKey"`
	Model   string `yaml:"model" default:"text-embedding-ada-002"`
	BaseURL string `yaml:"baseURL" default:"https://api.openai.com/v1"`
}

OpenAIConfig represents OpenAI configuration

type PineconeConfig

type PineconeConfig struct {
	APIKey      string `yaml:"apiKey"`
	Environment string `yaml:"environment"`
}

PineconeConfig represents Pinecone vector store configuration

type QdrantConfig

type QdrantConfig struct {
	URL    string `yaml:"url" default:"http://localhost:6333"`
	APIKey string `yaml:"apiKey"`
}

QdrantConfig represents Qdrant vector store configuration

type RAGConfig

type RAGConfig struct {
	TopK                  int     `yaml:"topK" default:"5"`
	ChunkSize             int     `yaml:"chunkSize" default:"1000"`
	ChunkOverlap          int     `yaml:"chunkOverlap" default:"100"`
	UseSemanticChunking   bool    `yaml:"useSemanticChunking" default:"false"`
	UseHyDE               bool    `yaml:"useHyDE" default:"false"`
	UseRAGFusion          bool    `yaml:"useRAGFusion" default:"false"`
	UseContextCompression bool    `yaml:"useContextCompression" default:"false"`
	RAGFusionQueries      int     `yaml:"ragFusionQueries" default:"4"`
	RAGFusionWeight       float64 `yaml:"ragFusionWeight" default:"0.5"`
}

RAGConfig represents RAG engine configuration

type ValidationError added in v0.6.0

type ValidationError struct {
	Field   string
	Message string
}

ValidationError represents a configuration validation error

func (ValidationError) Error added in v0.6.0

func (e ValidationError) Error() string

Error implements the error interface

type Validator added in v0.6.0

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

Validator validates configuration

func NewValidator added in v0.6.0

func NewValidator() *Validator

NewValidator creates a new validator

func (*Validator) AddError added in v0.6.0

func (v *Validator) AddError(field, message string)

AddError adds a validation error

func (*Validator) Error added in v0.6.0

func (v *Validator) Error() *errors.GoRAGError

Error returns a formatted error message

func (*Validator) Errors added in v0.6.0

func (v *Validator) Errors() []ValidationError

Errors returns all validation errors

func (*Validator) HasErrors added in v0.6.0

func (v *Validator) HasErrors() bool

HasErrors returns true if there are validation errors

type VectorStoreConfig

type VectorStoreConfig struct {
	Type     string         `yaml:"type" default:"memory"`
	Memory   MemoryConfig   `yaml:"memory"`
	Milvus   MilvusConfig   `yaml:"milvus"`
	Qdrant   QdrantConfig   `yaml:"qdrant"`
	Weaviate WeaviateConfig `yaml:"weaviate"`
	Pinecone PineconeConfig `yaml:"pinecone"`
}

VectorStoreConfig represents vector store configuration

type VoyageConfig added in v0.6.0

type VoyageConfig struct {
	APIKey  string `yaml:"apiKey"`
	Model   string `yaml:"model" default:"voyage-2"`
	BaseURL string `yaml:"baseURL" default:"https://api.voyageai.com/v1"`
}

VoyageConfig represents Voyage configuration

type WeaviateConfig

type WeaviateConfig struct {
	URL    string `yaml:"url" default:"http://localhost:8080"`
	APIKey string `yaml:"apiKey"`
}

WeaviateConfig represents Weaviate vector store configuration

Jump to

Keyboard shortcuts

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