refactor: replace print() with structured logging across backend
Replace all print()/stderr logging with Python logging module using logger = logging.getLogger(__name__) pattern for consistent log levels and formatting. Extract score conversion to shared score_utils module. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""
|
||||
大模型API集成 — 支持 SiliconFlow 和 DeepSeek 官方 + 视觉模型
|
||||
"""
|
||||
import logging
|
||||
import os
|
||||
import base64
|
||||
from typing import List, Dict, Any, Optional, AsyncGenerator, Tuple
|
||||
@@ -12,6 +13,8 @@ import openai
|
||||
|
||||
from ..core.config import get_settings
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
settings = get_settings()
|
||||
|
||||
# 图片描述提示词
|
||||
@@ -56,7 +59,7 @@ class SiliconFlowLLM:
|
||||
api_key, base_url, resolved_model = _resolve_provider(raw_model)
|
||||
|
||||
self.model_name = resolved_model
|
||||
print(f"[LLM] 模型: {resolved_model}, API: {base_url}")
|
||||
logger.info(f"模型: {resolved_model}, API: {base_url}")
|
||||
|
||||
self.llm = ChatOpenAI(
|
||||
model=resolved_model,
|
||||
@@ -210,7 +213,7 @@ class SiliconFlowLLM:
|
||||
return response.choices[0].message.content or ""
|
||||
|
||||
except Exception as e:
|
||||
print(f"[VLM] 描述失败 attempt={attempt+1}: {e}")
|
||||
logger.warning(f"描述失败 attempt={attempt+1}: {e}")
|
||||
if attempt < max_retries - 1:
|
||||
await asyncio.sleep(2 ** attempt)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user