diff --git a/README.md b/README.md index 91d881f8..56492878 100644 --- a/README.md +++ b/README.md @@ -43,51 +43,96 @@ Want to see examples of Skyvern in action? Jump to [#real-world-examples-of-skyv If you'd like to try it out, navigate to [app.skyvern.com](https://app.skyvern.com) and create an account. -## Local Install & Run -> ⚠️ **REQUIREMENT**: This project requires at least Python 3.11 ⚠️ +## Install & Run +> ⚠️ **Supported Python Versions**: Python 3.11, 3.12, 3.13 ⚠️ -1. **Install Skyvern** +### 1. Install Skyvern ```bash pip install skyvern ``` -2. **Run Skyvern** +### 2. Run Skyvern ```bash skyvern quickstart ``` -3. **Run task** +### 3. Run task - Run a skyvern task locally: - ```python - from skyvern import Skyvern +```python +from skyvern import Skyvern - skyvern = Skyvern() - task = await skyvern.run_task(prompt="Find the top post on hackernews today") - print(task) - ``` - A local browser will pop up. Skyvern will start executing the task in the browser and close the it when the task is done. You will be able to review the task from http://localhost:8080/history +skyvern = Skyvern() +task = await skyvern.run_task(prompt="Find the top post on hackernews today") +print(task) +``` +A browser will pop up. Skyvern will start executing the task in the browser and close the it when the task is done. You will be able to review the task from http://localhost:8080/history + +You can also run a task autonomously on Skyvern Cloud: +```python +from skyvern import Skyvern + +skyvern = Skyvern(api_key="SKYVERN API KEY") +task = await skyvern.run_task(prompt="Find the top post on hackernews today") +print(task) +``` + +Or any hosted Skyvern service: +```python +skyvern = Skyvern(base_url="http://localhost:8000", api_key="SKYVERN API KEY") +task = await skyvern.run_task(prompt="Find the top post on hackernews today") +print(task) +``` + +Check out more features to use for Skyvern task in our [official doc](https://docs.skyvern.com/running-tasks/run-tasks). Here are a couple of interesting examples: +#### Let Skyvern control your own browser +Firstly, add two variables to your .env file: +``` +# This is the path to your local chromium-compatible browser. We're using Google Chrome in Mac as an example +CHROME_EXECUTABLE_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" +BROWSER_TYPE=cdp-connect +``` + +Secondly, make sure you quit your browser (Skyvern will restart it) and run the task: +```python +from skyvern import Skyvern + +skyvern = Skyvern() +task = await skyvern.run_task(prompt="Find the top post on hackernews today") +``` + +#### Get consistent output schema from your run +You can do this by adding the `data_extraction_schema` parameter: +```python +from skyvern import Skyvern + +skyvern = Skyvern() +task = await skyvern.run_task( + prompt="Find the top post on hackernews today", + data_extraction_schema={ + "type": "object", + "properties": { + "title": { + "type": "string", + "description": "The title of the top post" + }, + "url": { + "type": "string", + "description": "The URL of the top post" + }, + "points": { + "type": "integer", + "description": "Number of points the post has received" + } + } + } +) +``` - You can also run a task autonomously on Skyvern Cloud: - ```python - from skyvern import Skyvern - - skyvern = Skyvern(api_key="SKYVERN API KEY") - task = await skyvern.run_task(prompt="Find the top post on hackernews today") - print(task) - ``` - Or any hosted Skyvern service: - ```python - skyvern = Skyvern(base_url="http://localhost:8000", api_key="SKYVERN API KEY") - task = await skyvern.run_task(prompt="Find the top post on hackernews today") - print(task) - ``` ### Helpful commands to debug issues - **Launch the Skyvern Server Separately** ```bash diff --git a/pyproject.toml b/pyproject.toml index 42e612c5..51645ab0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "skyvern" -version = "0.1.86" +version = "0.1.87" description = "" authors = ["Skyvern AI "] readme = "README.md" diff --git a/skyvern/cli/run_commands.py b/skyvern/cli/run_commands.py index 672f297b..fa54fec8 100644 --- a/skyvern/cli/run_commands.py +++ b/skyvern/cli/run_commands.py @@ -12,6 +12,8 @@ from mcp.server.fastmcp import FastMCP from rich.panel import Panel from rich.prompt import Confirm +from skyvern.config import settings +from skyvern.library.skyvern import Skyvern from skyvern.utils import detect_os from .console import console @@ -21,6 +23,36 @@ run_app = typer.Typer(help="Commands to run Skyvern services such as the API ser mcp = FastMCP("Skyvern") +@mcp.tool() +async def skyvern_run_task(prompt: str, url: str) -> dict[str, str]: + """Use Skyvern to execute anything in the browser. Useful for accomplishing tasks that require browser automation. + + This tool uses Skyvern's browser automation to navigate websites and perform actions to achieve + the user's intended outcome. It can handle tasks like form filling, clicking buttons, data extraction, + and multi-step workflows. + + It can even help you find updated data on the internet if your model information is outdated. + + Args: + prompt: A natural language description of what needs to be accomplished (e.g. "Book a flight from + NYC to LA", "Sign up for the newsletter", "Find the price of item X", "Apply to a job") + url: The starting URL of the website where the task should be performed + """ + skyvern_agent = Skyvern( + base_url=settings.SKYVERN_BASE_URL, + api_key=settings.SKYVERN_API_KEY, + ) + res = await skyvern_agent.run_task(prompt=prompt, url=url, user_agent="skyvern-mcp", wait_for_completion=True) + + # TODO: It would be nice if we could return the task URL here + output = res.model_dump()["output"] + base_url = settings.SKYVERN_BASE_URL + run_history_url = ( + "https://app.skyvern.com/history" if "skyvern.com" in base_url else "http://localhost:8080/history" + ) + return {"output": output, "run_history_url": run_history_url} + + def get_pids_on_port(port: int) -> List[int]: """Return a list of PIDs listening on the given port.""" pids = [] diff --git a/skyvern/library/skyvern.py b/skyvern/library/skyvern.py index 93224d7b..c1cad06a 100644 --- a/skyvern/library/skyvern.py +++ b/skyvern/library/skyvern.py @@ -303,7 +303,7 @@ class Skyvern(AsyncSkyvern): data_extraction_schema: dict[str, Any] | str | None = None, proxy_location: ProxyLocation | None = None, max_steps: int | None = None, - wait_for_completion: bool = True, + wait_for_completion: bool = False, timeout: float = DEFAULT_AGENT_TIMEOUT, browser_session_id: str | None = None, user_agent: str | None = None,