Skip to content

Commit 8fd161b

Browse files
Release 2.0.6
1 parent 46d491f commit 8fd161b

File tree

9 files changed

+352
-4
lines changed

9 files changed

+352
-4
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "browser-use-sdk"
33

44
[tool.poetry]
55
name = "browser-use-sdk"
6-
version = "2.0.5"
6+
version = "2.0.6"
77
description = "The official Python library for the Browser Use API"
88
readme = "README.md"
99
authors = []

reference.md

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,30 @@ client.tasks.create_task(
341341
<dl>
342342
<dd>
343343

344+
**judge:** `typing.Optional[bool]` — Enable judge mode to evaluate task completion against ground truth.
345+
346+
</dd>
347+
</dl>
348+
349+
<dl>
350+
<dd>
351+
352+
**judge_ground_truth:** `typing.Optional[str]` — Expected answer for judge evaluation.
353+
354+
</dd>
355+
</dl>
356+
357+
<dl>
358+
<dd>
359+
360+
**judge_llm:** `typing.Optional[SupportedLlMs]` — The LLM model to use for judging. If not provided, uses the default judge LLM.
361+
362+
</dd>
363+
</dl>
364+
365+
<dl>
366+
<dd>
367+
344368
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
345369

346370
</dd>
@@ -807,6 +831,76 @@ client.sessions.get_session(
807831
</dl>
808832

809833

834+
</dd>
835+
</dl>
836+
</details>
837+
838+
<details><summary><code>client.sessions.<a href="src/browser_use_sdk/sessions/client.py">delete_session</a>(...)</code></summary>
839+
<dl>
840+
<dd>
841+
842+
#### 📝 Description
843+
844+
<dl>
845+
<dd>
846+
847+
<dl>
848+
<dd>
849+
850+
Delete a session with all its tasks.
851+
</dd>
852+
</dl>
853+
</dd>
854+
</dl>
855+
856+
#### 🔌 Usage
857+
858+
<dl>
859+
<dd>
860+
861+
<dl>
862+
<dd>
863+
864+
```python
865+
from browser_use_sdk import BrowserUse
866+
867+
client = BrowserUse(
868+
api_key="YOUR_API_KEY",
869+
)
870+
client.sessions.delete_session(
871+
session_id="session_id",
872+
)
873+
874+
```
875+
</dd>
876+
</dl>
877+
</dd>
878+
</dl>
879+
880+
#### ⚙️ Parameters
881+
882+
<dl>
883+
<dd>
884+
885+
<dl>
886+
<dd>
887+
888+
**session_id:** `str`
889+
890+
</dd>
891+
</dl>
892+
893+
<dl>
894+
<dd>
895+
896+
**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.
897+
898+
</dd>
899+
</dl>
900+
</dd>
901+
</dl>
902+
903+
810904
</dd>
811905
</dl>
812906
</details>

src/browser_use_sdk/core/client_wrapper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ def __init__(
2222

2323
def get_headers(self) -> typing.Dict[str, str]:
2424
headers: typing.Dict[str, str] = {
25-
"User-Agent": "browser-use-sdk/2.0.5",
25+
"User-Agent": "browser-use-sdk/2.0.6",
2626
"X-Fern-Language": "Python",
2727
"X-Fern-SDK-Name": "browser-use-sdk",
28-
"X-Fern-SDK-Version": "2.0.5",
28+
"X-Fern-SDK-Version": "2.0.6",
2929
**(self.get_custom_headers() or {}),
3030
}
3131
headers["X-Browser-Use-API-Key"] = self.api_key

src/browser_use_sdk/sessions/client.py

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,35 @@ def get_session(self, session_id: str, *, request_options: typing.Optional[Reque
149149
_response = self._raw_client.get_session(session_id, request_options=request_options)
150150
return _response.data
151151

152+
def delete_session(self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
153+
"""
154+
Delete a session with all its tasks.
155+
156+
Parameters
157+
----------
158+
session_id : str
159+
160+
request_options : typing.Optional[RequestOptions]
161+
Request-specific configuration.
162+
163+
Returns
164+
-------
165+
None
166+
167+
Examples
168+
--------
169+
from browser_use_sdk import BrowserUse
170+
171+
client = BrowserUse(
172+
api_key="YOUR_API_KEY",
173+
)
174+
client.sessions.delete_session(
175+
session_id="session_id",
176+
)
177+
"""
178+
_response = self._raw_client.delete_session(session_id, request_options=request_options)
179+
return _response.data
180+
152181
def update_session(
153182
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
154183
) -> SessionView:
@@ -436,6 +465,43 @@ async def main() -> None:
436465
_response = await self._raw_client.get_session(session_id, request_options=request_options)
437466
return _response.data
438467

468+
async def delete_session(self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None) -> None:
469+
"""
470+
Delete a session with all its tasks.
471+
472+
Parameters
473+
----------
474+
session_id : str
475+
476+
request_options : typing.Optional[RequestOptions]
477+
Request-specific configuration.
478+
479+
Returns
480+
-------
481+
None
482+
483+
Examples
484+
--------
485+
import asyncio
486+
487+
from browser_use_sdk import AsyncBrowserUse
488+
489+
client = AsyncBrowserUse(
490+
api_key="YOUR_API_KEY",
491+
)
492+
493+
494+
async def main() -> None:
495+
await client.sessions.delete_session(
496+
session_id="session_id",
497+
)
498+
499+
500+
asyncio.run(main())
501+
"""
502+
_response = await self._raw_client.delete_session(session_id, request_options=request_options)
503+
return _response.data
504+
439505
async def update_session(
440506
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
441507
) -> SessionView:

src/browser_use_sdk/sessions/raw_client.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,58 @@ def get_session(
243243
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
244244
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
245245

246+
def delete_session(
247+
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
248+
) -> HttpResponse[None]:
249+
"""
250+
Delete a session with all its tasks.
251+
252+
Parameters
253+
----------
254+
session_id : str
255+
256+
request_options : typing.Optional[RequestOptions]
257+
Request-specific configuration.
258+
259+
Returns
260+
-------
261+
HttpResponse[None]
262+
"""
263+
_response = self._client_wrapper.httpx_client.request(
264+
f"sessions/{jsonable_encoder(session_id)}",
265+
method="DELETE",
266+
request_options=request_options,
267+
)
268+
try:
269+
if 200 <= _response.status_code < 300:
270+
return HttpResponse(response=_response, data=None)
271+
if _response.status_code == 404:
272+
raise NotFoundError(
273+
headers=dict(_response.headers),
274+
body=typing.cast(
275+
typing.Optional[typing.Any],
276+
construct_type(
277+
type_=typing.Optional[typing.Any], # type: ignore
278+
object_=_response.json(),
279+
),
280+
),
281+
)
282+
if _response.status_code == 422:
283+
raise UnprocessableEntityError(
284+
headers=dict(_response.headers),
285+
body=typing.cast(
286+
typing.Optional[typing.Any],
287+
construct_type(
288+
type_=typing.Optional[typing.Any], # type: ignore
289+
object_=_response.json(),
290+
),
291+
),
292+
)
293+
_response_json = _response.json()
294+
except JSONDecodeError:
295+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
296+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
297+
246298
def update_session(
247299
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
248300
) -> HttpResponse[SessionView]:
@@ -702,6 +754,58 @@ async def get_session(
702754
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
703755
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
704756

757+
async def delete_session(
758+
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
759+
) -> AsyncHttpResponse[None]:
760+
"""
761+
Delete a session with all its tasks.
762+
763+
Parameters
764+
----------
765+
session_id : str
766+
767+
request_options : typing.Optional[RequestOptions]
768+
Request-specific configuration.
769+
770+
Returns
771+
-------
772+
AsyncHttpResponse[None]
773+
"""
774+
_response = await self._client_wrapper.httpx_client.request(
775+
f"sessions/{jsonable_encoder(session_id)}",
776+
method="DELETE",
777+
request_options=request_options,
778+
)
779+
try:
780+
if 200 <= _response.status_code < 300:
781+
return AsyncHttpResponse(response=_response, data=None)
782+
if _response.status_code == 404:
783+
raise NotFoundError(
784+
headers=dict(_response.headers),
785+
body=typing.cast(
786+
typing.Optional[typing.Any],
787+
construct_type(
788+
type_=typing.Optional[typing.Any], # type: ignore
789+
object_=_response.json(),
790+
),
791+
),
792+
)
793+
if _response.status_code == 422:
794+
raise UnprocessableEntityError(
795+
headers=dict(_response.headers),
796+
body=typing.cast(
797+
typing.Optional[typing.Any],
798+
construct_type(
799+
type_=typing.Optional[typing.Any], # type: ignore
800+
object_=_response.json(),
801+
),
802+
),
803+
)
804+
_response_json = _response.json()
805+
except JSONDecodeError:
806+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
807+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
808+
705809
async def update_session(
706810
self, session_id: str, *, request_options: typing.Optional[RequestOptions] = None
707811
) -> AsyncHttpResponse[SessionView]:

src/browser_use_sdk/tasks/client.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ def create_task(
108108
thinking: typing.Optional[bool] = OMIT,
109109
vision: typing.Optional[CreateTaskRequestVision] = OMIT,
110110
system_prompt_extension: typing.Optional[str] = OMIT,
111+
judge: typing.Optional[bool] = OMIT,
112+
judge_ground_truth: typing.Optional[str] = OMIT,
113+
judge_llm: typing.Optional[SupportedLlMs] = OMIT,
111114
request_options: typing.Optional[RequestOptions] = None,
112115
) -> TaskCreatedResponse:
113116
"""
@@ -162,6 +165,15 @@ def create_task(
162165
system_prompt_extension : typing.Optional[str]
163166
Optional extension to the agent system prompt.
164167
168+
judge : typing.Optional[bool]
169+
Enable judge mode to evaluate task completion against ground truth.
170+
171+
judge_ground_truth : typing.Optional[str]
172+
Expected answer for judge evaluation.
173+
174+
judge_llm : typing.Optional[SupportedLlMs]
175+
The LLM model to use for judging. If not provided, uses the default judge LLM.
176+
165177
request_options : typing.Optional[RequestOptions]
166178
Request-specific configuration.
167179
@@ -197,6 +209,9 @@ def create_task(
197209
thinking=thinking,
198210
vision=vision,
199211
system_prompt_extension=system_prompt_extension,
212+
judge=judge,
213+
judge_ground_truth=judge_ground_truth,
214+
judge_llm=judge_llm,
200215
request_options=request_options,
201216
)
202217
return _response.data
@@ -397,6 +412,9 @@ async def create_task(
397412
thinking: typing.Optional[bool] = OMIT,
398413
vision: typing.Optional[CreateTaskRequestVision] = OMIT,
399414
system_prompt_extension: typing.Optional[str] = OMIT,
415+
judge: typing.Optional[bool] = OMIT,
416+
judge_ground_truth: typing.Optional[str] = OMIT,
417+
judge_llm: typing.Optional[SupportedLlMs] = OMIT,
400418
request_options: typing.Optional[RequestOptions] = None,
401419
) -> TaskCreatedResponse:
402420
"""
@@ -451,6 +469,15 @@ async def create_task(
451469
system_prompt_extension : typing.Optional[str]
452470
Optional extension to the agent system prompt.
453471
472+
judge : typing.Optional[bool]
473+
Enable judge mode to evaluate task completion against ground truth.
474+
475+
judge_ground_truth : typing.Optional[str]
476+
Expected answer for judge evaluation.
477+
478+
judge_llm : typing.Optional[SupportedLlMs]
479+
The LLM model to use for judging. If not provided, uses the default judge LLM.
480+
454481
request_options : typing.Optional[RequestOptions]
455482
Request-specific configuration.
456483
@@ -494,6 +521,9 @@ async def main() -> None:
494521
thinking=thinking,
495522
vision=vision,
496523
system_prompt_extension=system_prompt_extension,
524+
judge=judge,
525+
judge_ground_truth=judge_ground_truth,
526+
judge_llm=judge_llm,
497527
request_options=request_options,
498528
)
499529
return _response.data

0 commit comments

Comments
 (0)