Honeycomb und Control-Patch
This commit is contained in:
@@ -45,6 +45,13 @@ type Config struct {
|
||||
AutoEnrich bool
|
||||
ResearchEnabled bool
|
||||
APIKey string
|
||||
LearningEnabled bool
|
||||
ThinkingEnabled bool
|
||||
LearningCategories []string
|
||||
DisplayCategories []string
|
||||
ThinkingCategories []string
|
||||
DefaultView string
|
||||
RuntimeDefaultsConfigured bool
|
||||
|
||||
GLPIKBEnabled bool
|
||||
GLPIURL string
|
||||
@@ -111,6 +118,13 @@ func Load() (Config, error) {
|
||||
AutoEnrich: boolean("BRAIN_AUTO_ENRICH", true),
|
||||
ResearchEnabled: boolean("BRAIN_RESEARCH_ENABLED", false),
|
||||
APIKey: strings.TrimSpace(os.Getenv("BRAIN_API_KEY")),
|
||||
LearningEnabled: boolean("BRAIN_LEARNING_ENABLED", true),
|
||||
ThinkingEnabled: boolean("BRAIN_THINKING_ENABLED", true),
|
||||
LearningCategories: stringList("BRAIN_LEARNING_CATEGORIES"),
|
||||
DisplayCategories: stringList("BRAIN_DISPLAY_CATEGORIES"),
|
||||
ThinkingCategories: stringList("BRAIN_THINKING_CATEGORIES"),
|
||||
DefaultView: strings.ToLower(env("BRAIN_DEFAULT_VIEW", "neural")),
|
||||
RuntimeDefaultsConfigured: true,
|
||||
GLPIKBEnabled: boolean("GLPI_KB_ENABLED", false),
|
||||
GLPIURL: strings.TrimRight(strings.TrimSpace(os.Getenv("GLPI_URL")), "/"),
|
||||
GLPIAPIVersion: env("GLPI_API_VERSION", "v2.3"),
|
||||
@@ -153,6 +167,9 @@ func Load() (Config, error) {
|
||||
if cfg.ResearchEnabled && cfg.SearXNGURL == "" {
|
||||
return Config{}, fmt.Errorf("BRAIN_RESEARCH_ENABLED requires SEARXNG_URL")
|
||||
}
|
||||
if cfg.DefaultView != "neural" && cfg.DefaultView != "honeycomb" {
|
||||
return Config{}, fmt.Errorf("BRAIN_DEFAULT_VIEW must be neural or honeycomb")
|
||||
}
|
||||
if len(cfg.OllamaURLs) < 1 || len(cfg.OllamaURLs) > 64 {
|
||||
return Config{}, fmt.Errorf("OLLAMA_URLS must contain between 1 and 64 nodes")
|
||||
}
|
||||
|
||||
@@ -37,3 +37,23 @@ func TestLoadRejectsMismatchedPoolMetadata(t *testing.T) {
|
||||
t.Fatal("expected pool metadata validation error")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLoadRuntimeControlDefaultsAndFilters(t *testing.T) {
|
||||
t.Setenv("BRAIN_DATA_DIR", t.TempDir())
|
||||
t.Setenv("BRAIN_LEARNING_ENABLED", "false")
|
||||
t.Setenv("BRAIN_THINKING_ENABLED", "false")
|
||||
t.Setenv("BRAIN_LEARNING_CATEGORIES", "Netzwerk,GLPI KB")
|
||||
t.Setenv("BRAIN_DISPLAY_CATEGORIES", "GLPI KB")
|
||||
t.Setenv("BRAIN_THINKING_CATEGORIES", "Netzwerk")
|
||||
t.Setenv("BRAIN_DEFAULT_VIEW", "honeycomb")
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if cfg.LearningEnabled || cfg.ThinkingEnabled || cfg.DefaultView != "honeycomb" {
|
||||
t.Fatalf("unexpected runtime defaults: %+v", cfg)
|
||||
}
|
||||
if len(cfg.LearningCategories) != 2 || len(cfg.DisplayCategories) != 1 || len(cfg.ThinkingCategories) != 1 {
|
||||
t.Fatalf("unexpected category defaults: %+v", cfg)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user