core.config_validator

配置验证模块

该模块提供配置文件结构验证、参数合法性检查和配置一致性验证功能。

Functions

generate_default_config()

生成默认配置

validate_config_file(config_path)

验证配置文件

Classes

ConfigValidator()

配置验证器类

class core.config_validator.ConfigValidator[source]

Bases: object

配置验证器类

CONFIG_SCHEMA = {'properties': {'connectors': {'type': 'object'}, 'llm': {'properties': {'api_key': {'type': 'string'}, 'api_url': {'type': 'string'}, 'embedding_model': {'type': 'string'}, 'model': {'type': 'string'}, 'settings': {'type': 'object'}, 'type': {'type': 'string'}}, 'type': 'object'}, 'logging': {'properties': {'file': {'type': 'string'}, 'format': {'type': 'string'}, 'level': {'enum': ['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'], 'type': 'string'}}, 'type': 'object'}, 'processors': {'patternProperties': {'^[a-zA-Z_][a-zA-Z0-9_]*$': {'properties': {'class': {'type': 'string'}, 'config': {'type': 'object'}, 'enabled': {'type': 'boolean'}, 'module': {'type': 'string'}}, 'required': ['enabled'], 'type': 'object'}}, 'type': 'object'}, 'rag_settings': {'properties': {'prompt_template': {'type': 'string'}, 'threshold': {'maximum': 1.0, 'minimum': 0.0, 'type': 'number'}, 'top_k': {'maximum': 100, 'minimum': 1, 'type': 'integer'}}, 'type': 'object'}, 'storage': {'properties': {'base_path': {'type': 'string'}, 'output_path': {'type': 'string'}}, 'required': ['base_path', 'output_path'], 'type': 'object'}}, 'required': ['storage', 'processors'], 'type': 'object'}
PROCESSOR_NAME_MAPPING = {'ClassificationProcessor': 'classification_processor', 'EmbeddingProcessor': 'embedding_processor', 'FormatConverter': 'format_converter', 'OCRProcessor': 'ocr_processor', 'PreProcessor': 'pre_processor', 'StructureProcessor': 'structure_processor', 'classification_processor': 'classification_processor', 'embedding_processor': 'embedding_processor', 'format_converter': 'format_converter', 'ocr_processor': 'ocr_processor', 'pre_processor': 'pre_processor', 'structure_processor': 'structure_processor'}
REQUIRED_PROCESSORS = ['pre_processor', 'ocr_processor', 'structure_processor', 'embedding_processor']
__init__()[source]

初始化配置验证器

validate_config(config)[source]

验证配置的完整性和合法性

Parameters:

config (Dict[str, Any]) – 配置字典

Returns:

验证是否通过

Return type:

bool

normalize_processor_config(config)[source]

标准化处理器配置名称

Parameters:

config (Dict[str, Any]) – 原始配置

Returns:

标准化后的配置

Return type:

Dict[str, Any]

get_validation_report()[source]

获取验证报告

Returns:

包含错误和警告的报告

Return type:

Dict[str, Any]

core.config_validator.validate_config_file(config_path)[source]

验证配置文件

Parameters:

config_path (str) – 配置文件路径

Returns:

(是否验证通过, 验证报告)

Return type:

tuple

core.config_validator.generate_default_config()[source]

生成默认配置

Returns:

默认配置字典

Return type:

Dict[str, Any]