This commit is contained in:
@@ -24,7 +24,6 @@ services/ai_call_logger.py
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
import threading
|
||||
@@ -438,18 +437,3 @@ def _safe_meta_json(meta: Dict[str, Any]) -> str:
|
||||
except Exception as e:
|
||||
logger.warning("[AICallLogger] meta json dump failed: %s", e)
|
||||
return '{}'
|
||||
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
# 工具:caller 自動推斷(caller 沒給時用)
|
||||
# ─────────────────────────────────────────────────────────────────────────────
|
||||
def infer_caller_from_stack(default: str = 'unknown') -> str:
|
||||
"""從 inspect.stack() 推斷 caller(取上 1 層的 module 名末段)。"""
|
||||
try:
|
||||
frame = inspect.stack()[2]
|
||||
module = inspect.getmodule(frame.frame)
|
||||
if module and module.__name__:
|
||||
return module.__name__.split('.')[-1][:64]
|
||||
except Exception:
|
||||
logger.debug("[AICallLogger] infer caller from stack failed", exc_info=True)
|
||||
return default
|
||||
|
||||
Reference in New Issue
Block a user