From 52f9da8633133274f17b8ecd88c8881d40929060 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 6 Mar 2025 01:10:26 +0000 Subject: [PATCH 1/4] SDK regeneration --- pyproject.toml | 5 ++++- src/scrapybara/core/client_wrapper.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 56d4bed..ccb1c22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,9 @@ +[project] +name = "scrapybara" + [tool.poetry] name = "scrapybara" -version = "2.3.0" +version = "2.3.1" description = "" readme = "README.md" authors = [] diff --git a/src/scrapybara/core/client_wrapper.py b/src/scrapybara/core/client_wrapper.py index 1c86f52..eb85936 100644 --- a/src/scrapybara/core/client_wrapper.py +++ b/src/scrapybara/core/client_wrapper.py @@ -16,7 +16,7 @@ def get_headers(self) -> typing.Dict[str, str]: headers: typing.Dict[str, str] = { "X-Fern-Language": "Python", "X-Fern-SDK-Name": "scrapybara", - "X-Fern-SDK-Version": "2.3.0", + "X-Fern-SDK-Version": "2.3.1", } headers["x-api-key"] = self.api_key return headers From 0cd2e0d1d9923754e608864ea047c840f5aa7998 Mon Sep 17 00:00:00 2001 From: Justin Sun Date: Wed, 5 Mar 2025 18:13:57 -0800 Subject: [PATCH 2/4] feat: update prompts + move to model folder --- src/scrapybara/anthropic/__init__.py | 92 ++++++++++++++++++++++++++++ src/scrapybara/prompts/__init__.py | 26 +++++--- 2 files changed, 108 insertions(+), 10 deletions(-) diff --git a/src/scrapybara/anthropic/__init__.py b/src/scrapybara/anthropic/__init__.py index 7c54d8e..8a10c24 100644 --- a/src/scrapybara/anthropic/__init__.py +++ b/src/scrapybara/anthropic/__init__.py @@ -3,6 +3,7 @@ from pydantic import Field from ..types.act import Model +from datetime import datetime class Anthropic(Model): @@ -29,3 +30,94 @@ def __init__( api_key: Optional[str] = None, ) -> None: super().__init__(provider="anthropic", name=name, api_key=api_key) + + +UBUNTU_SYSTEM_PROMPT = f""" +* You have access to an Ubuntu VM with internet connectivity +* You can install Ubuntu applications using the bash tool (use curl over wget) +* To run GUI applications with the bash tool, use a subshell, e.g. "(DISPLAY=:1 xterm &)", make sure to include the parantheses +* GUI apps will appear but may take time to load - confirm with an extra screenshot +* Chromium is the default browser +* Start Chromium via the bash tool "(DISPLAY=:1 chromium &)", but interact with it visually via the computer tool +* If you need to read a HTML file: + - Open with the address bar in Chromium +* For commands with large text output: + - Redirect to a temp file + - Use str_replace_editor or grep with context (-B and -A flags) to view output +* When viewing pages: + - Zoom out to see full content, or + - Scroll to ensure you see everything +* When interacting with a field, always clear the field first using "ctrl+A" and "delete" + - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field +* When using str_replace_editor, create files in the ~/ directory unless instructed otherwise +* Computer function calls take time, string together calls when possible +* You are allowed to take actions on behalf of the user on sites that are authenticated +* If the user asks you to access a site, assume that the user has already authenticated +* To login additional sites, ask the user to use Auth Contexts or the Interactive Desktop +* If first screenshot shows black screen: + - Click mouse in screen center + - Take another screenshot +* Today's date is {datetime.today().strftime('%A, %B %-d, %Y')} + + + +* If given a complex task, break down into smaller steps and ask the user for details only if necessary +* Read through web pages thoroughly by scrolling down till you have gathered enough info +* Be concise! +""" +"""Recommended Anthropic system prompt for Ubuntu instances""" + + +BROWSER_SYSTEM_PROMPT = f""" +* You have access to a Chromium VM with internet connectivity +* Chromium should already be open and running +* You can interact with web pages using the computer tool +* When viewing pages: + - Zoom out to see full content, or + - Scroll to ensure you see everything +* When interacting with a field, always clear the field first using "ctrl+A" and "delete" + - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field +* Computer function calls take time, string together calls when possible +* You are allowed to take actions on behalf of the user on sites that are authenticated +* If the user asks you to access a site, assume that the user has already authenticated +* To login additional sites, ask the user to use Auth Contexts +* If first screenshot shows black screen: + - Click mouse in screen center + - Take another screenshot +* Today's date is {datetime.today().strftime('%A, %B %-d, %Y')} + + + +* If given a complex task, break down into smaller steps and ask the user for details only if necessary +* Read through web pages thoroughly by scrolling down till you have gathered enough info +* Be concise! +""" +"""Recommended Anthropic system prompt for Browser instances""" + + +WINDOWS_SYSTEM_PROMPT = f""" +* You wave access to a Windows VM with internet connectivity +* You can interact with the Windows desktop using the computer tool +* GUI apps will appear but may take time to load - confirm with an extra screenshot +* Edge is the default browser +* When viewing pages: + - Zoom out to see full content, or + - Scroll to ensure you see everything +* When interacting with a field, always clear the field first using "ctrl+A" and "delete" + - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field +* Computer function calls take time, string together calls when possible +* You are allowed to take actions on behalf of the user on sites that are authenticated +* If the user asks you to access a site, assume that the user has already authenticated +* To login additional sites, ask the user to use Auth Contexts or the Interactive Desktop +* If first screenshot shows black screen: + - Click mouse in screen center + - Take another screenshot +* Today's date is {datetime.today().strftime('%A, %B %-d, %Y')} + + + +* If given a complex task, break down into smaller steps and ask the user for details only if necessary +* Read through web pages thoroughly by scrolling down till you have gathered enough info +* Be concise! +""" +"""Recommended Anthropic system prompt for Windows instances""" diff --git a/src/scrapybara/prompts/__init__.py b/src/scrapybara/prompts/__init__.py index e1cdf6e..4c8d83c 100644 --- a/src/scrapybara/prompts/__init__.py +++ b/src/scrapybara/prompts/__init__.py @@ -1,16 +1,12 @@ from datetime import datetime UBUNTU_SYSTEM_PROMPT = f""" -* You have access to an Ubuntu virtual machine with internet connectivity +* You have access to an Ubuntu VM with internet connectivity * You can install Ubuntu applications using the bash tool (use curl over wget) * To run GUI applications with the bash tool, use a subshell, e.g. "(DISPLAY=:1 xterm &)", make sure to include the parantheses * GUI apps will appear but may take time to load - confirm with an extra screenshot * Chromium is the default browser * Start Chromium via the bash tool "(DISPLAY=:1 chromium &)", but interact with it visually via the computer tool -* If you need to read a full PDF after initial screenshot - - Download with curl - - Convert to text using pdftotext - - Read the text file with StrReplaceEditTool * If you need to read a HTML file: - Open with the address bar in Chromium * For commands with large text output: @@ -21,6 +17,7 @@ - Scroll to ensure you see everything * When interacting with a field, always clear the field first using "ctrl+A" and "delete" - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field +* When using str_replace_editor, create files in the ~/ directory unless instructed otherwise * Computer function calls take time, string together calls when possible * You are allowed to take actions on behalf of the user on sites that are authenticated * If the user asks you to access a site, assume that the user has already authenticated @@ -33,13 +30,16 @@ * If given a complex task, break down into smaller steps and ask the user for details only if necessary -* Read through web pages thoroughly by scrolling down till the end +* Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ +"""DEPRECATED: Please import prompts from their respective models instead: + +from scrapybara.anthropic import UBUNTU_SYSTEM_PROMPT""" BROWSER_SYSTEM_PROMPT = f""" -* You have access to a Chromium browser instance with internet connectivity +* You have access to a Chromium VM with internet connectivity * Chromium should already be open and running * You can interact with web pages using the computer tool * When viewing pages: @@ -59,13 +59,16 @@ * If given a complex task, break down into smaller steps and ask the user for details only if necessary -* Read through web pages thoroughly by scrolling down till the end +* Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ +"""DEPRECATED: Please import prompts from their respective models instead: + +from scrapybara.anthropic import BROWSER_SYSTEM_PROMPT""" WINDOWS_SYSTEM_PROMPT = f""" -* You have access to a Windows virtual machine with internet connectivity +* You have access to a Windows VM with internet connectivity * You can interact with the Windows desktop using the computer tool * GUI apps will appear but may take time to load - confirm with an extra screenshot * Edge is the default browser @@ -86,6 +89,9 @@ * If given a complex task, break down into smaller steps and ask the user for details only if necessary -* Read through web pages thoroughly by scrolling down till the end +* Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ +"""DEPRECATED: Please import prompts from their respective models instead: + +from scrapybara.anthropic import WINDOWS_SYSTEM_PROMPT""" From 962df2e8e2637c1307244418420357f5a36c886c Mon Sep 17 00:00:00 2001 From: Justin Sun Date: Wed, 5 Mar 2025 18:21:23 -0800 Subject: [PATCH 3/4] feat: update prompts in test --- src/scrapybara/anthropic/__init__.py | 1 - src/scrapybara/prompts/__init__.py | 1 - tests/custom/test_client.py | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/scrapybara/anthropic/__init__.py b/src/scrapybara/anthropic/__init__.py index 8a10c24..8732edb 100644 --- a/src/scrapybara/anthropic/__init__.py +++ b/src/scrapybara/anthropic/__init__.py @@ -49,7 +49,6 @@ def __init__( - Scroll to ensure you see everything * When interacting with a field, always clear the field first using "ctrl+A" and "delete" - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field -* When using str_replace_editor, create files in the ~/ directory unless instructed otherwise * Computer function calls take time, string together calls when possible * You are allowed to take actions on behalf of the user on sites that are authenticated * If the user asks you to access a site, assume that the user has already authenticated diff --git a/src/scrapybara/prompts/__init__.py b/src/scrapybara/prompts/__init__.py index 4c8d83c..4951ac6 100644 --- a/src/scrapybara/prompts/__init__.py +++ b/src/scrapybara/prompts/__init__.py @@ -17,7 +17,6 @@ - Scroll to ensure you see everything * When interacting with a field, always clear the field first using "ctrl+A" and "delete" - Take an extra screenshot after clicking "enter" to confirm the field is properly submitted and move the mouse to the next field -* When using str_replace_editor, create files in the ~/ directory unless instructed otherwise * Computer function calls take time, string together calls when possible * You are allowed to take actions on behalf of the user on sites that are authenticated * If the user asks you to access a site, assume that the user has already authenticated diff --git a/tests/custom/test_client.py b/tests/custom/test_client.py index 894c531..78e296f 100644 --- a/tests/custom/test_client.py +++ b/tests/custom/test_client.py @@ -3,10 +3,10 @@ import os import pytest -from scrapybara.anthropic import Anthropic -from scrapybara.prompts import ( - BROWSER_SYSTEM_PROMPT, +from scrapybara.anthropic import ( + Anthropic, UBUNTU_SYSTEM_PROMPT, + BROWSER_SYSTEM_PROMPT, WINDOWS_SYSTEM_PROMPT, ) from scrapybara.tools import BashTool, ComputerTool, EditTool From 344b88ed7c79ede9b6c621147d6176ae54815b27 Mon Sep 17 00:00:00 2001 From: Justin Sun Date: Wed, 5 Mar 2025 18:29:41 -0800 Subject: [PATCH 4/4] feat: update deprecated docstrings --- src/scrapybara/prompts/__init__.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/scrapybara/prompts/__init__.py b/src/scrapybara/prompts/__init__.py index 4951ac6..a8d6108 100644 --- a/src/scrapybara/prompts/__init__.py +++ b/src/scrapybara/prompts/__init__.py @@ -32,9 +32,7 @@ * Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ -"""DEPRECATED: Please import prompts from their respective models instead: - -from scrapybara.anthropic import UBUNTU_SYSTEM_PROMPT""" +"""DEPRECATED — Please import prompts from their respective models instead: `from scrapybara.anthropic import UBUNTU_SYSTEM_PROMPT`""" BROWSER_SYSTEM_PROMPT = f""" @@ -61,9 +59,7 @@ * Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ -"""DEPRECATED: Please import prompts from their respective models instead: - -from scrapybara.anthropic import BROWSER_SYSTEM_PROMPT""" +"""DEPRECATED — Please import prompts from their respective models instead: `from scrapybara.anthropic import BROWSER_SYSTEM_PROMPT`""" WINDOWS_SYSTEM_PROMPT = f""" @@ -91,6 +87,4 @@ * Read through web pages thoroughly by scrolling down till you have gathered enough info * Be concise! """ -"""DEPRECATED: Please import prompts from their respective models instead: - -from scrapybara.anthropic import WINDOWS_SYSTEM_PROMPT""" +"""DEPRECATED — Please import prompts from their respective models instead: `from scrapybara.anthropic import WINDOWS_SYSTEM_PROMPT`"""