Skip to main content

No project description provided

Project description

Skyvern Langchain

This is a langchain integration for Skyvern.

Installation

pip install skyvern-langchain

Usage

Run a task(sync) with notebook style (code block)

:warning: :warning: if you want to run this code block, you need to run skvyern init command in your terminal to set up skyvern first.

import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from skyvern_langchain.agent import run_observer_task_v_2

load_dotenv()

llm = ChatOpenAI(model="gpt-4o", temperature=0)

agent = initialize_agent(
    llm=llm,
    tools=[run_observer_task_v_2],
    verbose=True,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)


async def main():
    # to run skyvern agent locally, must run `skvyern init` first
    print(await agent.ainvoke("Create a task by Skyvern. The task is about 'Navigate to the Hacker News homepage and get the top 3 posts.'"))


if __name__ == "__main__":
    asyncio.run(main())

Run a task(async) with notebook style (code block)

:warning: :warning: if you want to run this code block, you need to run skvyern init command in your terminal to set up skyvern first.

import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from skyvern_langchain.agent import create_observer_task_v_2, get_observer_task_v_2

from langchain_community.tools.sleep.tool import SleepTool

load_dotenv()

llm = ChatOpenAI(model="gpt-4o", temperature=0)

agent = initialize_agent(
    llm=llm,
    tools=[
        create_observer_task_v_2,
        get_observer_task_v_2,
        SleepTool(),
    ],
    verbose=True,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)


async def main():
    # use sleep tool to set up the polling logic until the task is completed, if you only want to run the create task, you can remove the sleep tool
    print(await agent.ainvoke("Create a task by Skyvern. The task is about 'Navigate to the Hacker News homepage and get the top 3 posts.' Then, get this task information until it's completed. The task information re-get interval should be 60s."))


if __name__ == "__main__":
    asyncio.run(main())

Run a task(sync) with client style (callling skyvern cloud api)

no need to run skvyern init command in your terminal to set up skyvern before using this integration.

import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from skyvern_langchain.client import RunSkyvernClientObserverTaskTool

load_dotenv()

llm = ChatOpenAI(model="gpt-4o", temperature=0)

run_observer_task = RunSkyvernClientObserverTaskTool(
    credential="<your_organization_api_key>",
)

agent = initialize_agent(
    llm=llm,
    tools=[run_observer_task],
    verbose=True,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)

print(await agent.ainvoke("Create a task by Skyvern. The task is about 'Navigate to the Hacker News homepage and get the top 3 posts.'"))

Run a task(async) with client style (callling skyvern cloud api)

no need to run skvyern init command in your terminal to set up skyvern before using this integration.

import asyncio
from dotenv import load_dotenv
from langchain_openai import ChatOpenAI
from langchain.agents import initialize_agent, AgentType
from skyvern_langchain.client import (
    RunSkyvernClientTaskTool,
    RunSkyvernClientObserverTaskTool,
    CreateSkyvernClientTaskTool,
    GetSkyvernClientTaskTool,
    CreateSkyvernClientObserverTaskV2Tool,
    GetSkyvernClientObserverTaskV2Tool,
)

from langchain_community.tools.sleep.tool import SleepTool

load_dotenv()

llm = ChatOpenAI(model="gpt-4o", temperature=0)

create_observer_task_v_2 = CreateSkyvernClientObserverTaskV2Tool(
    credential="<your_organization_api_key>",
)

get_observer_task_v_2 = GetSkyvernClientObserverTaskV2Tool(
    credential="<your_organization_api_key>",
)

agent = initialize_agent(
    llm=llm,
    tools=[
        create_observer_task_v_2,
        get_observer_task_v_2,
        SleepTool(),
    ],
    verbose=True,
    agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)


async def main():
    # use sleep tool to set up the polling logic until the task is completed, if you only want to run the create task, you can remove the sleep tool
    print(await agent.ainvoke("Create a task by Skyvern. The task is about 'Navigate to the Hacker News homepage and get the top 3 posts.' Then, get this task information until it's completed. The task information re-get interval should be 60s."))


if __name__ == "__main__":
    asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

skyvern_langchain-0.1.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

skyvern_langchain-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file skyvern_langchain-0.1.0.tar.gz.

File metadata

  • Download URL: skyvern_langchain-0.1.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for skyvern_langchain-0.1.0.tar.gz
Algorithm Hash digest
SHA256 533d69361bba37a151985c364b9f8a3c5cdf700c1d9fead9dc2f93907a9b0aaf
MD5 e322fa34f9db506a3489895493e0c636
BLAKE2b-256 9c10cca95917a065835a784c4b58c9c691130fc6e42808a06f424df1103bbec1

See more details on using hashes here.

File details

Details for the file skyvern_langchain-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for skyvern_langchain-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f723e0668c381f37a9a58b621eea16b2e196a3fb6bab341c91c6805bfbf1b2f6
MD5 099a20f2d9b0958dfb0848450b65c72e
BLAKE2b-256 a341194122bda8179f9dd93b339ee69bfb1453118796dc3dc774acb61e5b640c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page