From 1ace1921553e733563f9cb9d90a716a789da80ba Mon Sep 17 00:00:00 2001 From: unclecode Date: Mon, 8 Apr 2024 12:42:24 +0800 Subject: [PATCH] Fix issue #2832: Add protected_namespaces to Config class within utils.py, router.py and completion.py to avoid the warning message. --- litellm/types/completion.py | 2 +- litellm/types/router.py | 5 ++++- litellm/utils.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/litellm/types/completion.py b/litellm/types/completion.py index 5eac90575..5302d16b9 100644 --- a/litellm/types/completion.py +++ b/litellm/types/completion.py @@ -32,5 +32,5 @@ class CompletionRequest(BaseModel): model_list: Optional[List[str]] = None class Config: - # allow kwargs extra = "allow" + protected_namespaces = () \ No newline at end of file diff --git a/litellm/types/router.py b/litellm/types/router.py index dc29bb949..16f7413d2 100644 --- a/litellm/types/router.py +++ b/litellm/types/router.py @@ -41,6 +41,8 @@ class RouterConfig(BaseModel): "latency-based-routing", ] = "simple-shuffle" + class Config: + protected_namespaces = () class ModelInfo(BaseModel): id: Optional[ @@ -141,7 +143,8 @@ class Deployment(BaseModel): class Config: extra = "allow" - + protected_namespaces = () + def __contains__(self, key): # Define custom behavior for the 'in' operator return hasattr(self, key) diff --git a/litellm/utils.py b/litellm/utils.py index 6a58d56db..4bf877b0d 100644 --- a/litellm/utils.py +++ b/litellm/utils.py @@ -236,6 +236,7 @@ class HiddenParams(OpenAIObject): class Config: extra = "allow" + protected_namespaces = () def get(self, key, default=None): # Custom .get() method to access attributes with a default value if the attribute doesn't exist