No project description provided
Project description
Table of Contents generated with DocToc
- Skyvern Langchain
- Installation
- Usage
- Run a task(sync) with skyvern agent (calling skyvern agent function directly in the tool)
- Run a task(async) with skyvern agent (calling skyvern agent function directly in the tool)
- Run a task(sync) with skyvern client (calling skyvern OpenAPI in the tool)
- Run a task(async) with skyvern client (calling skyvern OpenAPI in the tool)
Skyvern Langchain
This is a langchain integration for Skyvern.
Installation
pip install skyvern-langchain
Usage
Run a task(sync) with skyvern agent (calling skyvern agent function directly in the tool)
sync task won't return until the task is finished.
:warning: :warning: if you want to run this code block, you need to run skyvern 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_task_v2
load_dotenv()
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = initialize_agent(
llm=llm,
tools=[run_task_v2],
verbose=True,
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)
async def main():
# to run skyvern agent locally, must run `skyvern init` first
print(await agent.ainvoke("Run a task with 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 skyvern agent (calling skyvern agent function directly in the tool)
async task will return immediately and the task will be running in the background. You can use
get_task_v2tool to poll the task information until the task is finished.
:warning: :warning: if you want to run this code block, you need to run skyvern 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 queue_task_v2, get_task_v2
from langchain_community.tools.sleep.tool import SleepTool
load_dotenv()
llm = ChatOpenAI(model="gpt-4o", temperature=0)
agent = initialize_agent(
llm=llm,
tools=[
queue_task_v2,
get_task_v2,
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 queue a task, you can remove the sleep tool
print(await agent.ainvoke("Queue a task with 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 skyvern client (calling skyvern OpenAPI in the tool)
sync task won't return until the task is finished.
no need to run skyvern 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 RunSkyvernClientTaskV2Tool
load_dotenv()
llm = ChatOpenAI(model="gpt-4o", temperature=0)
run_task_v2 = RunSkyvernClientTaskV2Tool(
credential="<your_organization_api_key>",
)
agent = initialize_agent(
llm=llm,
tools=[run_task_v2],
verbose=True,
agent=AgentType.STRUCTURED_CHAT_ZERO_SHOT_REACT_DESCRIPTION,
)
async def main():
print(await agent.ainvoke("Run a task with 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 skyvern client (calling skyvern OpenAPI in the tool)
async task will return immediately and the task will be running in the background. You can use
GetSkyvernClientTaskV2Tooltool to poll the task information until the task is finished.
no need to run skyvern 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 (
QueueSkyvernClientTaskV2Tool,
GetSkyvernClientTaskV2Tool,
)
from langchain_community.tools.sleep.tool import SleepTool
load_dotenv()
llm = ChatOpenAI(model="gpt-4o", temperature=0)
queue_task_v2 = QueueSkyvernClientTaskV2Tool(
credential="<your_organization_api_key>",
)
get_task_v2 = GetSkyvernClientTaskV2Tool(
credential="<your_organization_api_key>",
)
agent = initialize_agent(
llm=llm,
tools=[
queue_task_v2,
get_task_v2,
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 queue a task, you can remove the sleep tool
print(await agent.ainvoke("Queue a task with 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skyvern_langchain-0.0.1.tar.gz.
File metadata
- Download URL: skyvern_langchain-0.0.1.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71a004bb73563760bc9a5ada142c8d9e7af4f6ecc9cc42403c0095a67ab14296
|
|
| MD5 |
f8a8b9851c4383ed8ede728ea581299d
|
|
| BLAKE2b-256 |
b02935338027484f893cb030dd51c62255977530d97c73056f61ea762c151331
|
File details
Details for the file skyvern_langchain-0.0.1-py3-none-any.whl.
File metadata
- Download URL: skyvern_langchain-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e702c437a4afa7e5616f146e267dacdc4e353bbb4498ef24d4311be7f95ed4db
|
|
| MD5 |
9fc28abe97ce5414fc5b293947037eba
|
|
| BLAKE2b-256 |
82bfd30e39b8d5fcf4158fa34b8d610b4e8dddb6b5447109754914dd8d6bf4e0
|