传入的 llm_model_id 和 vision_model_id 会被正确传递到配置中
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
朱潮 2025-08-26 00:58:18 +08:00
parent 0c9da8e2eb
commit edc80888cc
2 changed files with 26 additions and 6 deletions

View File

@ -173,9 +173,9 @@ class MinerUExtractor(BaseMinerUExtractor):
# 创建MaxKB适配器 # 创建MaxKB适配器
adapter = MaxKBAdapter() adapter = MaxKBAdapter()
# 导入并创建MaxKB特定的配置 # 导入并创建MaxKB特定的配置传递模型ID
from .config_maxkb import MaxKBMinerUConfig from .config_maxkb import MaxKBMinerUConfig
config = MaxKBMinerUConfig() config = MaxKBMinerUConfig(llm_model_id=llm_model_id, vision_model_id=vision_model_id)
# 调用基类初始化传递适配器、配置和MaxKB特有参数 # 调用基类初始化传递适配器、配置和MaxKB特有参数
super().__init__( super().__init__(

View File

@ -12,16 +12,36 @@ from ..config_base import MinerUConfig
class MaxKBMinerUConfig(MinerUConfig): class MaxKBMinerUConfig(MinerUConfig):
"""MaxKB-specific configuration for MinerU""" """MaxKB-specific configuration for MinerU"""
def __init__(self, llm_model_id: str = None, vision_model_id: str = None):
"""Initialize with MaxKB-specific settings"""
# Store the model IDs before calling parent init
self._init_llm_model_id = llm_model_id
self._init_vision_model_id = vision_model_id
# Call parent initialization
super().__init__()
def __post_init__(self): def __post_init__(self):
"""Initialize with MaxKB-specific settings""" """Initialize with MaxKB-specific settings"""
# Call parent initialization first # Call parent initialization first
super().__post_init__() super().__post_init__()
# MaxKB specific settings from environment or defaults # MaxKB specific settings - use provided IDs first, then environment, then defaults
# 如果环境变量中设置了具体的UUID使用UUID否则使用默认值或自动检测 # 优先使用传入的模型ID其次是环境变量最后是默认值
if hasattr(self, '_init_llm_model_id') and self._init_llm_model_id:
self.llm_model_id = self._init_llm_model_id
else:
self.llm_model_id = os.getenv('MAXKB_LLM_MODEL_ID', self._get_default_llm_model_id()) self.llm_model_id = os.getenv('MAXKB_LLM_MODEL_ID', self._get_default_llm_model_id())
if hasattr(self, '_init_vision_model_id') and self._init_vision_model_id:
self.vision_model_id = self._init_vision_model_id
else:
self.vision_model_id = os.getenv('MAXKB_VISION_MODEL_ID', self._get_default_vision_model_id()) self.vision_model_id = os.getenv('MAXKB_VISION_MODEL_ID', self._get_default_vision_model_id())
# Log the configured model IDs
from .logger import get_module_logger
logger = get_module_logger('config_maxkb')
logger.info(f"MaxKBMinerUConfig initialized with LLM={self.llm_model_id}, Vision={self.vision_model_id}")
# MaxKB API settings # MaxKB API settings
self.maxkb_api_key = os.getenv('MAXKB_API_KEY') self.maxkb_api_key = os.getenv('MAXKB_API_KEY')
self.maxkb_api_url = os.getenv('MAXKB_API_URL', 'https://api.maxkb.com') self.maxkb_api_url = os.getenv('MAXKB_API_URL', 'https://api.maxkb.com')