From 0c9da8e2ebf9e1e6b4e8eb1902acb0460e342355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Mon, 25 Aug 2025 22:49:43 +0800 Subject: [PATCH] maxkb add log --- .../impl/mineru/maxkb_adapter/config_maxkb.py | 7 +++++-- .../mineru/maxkb_adapter/maxkb_model_client.py | 14 ++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/apps/common/handle/impl/mineru/maxkb_adapter/config_maxkb.py b/apps/common/handle/impl/mineru/maxkb_adapter/config_maxkb.py index c62bf975..ef53cf3b 100644 --- a/apps/common/handle/impl/mineru/maxkb_adapter/config_maxkb.py +++ b/apps/common/handle/impl/mineru/maxkb_adapter/config_maxkb.py @@ -120,7 +120,7 @@ class MaxKBMinerUConfig(MinerUConfig): else: model_id = self.vision_model_id - logger.debug(f"MaxKB: Calling model {model_id} with {len(messages)} messages") + logger.info(f"MaxKB: Calling model {model_id} with {len(messages)} messages, use_llm={use_llm}, model_type={model_type}") # Check if this is a vision request (has images) has_images = False @@ -171,6 +171,7 @@ class MaxKBMinerUConfig(MinerUConfig): combined_prompt += msg.get('content', '') if image_path: + logger.info(f"MaxKB: Calling vision_completion with model_id={model_id}, image_path={image_path[:100] if len(image_path) > 100 else image_path}") response_text = await maxkb_model_client.vision_completion( model_id=model_id, image_path=image_path, @@ -179,6 +180,7 @@ class MaxKBMinerUConfig(MinerUConfig): ) else: # Fallback to text completion + logger.info(f"MaxKB: Falling back to chat_completion for vision model {model_id} (no image content)") response_text = await maxkb_model_client.chat_completion( model_id=model_id, messages=messages, @@ -186,6 +188,7 @@ class MaxKBMinerUConfig(MinerUConfig): ) else: # Regular text completion + logger.info(f"MaxKB: Calling chat_completion with model_id={model_id}") response_text = await maxkb_model_client.chat_completion( model_id=model_id, messages=messages, @@ -210,7 +213,7 @@ class MaxKBMinerUConfig(MinerUConfig): return MockResponse(response_text) except Exception as e: - logger.error(f"MaxKB model call failed: {str(e)}") + logger.error(f"MaxKB model call failed for model_id={model_id}, use_llm={use_llm}: {str(e)}") # Return a mock response with error message class MockResponse: def __init__(self, content): diff --git a/apps/common/handle/impl/mineru/maxkb_adapter/maxkb_model_client.py b/apps/common/handle/impl/mineru/maxkb_adapter/maxkb_model_client.py index 71733215..4515641b 100644 --- a/apps/common/handle/impl/mineru/maxkb_adapter/maxkb_model_client.py +++ b/apps/common/handle/impl/mineru/maxkb_adapter/maxkb_model_client.py @@ -67,7 +67,7 @@ class MaxKBModelClient: ).first() if model: - self.logger.info(f"Using default model: {model.name} (ID: {model.id})") + self.logger.info(f"Using default LLM model: {model.name} (ID: {model.id}, model_name: {model.model_name})") if not model: raise ValueError(f"No LLM model available (requested: {model_id})") @@ -144,7 +144,7 @@ class MaxKBModelClient: ).first() if model: - self.logger.info(f"Using default model: {model.name} (ID: {model.id})") + self.logger.info(f"Using default vision model: {model.name} (ID: {model.id}, model_name: {model.model_name})") if not model: raise ValueError(f"No vision model available (requested: {model_id})") @@ -183,6 +183,7 @@ class MaxKBModelClient: 模型响应文本 """ try: + self.logger.info(f"Calling chat completion with model_id: {model_id}") # 获取模型实例 llm_model = await self.get_llm_model(model_id) @@ -207,7 +208,7 @@ class MaxKBModelClient: return str(response) except Exception as e: - self.logger.error(f"Chat completion failed: {str(e)}") + self.logger.error(f"Chat completion failed for model {model_id}: {str(e)}") # 返回错误JSON而不是空字符串 import json return json.dumps({ @@ -230,6 +231,7 @@ class MaxKBModelClient: 模型响应文本 """ try: + self.logger.info(f"Calling vision completion with model_id: {model_id}") # 获取视觉模型实例 vision_model = await self.get_vision_model(model_id) @@ -242,6 +244,10 @@ class MaxKBModelClient: "title": "No Model", "description": "Vision model not available" }) + else: + # Log actual model name if available + actual_model_name = getattr(vision_model, 'model_name', 'unknown') + self.logger.info(f"Vision model instance created with actual model_name: {actual_model_name}") # 读取图片并转换为base64 import base64 @@ -292,7 +298,7 @@ class MaxKBModelClient: return str(response) except Exception as e: - self.logger.error(f"Vision completion failed: {str(e)}") + self.logger.error(f"Vision completion failed for model {model_id}: {str(e)}") # 返回错误JSON而不是空字符串 import json return json.dumps({