更新回复格式
This commit is contained in:
@@ -66,6 +66,30 @@ async def after_model_callback(callback_context, llm_response):
|
||||
)
|
||||
total_tokens = getattr(usage, "total_token_count", None) if usage else None
|
||||
|
||||
# ── 打印模型输出的完整内容(用于排查问题) ──
|
||||
content = getattr(llm_response, "content", None)
|
||||
if content:
|
||||
parts = getattr(content, "parts", None) or []
|
||||
for i, part in enumerate(parts):
|
||||
text = getattr(part, "text", None)
|
||||
if text:
|
||||
logger.info(
|
||||
"【模型输出】agent=%s part=%d text=%s",
|
||||
agent_name,
|
||||
i,
|
||||
text[:2000] if len(text) > 2000 else text,
|
||||
)
|
||||
else:
|
||||
# 非文本 part(如工具调用)
|
||||
func_call = getattr(part, "function_call", None)
|
||||
if func_call:
|
||||
logger.info(
|
||||
"【工具调用】agent=%s function=%s args=%s",
|
||||
agent_name,
|
||||
getattr(func_call, "name", "?"),
|
||||
getattr(func_call, "args", {}),
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"模型调用完成 | agent=%s model=%s latency=%.3fs "
|
||||
"prompt_tokens=%s completion_tokens=%s total_tokens=%s",
|
||||
|
||||
Reference in New Issue
Block a user