Skip to content

Commit df80c01

Browse files
committed
Refactor reasoning_models initialization in ChatOpenAI class
Changed the initialization of reasoning_models to use a default factory with field(), enhancing clarity and maintainability of the code.
1 parent 9e5ab89 commit df80c01

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

browser_use/llm/openai/chat.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from collections.abc import Iterable, Mapping
2-
from dataclasses import dataclass
2+
from dataclasses import dataclass, field
33
from typing import Any, Literal, TypeVar, overload
44

55
import httpx
@@ -55,17 +55,19 @@ class ChatOpenAI(BaseChatModel):
5555
http_client: httpx.AsyncClient | None = None
5656
_strict_response_validation: bool = False
5757
max_completion_tokens: int | None = 4096
58-
reasoning_models: list[ChatModel | str] | None = [
59-
'o4-mini',
60-
'o3',
61-
'o3-mini',
62-
'o1',
63-
'o1-pro',
64-
'o3-pro',
65-
'gpt-5',
66-
'gpt-5-mini',
67-
'gpt-5-nano',
68-
]
58+
reasoning_models: list[ChatModel | str] | None = field(
59+
default_factory=lambda: [
60+
'o4-mini',
61+
'o3',
62+
'o3-mini',
63+
'o1',
64+
'o1-pro',
65+
'o3-pro',
66+
'gpt-5',
67+
'gpt-5-mini',
68+
'gpt-5-nano',
69+
]
70+
)
6971

7072
# Static
7173
@property

0 commit comments

Comments
 (0)