mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-11 09:51:44 +08:00
Ports dataset knowledge compilation (wiki/graph/tree/mindmap) to the Go scheduler with a status contract, aligns wiki storage/retrieval with Python, sizes prompts by content_length, and resolves embedding batch size from provider capability.
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
//
|
|
// Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
|
|
//
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
// you may not use this file except in compliance with the License.
|
|
// You may obtain a copy of the License at
|
|
//
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
//
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
// See the License for the specific language governing permissions and
|
|
// limitations under the License.
|
|
|
|
package config
|
|
|
|
import "github.com/spf13/viper"
|
|
|
|
type IngestorConfig struct {
|
|
// MaxConcurrentWorkers bounds how many ingestion tasks the ingestor runs in
|
|
// parallel (the task channel width and dataset-level compile worker count
|
|
// default to this value). 0/negative falls back to runtime.NumCPU().
|
|
MaxConcurrentWorkers int `mapstructure:"max_concurrent_workers"`
|
|
// CompilerPoolSize bounds the process-wide knowledge-compilation worker
|
|
// pool that drives the cross-doc KNN / LLM-merge / write stages. 0/negative
|
|
// falls back to runtime.NumCPU() (or KC_COMPILE_CONCURRENCY if set).
|
|
CompilerPoolSize int `mapstructure:"compiler_pool_size"`
|
|
}
|
|
|
|
func (c *Config) ParseIngestorConfig(v *viper.Viper) error {
|
|
// Default Ingestor config
|
|
c.ingestor.MaxConcurrentWorkers = 1
|
|
c.ingestor.CompilerPoolSize = 0
|
|
|
|
if !v.IsSet("ingestor") {
|
|
return nil
|
|
}
|
|
sub := v.Sub("ingestor")
|
|
if sub == nil {
|
|
return nil
|
|
}
|
|
|
|
if sub.IsSet("max_concurrent_workers") {
|
|
c.ingestor.MaxConcurrentWorkers = sub.GetInt("max_concurrent_workers")
|
|
}
|
|
|
|
if sub.IsSet("compiler_pool_size") {
|
|
c.ingestor.CompilerPoolSize = sub.GetInt("compiler_pool_size")
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
func (c *Config) GetIngestorConfig() *IngestorConfig {
|
|
return &c.ingestor
|
|
}
|