mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-09 03:18:44 +00:00
refactor(redaction): build the redacted MCP metadata in a single comprehension
This commit is contained in:
parent
40f1e3eab0
commit
71b09960e9
2 changed files with 3 additions and 3 deletions
|
|
@ -860,7 +860,7 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbac
|
|||
if "messages" not in (excluded_fields or []) and standard_logging_object_copy.get("messages") is not None:
|
||||
standard_logging_object_copy["messages"] = [Message(content=redacted_str).model_dump()]
|
||||
|
||||
if "metadata" not in (excluded_fields or []):
|
||||
if not excluded_fields or "metadata" not in excluded_fields:
|
||||
metadata: Final = standard_logging_object_copy.get("metadata")
|
||||
redacted_metadata: Final = redacted_mcp_tool_call_metadata(metadata, redacted_str)
|
||||
if redacted_metadata is not metadata:
|
||||
|
|
|
|||
|
|
@ -171,8 +171,8 @@ def redacted_mcp_tool_call_metadata(metadata: object, redacted_str: str) -> obje
|
|||
return metadata
|
||||
|
||||
redacted_call: Final = {
|
||||
**mcp_tool_call,
|
||||
**{key: redacted_str for key in ("arguments", "result") if mcp_tool_call.get(key) is not None},
|
||||
key: (redacted_str if key in ("arguments", "result") and value is not None else value)
|
||||
for key, value in mcp_tool_call.items()
|
||||
}
|
||||
return {**metadata, "mcp_tool_call_metadata": redacted_call}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue