Skip to content

Commit b300e0e

Browse files
Derive BrowserUse tool model enums from SDK constants
Co-authored-by: Shri Sukhani <shrisukhani@users.noreply.github.com>
1 parent 63fdb16 commit b300e0e

1 file changed

Lines changed: 15 additions & 20 deletions

File tree

hyperbrowser/tools/schema.py

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1-
from typing import Literal, List, Optional
1+
from typing import List, Literal, Optional, get_args
2+
3+
from hyperbrowser.models.consts import BrowserUseLlm
24

35
scrape_types = Literal["markdown", "screenshot"]
46

7+
BROWSER_USE_LLM_VALUES = list(get_args(BrowserUseLlm))
8+
BROWSER_USE_DEFAULT_LLM = (
9+
"gemini-2.5-flash"
10+
if "gemini-2.5-flash" in BROWSER_USE_LLM_VALUES
11+
else BROWSER_USE_LLM_VALUES[0]
12+
)
13+
514

615
def get_scrape_options(formats: Optional[List[scrape_types]] = None):
716
formats = formats or ["markdown"]
@@ -134,22 +143,8 @@ def get_scrape_options(formats: Optional[List[scrape_types]] = None):
134143

135144
BROWSER_USE_LLM_SCHEMA = {
136145
"type": "string",
137-
"enum": [
138-
"gpt-4o",
139-
"gpt-4o-mini",
140-
"gpt-4.1",
141-
"gpt-4.1-mini",
142-
"gpt-5",
143-
"gpt-5-mini",
144-
"claude-sonnet-4-5",
145-
"claude-sonnet-4-20250514",
146-
"claude-3-7-sonnet-20250219",
147-
"claude-3-5-sonnet-20241022",
148-
"claude-3-5-haiku-20241022",
149-
"gemini-2.0-flash",
150-
"gemini-2.5-flash",
151-
],
152-
"default": "gemini-2.5-flash",
146+
"enum": BROWSER_USE_LLM_VALUES,
147+
"default": BROWSER_USE_DEFAULT_LLM,
153148
}
154149

155150
BROWSER_USE_SCHEMA = {
@@ -161,15 +156,15 @@ def get_scrape_options(formats: Optional[List[scrape_types]] = None):
161156
},
162157
"llm": {
163158
**BROWSER_USE_LLM_SCHEMA,
164-
"description": "The language model (LLM) instance to use for generating actions. Defaults to gemini-2.5-flash.",
159+
"description": f"The language model (LLM) instance to use for generating actions. Defaults to {BROWSER_USE_DEFAULT_LLM}.",
165160
},
166161
"planner_llm": {
167162
**BROWSER_USE_LLM_SCHEMA,
168-
"description": "The language model to use specifically for planning future actions, can differ from the main LLM. Defaults to gemini-2.5-flash.",
163+
"description": f"The language model to use specifically for planning future actions, can differ from the main LLM. Defaults to {BROWSER_USE_DEFAULT_LLM}.",
169164
},
170165
"page_extraction_llm": {
171166
**BROWSER_USE_LLM_SCHEMA,
172-
"description": "The language model to use for extracting structured data from webpages. Defaults to gemini-2.5-flash.",
167+
"description": f"The language model to use for extracting structured data from webpages. Defaults to {BROWSER_USE_DEFAULT_LLM}.",
173168
},
174169
"keep_browser_open": {
175170
"type": "boolean",

0 commit comments

Comments
 (0)