Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .fernignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

src/scrapybara/client.py
src/scrapybara/anthropic/
src/scrapybara/herd/
src/scrapybara/prompts/
src/scrapybara/tools/
src/scrapybara/types/__init__.py
Expand Down
18 changes: 9 additions & 9 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "scrapybara"
version = "2.2.7"
version = "2.2.8"
description = ""
readme = "README.md"
authors = []
Expand Down Expand Up @@ -32,7 +32,7 @@ Repository = 'https://github.com/scrapybara/scrapybara-python'

[tool.poetry.dependencies]
python = "^3.8"
anthropic = "^0.39.0"
anthropic = "^0.47.2"
httpx = ">=0.21.2"
playwright = "^1.48.0"
pydantic = ">= 1.9.2"
Expand Down
73 changes: 73 additions & 0 deletions reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,79 @@ client.browser.save_auth(
</dl>


</dd>
</dl>
</details>

<details><summary><code>client.browser.<a href="src/scrapybara/browser/client.py">modify_auth</a>(...)</code></summary>
<dl>
<dd>

#### 🔌 Usage

<dl>
<dd>

<dl>
<dd>

```python
from scrapybara import Scrapybara

client = Scrapybara(
api_key="YOUR_API_KEY",
)
client.browser.modify_auth(
instance_id="instance_id",
auth_state_id="auth_state_id",
)

```
</dd>
</dl>
</dd>
</dl>

#### ⚙️ Parameters

<dl>
<dd>

<dl>
<dd>

**instance_id:** `str`

</dd>
</dl>

<dl>
<dd>

**auth_state_id:** `str`

</dd>
</dl>

<dl>
<dd>

**name:** `typing.Optional[str]`

</dd>
</dl>

<dl>
<dd>

**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration.

</dd>
</dl>
</dd>
</dl>


</dd>
</dl>
</details>
Expand Down
2 changes: 2 additions & 0 deletions src/scrapybara/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
InstanceGetStreamUrlResponse,
InstanceScreenshotResponse,
KernelInfo,
ModifyBrowserAuthResponse,
Notebook,
NotebookCell,
SaveBrowserAuthResponse,
Expand Down Expand Up @@ -54,6 +55,7 @@
"InstanceGetStreamUrlResponse",
"InstanceScreenshotResponse",
"KernelInfo",
"ModifyBrowserAuthResponse",
"Notebook",
"NotebookCell",
"SaveBrowserAuthResponse",
Expand Down
6 changes: 4 additions & 2 deletions src/scrapybara/anthropic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ class Anthropic(Model):
"""Model adapter for Anthropic.

Supported models:
- claude-3-7-sonnet-20250219 (1x agent credit if no api_key)
- claude-3-7-sonnet-20250219-thinking (1x agent credit if no api_key)
- claude-3-5-sonnet-20241022 (1x agent credit if no api_key)

Args:
name: Anthropic model name, defaults to "claude-3-5-sonnet-20241022"
name: Anthropic model name, defaults to "claude-3-7-sonnet-20250219"
api_key: Optional Anthropic API key

Returns:
Expand All @@ -31,7 +33,7 @@ class Anthropic(Model):

def __init__(
self,
name: Optional[str] = "claude-3-5-sonnet-20241022",
name: Optional[str] = "claude-3-7-sonnet-20250219",
api_key: Optional[str] = None,
) -> None:
super().__init__(provider="anthropic", name=name, api_key=api_key)
Expand Down
149 changes: 149 additions & 0 deletions src/scrapybara/browser/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ..core.api_error import ApiError
from ..types.browser_get_cdp_url_response import BrowserGetCdpUrlResponse
from ..types.save_browser_auth_response import SaveBrowserAuthResponse
from ..types.modify_browser_auth_response import ModifyBrowserAuthResponse
from ..types.browser_authenticate_response import BrowserAuthenticateResponse
from ..types.stop_browser_response import StopBrowserResponse
from ..core.client_wrapper import AsyncClientWrapper
Expand Down Expand Up @@ -198,6 +199,76 @@ def save_auth(
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def modify_auth(
self,
instance_id: str,
*,
auth_state_id: str,
name: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> ModifyBrowserAuthResponse:
"""
Parameters
----------
instance_id : str

auth_state_id : str

name : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
ModifyBrowserAuthResponse
Successful Response

Examples
--------
from scrapybara import Scrapybara

client = Scrapybara(
api_key="YOUR_API_KEY",
)
client.browser.modify_auth(
instance_id="instance_id",
auth_state_id="auth_state_id",
)
"""
_response = self._client_wrapper.httpx_client.request(
f"v1/instance/{jsonable_encoder(instance_id)}/browser/modify_auth",
method="POST",
params={
"auth_state_id": auth_state_id,
"name": name,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
ModifyBrowserAuthResponse,
parse_obj_as(
type_=ModifyBrowserAuthResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
typing.cast(
HttpValidationError,
parse_obj_as(
type_=HttpValidationError, # type: ignore
object_=_response.json(),
),
)
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

def authenticate(
self, instance_id: str, *, auth_state_id: str, request_options: typing.Optional[RequestOptions] = None
) -> BrowserAuthenticateResponse:
Expand Down Expand Up @@ -520,6 +591,84 @@ async def main() -> None:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def modify_auth(
self,
instance_id: str,
*,
auth_state_id: str,
name: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> ModifyBrowserAuthResponse:
"""
Parameters
----------
instance_id : str

auth_state_id : str

name : typing.Optional[str]

request_options : typing.Optional[RequestOptions]
Request-specific configuration.

Returns
-------
ModifyBrowserAuthResponse
Successful Response

Examples
--------
import asyncio

from scrapybara import AsyncScrapybara

client = AsyncScrapybara(
api_key="YOUR_API_KEY",
)


async def main() -> None:
await client.browser.modify_auth(
instance_id="instance_id",
auth_state_id="auth_state_id",
)


asyncio.run(main())
"""
_response = await self._client_wrapper.httpx_client.request(
f"v1/instance/{jsonable_encoder(instance_id)}/browser/modify_auth",
method="POST",
params={
"auth_state_id": auth_state_id,
"name": name,
},
request_options=request_options,
)
try:
if 200 <= _response.status_code < 300:
return typing.cast(
ModifyBrowserAuthResponse,
parse_obj_as(
type_=ModifyBrowserAuthResponse, # type: ignore
object_=_response.json(),
),
)
if _response.status_code == 422:
raise UnprocessableEntityError(
typing.cast(
HttpValidationError,
parse_obj_as(
type_=HttpValidationError, # type: ignore
object_=_response.json(),
),
)
)
_response_json = _response.json()
except JSONDecodeError:
raise ApiError(status_code=_response.status_code, body=_response.text)
raise ApiError(status_code=_response.status_code, body=_response_json)

async def authenticate(
self, instance_id: str, *, auth_state_id: str, request_options: typing.Optional[RequestOptions] = None
) -> BrowserAuthenticateResponse:
Expand Down
Loading
Loading