mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-12 23:01:41 +00:00
style: apply ruff format to MCP logging files
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
4f21b35efe
commit
0191362bb9
2 changed files with 5 additions and 13 deletions
|
|
@ -2658,14 +2658,10 @@ class Logging(LiteLLMLoggingBaseClass):
|
|||
# An MCP tool call that fails at the tool level (CallToolResult.isError)
|
||||
# likewise still incurs the configured per-query cost, computed before
|
||||
# this handler runs; don't zero it like a generic failed LLM call.
|
||||
preserve_mcp_cost = (
|
||||
self.call_type == CallTypes.call_mcp_tool.value
|
||||
and self.model_call_details.get("response_cost")
|
||||
preserve_mcp_cost = self.call_type == CallTypes.call_mcp_tool.value and self.model_call_details.get(
|
||||
"response_cost"
|
||||
)
|
||||
if (
|
||||
self.model_call_details.get("combined_usage_object") is None
|
||||
and not preserve_mcp_cost
|
||||
):
|
||||
if self.model_call_details.get("combined_usage_object") is None and not preserve_mcp_cost:
|
||||
self.model_call_details["response_cost"] = 0
|
||||
|
||||
if hasattr(exception, "headers") and isinstance(exception.headers, dict):
|
||||
|
|
|
|||
|
|
@ -181,9 +181,7 @@ def _mcp_session_id_from_headers(
|
|||
def _mcp_content_block_text(block: object) -> Optional[str]:
|
||||
"""The ``text`` of an MCP content block (``TextContent`` object or ``dict``),
|
||||
or ``None`` when the block carries no usable text."""
|
||||
text = (
|
||||
block.get("text") if isinstance(block, dict) else getattr(block, "text", None)
|
||||
)
|
||||
text = block.get("text") if isinstance(block, dict) else getattr(block, "text", None)
|
||||
return text if isinstance(text, str) and text else None
|
||||
|
||||
|
||||
|
|
@ -2558,9 +2556,7 @@ if MCP_AVAILABLE:
|
|||
content = getattr(response, "content", None) or ()
|
||||
if not is_error:
|
||||
return None
|
||||
texts = tuple(
|
||||
text for block in content if (text := _mcp_content_block_text(block))
|
||||
)
|
||||
texts = tuple(text for block in content if (text := _mcp_content_block_text(block)))
|
||||
return "\n".join(texts) or "MCP tool call returned an error result"
|
||||
|
||||
@client
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue