@@ -2,6 +2,7 @@ package engine
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -18,6 +19,7 @@ type RuntimeSettings struct {
|
||||
DisplayCategories []string `json:"display_categories"`
|
||||
ThinkingCategories []string `json:"thinking_categories"`
|
||||
ViewMode string `json:"view_mode"`
|
||||
MaxDisplayNodes int `json:"max_display_nodes"`
|
||||
}
|
||||
|
||||
type CategoryInfo struct {
|
||||
@@ -33,6 +35,7 @@ func (e *Engine) defaultRuntimeSettings() RuntimeSettings {
|
||||
DisplayCategories: append([]string(nil), e.Cfg.DisplayCategories...),
|
||||
ThinkingCategories: append([]string(nil), e.Cfg.ThinkingCategories...),
|
||||
ViewMode: e.Cfg.DefaultView,
|
||||
MaxDisplayNodes: e.Cfg.MaxDisplayNodes,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -47,6 +50,12 @@ func normalizeRuntimeSettings(in RuntimeSettings) RuntimeSettings {
|
||||
if in.ViewMode != "neural" && in.ViewMode != "honeycomb" {
|
||||
in.ViewMode = "neural"
|
||||
}
|
||||
if in.MaxDisplayNodes < 0 {
|
||||
in.MaxDisplayNodes = 0
|
||||
}
|
||||
if in.MaxDisplayNodes > 500000 {
|
||||
in.MaxDisplayNodes = 500000
|
||||
}
|
||||
return in
|
||||
}
|
||||
|
||||
@@ -96,6 +105,9 @@ func (e *Engine) RuntimeSettings() RuntimeSettings {
|
||||
}
|
||||
|
||||
func (e *Engine) SetRuntimeSettings(settings RuntimeSettings) (RuntimeSettings, error) {
|
||||
if settings.MaxDisplayNodes < 0 || settings.MaxDisplayNodes > 500000 {
|
||||
return e.RuntimeSettings(), fmt.Errorf("max_display_nodes must be between 0 and 500000")
|
||||
}
|
||||
settings = normalizeRuntimeSettings(settings)
|
||||
e.runtimeMu.Lock()
|
||||
previous := e.runtime
|
||||
@@ -136,6 +148,7 @@ func (e *Engine) SetRuntimeSettings(settings RuntimeSettings) (RuntimeSettings,
|
||||
"display_categories": len(settings.DisplayCategories),
|
||||
"thinking_categories": len(settings.ThinkingCategories),
|
||||
"view_mode": settings.ViewMode,
|
||||
"max_display_nodes": settings.MaxDisplayNodes,
|
||||
},
|
||||
})
|
||||
return settings, nil
|
||||
|
||||
Reference in New Issue
Block a user