File Tree: fix pydantic Config class usage

Rafael Uzarowski committed Nov 9, 2025 at 14:15 UTC 62ca1e36f915d2735e6363c3917c06039755c967
1 file changed +13 -11
models.py
+13 -11
@@ -41,6 +41,7 @@ from langchain_core.messages import (
41 )
42 from langchain.embeddings.base import Embeddings
43 from sentence_transformers import SentenceTransformer
44 +from pydantic import ConfigDict
45
46
47 # disable extra logging, must be done repeatedly, otherwise browser-use will turn it back on for some reason
@@ -106,17 +107,17 @@ class ChatGenerationResult:
107 def add_chunk(self, chunk: ChatChunk) -> ChatChunk:
108 if chunk["reasoning_delta"]:
109 self.native_reasoning = True
109 -
110 +
111 # if native reasoning detection works, there's no need to worry about thinking tags
112 if self.native_reasoning:
113 processed_chunk = ChatChunk(response_delta=chunk["response_delta"], reasoning_delta=chunk["reasoning_delta"])
114 else:
115 # if the model outputs thinking tags, we ned to parse them manually as reasoning
116 processed_chunk = self._process_thinking_chunk(chunk)
116 -
117 +
118 self.reasoning += processed_chunk["reasoning_delta"]
119 self.response += processed_chunk["response_delta"]
119 -
120 +
121 return processed_chunk
122
123 def _process_thinking_chunk(self, chunk: ChatChunk) -> ChatChunk:
@@ -145,7 +146,7 @@ class ChatGenerationResult:
146 response = response[len(opening_tag):]
147 self.thinking = True
148 self.thinking_tag = closing_tag
148 -
149 +
150 close_pos = response.find(closing_tag)
151 if close_pos != -1:
152 reasoning += response[:close_pos]
@@ -164,7 +165,7 @@ class ChatGenerationResult:
165 self.unprocessed = response
166 response = ""
167 break
167 -
168 +
169 return ChatChunk(response_delta=response, reasoning_delta=reasoning)
170
171 def _is_partial_opening_tag(self, text: str, opening_tag: str) -> bool:
@@ -191,7 +192,7 @@ class ChatGenerationResult:
192 else:
193 response += self.unprocessed
194 return ChatChunk(response_delta=response, reasoning_delta=reasoning)
194 -
195 +
196
197 rate_limiters: dict[str, RateLimiter] = {}
198 api_keys_round_robin: dict[str, int] = {}
@@ -293,10 +294,11 @@ class LiteLLMChatWrapper(SimpleChatModel):
294 provider: str
295 kwargs: dict = {}
296
296 - class Config:
297 - arbitrary_types_allowed = True
298 - extra = "allow" # Allow extra attributes
299 - validate_assignment = False # Don't validate on assignment
297 + model_config = ConfigDict(
298 + arbitrary_types_allowed=True,
299 + extra="allow",
300 + validate_assignment=False,
301 + )
302
303 def __init__(
304 self,
@@ -552,7 +554,7 @@ class LiteLLMChatWrapper(SimpleChatModel):
554
555 except Exception as e:
556 import asyncio
555 -
557 +
558 # Retry only if no chunks received and error is transient
559 if got_any_chunk or not _is_transient_litellm_error(e) or attempt >= max_retries:
560 raise