This commit is contained in:
+58
-22
@@ -52,27 +52,29 @@ type Engine struct {
|
||||
GLPIKB *ingest.GLPIKBSyncer
|
||||
Persistence *persist.Coordinator
|
||||
|
||||
mu sync.Mutex
|
||||
stateMu sync.RWMutex
|
||||
lastScan time.Time
|
||||
lastEnrich time.Time
|
||||
lastAttempt time.Time
|
||||
nextEnrich time.Time
|
||||
ollamaOK bool
|
||||
enrichRunning bool
|
||||
enrichTrigger string
|
||||
enrichResult string
|
||||
enrichError string
|
||||
enrichCycles uint64
|
||||
enrichCreated uint64
|
||||
enrichRejected uint64
|
||||
relationsCreated uint64
|
||||
articlesCreated uint64
|
||||
articlesSkipped uint64
|
||||
enrichRequests chan string
|
||||
runtimeMu sync.RWMutex
|
||||
runtime RuntimeSettings
|
||||
runtimePath string
|
||||
mu sync.Mutex
|
||||
stateMu sync.RWMutex
|
||||
lastScan time.Time
|
||||
lastEnrich time.Time
|
||||
lastAttempt time.Time
|
||||
nextEnrich time.Time
|
||||
ollamaOK bool
|
||||
enrichRunning bool
|
||||
enrichTrigger string
|
||||
enrichResult string
|
||||
enrichError string
|
||||
enrichCycles uint64
|
||||
enrichCreated uint64
|
||||
enrichRejected uint64
|
||||
relationsCreated uint64
|
||||
articlesCreated uint64
|
||||
articlesSkipped uint64
|
||||
enrichRequests chan string
|
||||
runtimeMu sync.RWMutex
|
||||
runtime RuntimeSettings
|
||||
runtimePath string
|
||||
researchEvidenceMu sync.RWMutex
|
||||
researchEvidenceCache map[string]researchEvidenceRecord
|
||||
}
|
||||
|
||||
func New(cfg config.Config, g *graph.Store, b *activity.Broker) *Engine {
|
||||
@@ -108,6 +110,36 @@ func New(cfg config.Config, g *graph.Store, b *activity.Broker) *Engine {
|
||||
if cfg.ArticleMinAnswerChars < 1 {
|
||||
cfg.ArticleMinAnswerChars = 420
|
||||
}
|
||||
if cfg.ArticleMaxResearchQueries < 1 {
|
||||
cfg.ArticleMaxResearchQueries = 6
|
||||
}
|
||||
if cfg.ArticleResearchResults < 1 {
|
||||
cfg.ArticleResearchResults = 8
|
||||
}
|
||||
if cfg.ArticleResearchRounds < 1 {
|
||||
cfg.ArticleResearchRounds = 3
|
||||
}
|
||||
if cfg.ArticleResearchFetchResults < 1 {
|
||||
cfg.ArticleResearchFetchResults = 4
|
||||
}
|
||||
if cfg.ArticleResearchFetchResults > cfg.ArticleResearchResults {
|
||||
cfg.ArticleResearchFetchResults = cfg.ArticleResearchResults
|
||||
}
|
||||
if cfg.ArticleResearchMinRelevance <= 0 {
|
||||
cfg.ArticleResearchMinRelevance = .65
|
||||
}
|
||||
if cfg.ArticleResearchMinQuality <= 0 {
|
||||
cfg.ArticleResearchMinQuality = .45
|
||||
}
|
||||
if cfg.ArticleResearchPageMaxBytes < 1 {
|
||||
cfg.ArticleResearchPageMaxBytes = 2 << 20
|
||||
}
|
||||
if cfg.ArticleResearchPageMaxChars < 1 {
|
||||
cfg.ArticleResearchPageMaxChars = 14000
|
||||
}
|
||||
if cfg.ArticleResearchFetchTimeout < time.Second {
|
||||
cfg.ArticleResearchFetchTimeout = 20 * time.Second
|
||||
}
|
||||
ollamaURLs := append([]string(nil), cfg.OllamaURLs...)
|
||||
if len(ollamaURLs) == 0 && strings.TrimSpace(cfg.OllamaURL) != "" {
|
||||
ollamaURLs = []string{cfg.OllamaURL}
|
||||
@@ -136,7 +168,7 @@ func New(cfg config.Config, g *graph.Store, b *activity.Broker) *Engine {
|
||||
RequireEmbeddingModel: cfg.OllamaRequireEmbeddingModel,
|
||||
}, cfg.ChatModel, cfg.EmbeddingModel)
|
||||
persistence := persist.New(g, b, cfg.PersistInterval)
|
||||
e := &Engine{Cfg: cfg, Graph: g, Broker: b, Ollama: pool, Persistence: persistence, Scanner: &ingest.KnowledgeScanner{Graph: g, ProductionDirs: cfg.KnowledgeDirs, StagingDirs: cfg.StagingDirs}, enrichRequests: make(chan string, 1), runtimePath: filepath.Join(cfg.DataDir, "runtime-settings.json")}
|
||||
e := &Engine{Cfg: cfg, Graph: g, Broker: b, Ollama: pool, Persistence: persistence, Scanner: &ingest.KnowledgeScanner{Graph: g, ProductionDirs: cfg.KnowledgeDirs, StagingDirs: cfg.StagingDirs}, enrichRequests: make(chan string, 1), runtimePath: filepath.Join(cfg.DataDir, "runtime-settings.json"), researchEvidenceCache: map[string]researchEvidenceRecord{}}
|
||||
e.loadRuntimeSettings()
|
||||
if cfg.SearXNGURL != "" {
|
||||
e.Research = research.New(cfg.SearXNGURL)
|
||||
@@ -736,6 +768,10 @@ func (e *Engine) Status() map[string]any {
|
||||
"article_min_sources": e.Cfg.ArticleMinSources, "article_max_sources": e.Cfg.ArticleMaxSources,
|
||||
"article_min_production_ratio": e.Cfg.ArticleMinProductionRatio, "article_max_generation_depth": e.Cfg.ArticleMaxGenerationDepth,
|
||||
"article_max_research_queries": e.Cfg.ArticleMaxResearchQueries, "article_research_results": e.Cfg.ArticleResearchResults,
|
||||
"article_research_rounds": e.Cfg.ArticleResearchRounds, "article_research_fetch_results": e.Cfg.ArticleResearchFetchResults,
|
||||
"article_research_min_relevance": e.Cfg.ArticleResearchMinRelevance, "article_research_min_quality": e.Cfg.ArticleResearchMinQuality,
|
||||
"article_research_page_max_bytes": e.Cfg.ArticleResearchPageMaxBytes, "article_research_page_max_chars": e.Cfg.ArticleResearchPageMaxChars,
|
||||
"article_research_fetch_timeout": e.Cfg.ArticleResearchFetchTimeout.String(), "article_research_allow_private": e.Cfg.ArticleResearchAllowPrivate,
|
||||
"enrich_interval": e.Cfg.EnrichInterval.String(),
|
||||
"enrich_batch_size": e.Cfg.EnrichBatchSize, "enrich_anchors": e.Cfg.EnrichAnchors,
|
||||
"research_enabled": e.Cfg.ResearchEnabled, "chat_model": e.Cfg.ChatModel, "embedding_model": e.Cfg.EmbeddingModel,
|
||||
|
||||
Reference in New Issue
Block a user