Add recursion depth to convert_anyof_null_to_nullable, constants.py. Fix recursive_detector.py raise error state

This commit is contained in:
Nicholas Grabar 2025-03-28 13:11:19 -07:00
parent e7181395ff
commit 1f2bbda11d
7 changed files with 62 additions and 17 deletions

View file

@ -1,8 +1,9 @@
import json
from typing import Any, Union
from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH
def safe_dumps(data: Any, max_depth: int = 10) -> str:
def safe_dumps(data: Any, max_depth: int = DEFAULT_MAX_RECURSE_DEPTH) -> str:
"""
Recursively serialize data while detecting circular references.
If a circular reference is detected then a marker string is returned.

View file

@ -1,4 +1,5 @@
from typing import Any, Dict, Optional, Set
from litellm.constants import DEFAULT_MAX_RECURSE_DEPTH
class SensitiveDataMasker:
@ -39,7 +40,7 @@ class SensitiveDataMasker:
return result
def mask_dict(
self, data: Dict[str, Any], depth: int = 0, max_depth: int = 10
self, data: Dict[str, Any], depth: int = 0, max_depth: int = DEFAULT_MAX_RECURSE_DEPTH
) -> Dict[str, Any]:
if depth >= max_depth:
return data