mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-17 23:51:30 +00:00
fix(guardrails): avoid mutable dict literal in guardrail metadata population
This commit is contained in:
parent
698f608ad6
commit
ca9e121eb6
1 changed files with 6 additions and 3 deletions
|
|
@ -273,13 +273,16 @@ class _ProxyDBLogger(CustomLogger):
|
|||
# guardrail_information is missing from SLP. Populate it from post-call evals
|
||||
# before spend-log write so reports show accurate guardrail results.
|
||||
if sl_object is not None:
|
||||
litellm_metadata: Final = kwargs.get("litellm_metadata")
|
||||
guardrail_info_from_hooks: Final = (
|
||||
kwargs.get("litellm_metadata", {}).get("standard_logging_guardrail_information")
|
||||
if isinstance(kwargs.get("litellm_metadata"), dict)
|
||||
litellm_metadata.get("standard_logging_guardrail_information")
|
||||
if isinstance(litellm_metadata, dict)
|
||||
else None
|
||||
)
|
||||
if guardrail_info_from_hooks is not None and not sl_object.get("guardrail_information"):
|
||||
sl_object["guardrail_information"] = guardrail_info_from_hooks
|
||||
sl_object["guardrail_information"] = (
|
||||
guardrail_info_from_hooks # mutable-ok: populate SLP before spend-log write
|
||||
)
|
||||
|
||||
if response_cost is not None:
|
||||
user_api_key: Final = metadata.get("user_api_key", None)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue