Agent Zero AI framework
File Tree: fix pydantic Config class usage
Rafael Uzarowski62ca1e36f915
diff --git a/models.py b/models.pyindex 469925e49..fbc2694df 100644--- a/models.py+++ b/models.py@@ -41,6 +41,7 @@ from langchain_core.messages import ()from langchain.embeddings.base import Embeddingsfrom sentence_transformers import SentenceTransformer+from pydantic import ConfigDict# disable extra logging, must be done repeatedly, otherwise browser-use will turn it back on for some reason@@ -106,17 +107,17 @@ class ChatGenerationResult:def add_chunk(self, chunk: ChatChunk) -> ChatChunk:if chunk["reasoning_delta"]:self.native_reasoning = True-+# if native reasoning detection works, there's no need to worry about thinking tagsif self.native_reasoning:processed_chunk = ChatChunk(response_delta=chunk["response_delta"], reasoning_delta=chunk["reasoning_delta"])else:# if the model outputs thinking tags, we ned to parse them manually as reasoningprocessed_chunk = self._process_thinking_chunk(chunk)-+self.reasoning += processed_chunk["reasoning_delta"]self.response += processed_chunk["response_delta"]-+return processed_chunkdef _process_thinking_chunk(self, chunk: ChatChunk) -> ChatChunk:@@ -145,7 +146,7 @@ class ChatGenerationResult:response = response[len(opening_tag):]self.thinking = Trueself.thinking_tag = closing_tag-+close_pos = response.find(closing_tag)if close_pos != -1:reasoning += response[:close_pos]@@ -164,7 +165,7 @@ class ChatGenerationResult:self.unprocessed = responseresponse = ""break-+return ChatChunk(response_delta=response, reasoning_delta=reasoning)def _is_partial_opening_tag(self, text: str, opening_tag: str) -> bool:@@ -191,7 +192,7 @@ class ChatGenerationResult:else:response += self.unprocessedreturn ChatChunk(response_delta=response, reasoning_delta=reasoning)-+rate_limiters: dict[str, RateLimiter] = {}api_keys_round_robin: dict[str, int] = {}@@ -293,10 +294,11 @@ class LiteLLMChatWrapper(SimpleChatModel):provider: strkwargs: dict = {}- class Config:- arbitrary_types_allowed = True- extra = "allow" # Allow extra attributes- validate_assignment = False # Don't validate on assignment+ model_config = ConfigDict(+ arbitrary_types_allowed=True,+ extra="allow",+ validate_assignment=False,+ )def __init__(self,@@ -552,7 +554,7 @@ class LiteLLMChatWrapper(SimpleChatModel):except Exception as e:import asyncio-+# Retry only if no chunks received and error is transientif got_any_chunk or not _is_transient_litellm_error(e) or attempt >= max_retries:raise