From c9f88bf2c7eed2b6d5932160634ea01a9286288d Mon Sep 17 00:00:00 2001 From: Brian Caswell Date: Mon, 8 Dec 2025 21:48:42 -0500 Subject: [PATCH] mitigate PydanticDeprecatedSince20 warnings (#17657) When using litellm with a recent pydantic, the following deprecation warnings are shown ``` litellm/types/llms/anthropic.py:531: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/ class AnthropicResponseContentBlockToolUse(BaseModel): litellm/types/rag.py:181: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.12/migration/ class RAGIngestRequest(BaseModel): ``` This aligns with multiple existing places within the litellm codebase that uses ConfigDict to configure pydantic model behavior. --- litellm/types/llms/anthropic.py | 5 ++--- litellm/types/rag.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/litellm/types/llms/anthropic.py b/litellm/types/llms/anthropic.py index df6580f9b3..23dd661e9a 100644 --- a/litellm/types/llms/anthropic.py +++ b/litellm/types/llms/anthropic.py @@ -1,7 +1,7 @@ from enum import Enum from typing import Any, Dict, Iterable, List, Optional, Union -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict from typing_extensions import Literal, Required, TypedDict from .openai import ( @@ -535,8 +535,7 @@ class AnthropicResponseContentBlockToolUse(BaseModel): input: dict provider_specific_fields: Optional[Dict[str, Any]] = None - class Config: - extra = "allow" # Allow provider_specific_fields + model_config = ConfigDict(extra="allow") # Allow provider_specific_fields class AnthropicResponseContentBlockThinking(BaseModel): diff --git a/litellm/types/rag.py b/litellm/types/rag.py index 7a964931af..dd724ca217 100644 --- a/litellm/types/rag.py +++ b/litellm/types/rag.py @@ -4,7 +4,7 @@ Type definitions for RAG (Retrieval Augmented Generation) Ingest API. from typing import Any, Dict, List, Literal, Optional, Union -from pydantic import BaseModel +from pydantic import BaseModel, ConfigDict from typing_extensions import TypedDict @@ -185,6 +185,5 @@ class RAGIngestRequest(BaseModel): file_id: Optional[str] = None # Existing file ID ingest_options: Dict[str, Any] # RAGIngestOptions as dict for flexibility - class Config: - extra = "allow" # Allow additional fields + model_config = ConfigDict(extra="allow") # Allow additional fields