fix: use navigation_goal/data_extraction_goal for self-hosted Skyvern API
Cloud API uses 'prompt', self-hosted uses 'navigation_goal' and 'data_extraction_goal'. Pass them separately. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,16 +16,17 @@ POLL_INTERVAL = 5 # seconds
|
|||||||
MAX_POLL_TIME = 300 # 5 minutes
|
MAX_POLL_TIME = 300 # 5 minutes
|
||||||
|
|
||||||
|
|
||||||
async def _create_task(url: str, goal: str, extraction_schema: dict | None = None,
|
async def _create_task(url: str, goal: str, extraction_goal: str = "",
|
||||||
|
extraction_schema: dict | None = None,
|
||||||
credential_id: str | None = None, totp_identifier: str | None = None) -> str:
|
credential_id: str | None = None, totp_identifier: str | None = None) -> str:
|
||||||
"""Create a Skyvern task and return the run_id."""
|
"""Create a Skyvern task and return the task_id."""
|
||||||
payload: dict = {
|
payload: dict = {
|
||||||
"prompt": goal,
|
|
||||||
"url": url,
|
"url": url,
|
||||||
"engine": "skyvern-v2",
|
"navigation_goal": goal,
|
||||||
|
"data_extraction_goal": extraction_goal or goal,
|
||||||
}
|
}
|
||||||
if extraction_schema:
|
if extraction_schema:
|
||||||
payload["data_extraction_schema"] = extraction_schema
|
payload["extracted_information_schema"] = extraction_schema
|
||||||
if credential_id:
|
if credential_id:
|
||||||
payload["credential_id"] = credential_id
|
payload["credential_id"] = credential_id
|
||||||
if totp_identifier:
|
if totp_identifier:
|
||||||
@@ -82,10 +83,8 @@ async def execute_browser_scrape(job: dict, send_text, **_kwargs) -> dict:
|
|||||||
target_room = job["targetRoom"]
|
target_room = job["targetRoom"]
|
||||||
config = job.get("config", {})
|
config = job.get("config", {})
|
||||||
url = config.get("url", "")
|
url = config.get("url", "")
|
||||||
extraction_goal = config.get("extractionGoal", "")
|
|
||||||
goal = config.get("goal", config.get("query", f"Scrape content from {url}"))
|
goal = config.get("goal", config.get("query", f"Scrape content from {url}"))
|
||||||
if extraction_goal:
|
extraction_goal = config.get("extractionGoal", "") or goal
|
||||||
goal += f"\n\nExtract the following: {extraction_goal}"
|
|
||||||
extraction_schema = config.get("extractionSchema")
|
extraction_schema = config.get("extractionSchema")
|
||||||
browser_profile = job.get("browserProfile")
|
browser_profile = job.get("browserProfile")
|
||||||
|
|
||||||
@@ -118,6 +117,7 @@ async def execute_browser_scrape(job: dict, send_text, **_kwargs) -> dict:
|
|||||||
run_id = await _create_task(
|
run_id = await _create_task(
|
||||||
url=url,
|
url=url,
|
||||||
goal=goal,
|
goal=goal,
|
||||||
|
extraction_goal=extraction_goal,
|
||||||
extraction_schema=extraction_schema,
|
extraction_schema=extraction_schema,
|
||||||
credential_id=credential_id,
|
credential_id=credential_id,
|
||||||
totp_identifier=totp_identifier,
|
totp_identifier=totp_identifier,
|
||||||
|
|||||||
@@ -42,20 +42,15 @@ async def execute_skyvern(config: dict, send_text=None, target_room: str = "", *
|
|||||||
if not url or not goal:
|
if not url or not goal:
|
||||||
raise ValueError("Skyvern step requires 'url' and 'goal' in config")
|
raise ValueError("Skyvern step requires 'url' and 'goal' in config")
|
||||||
|
|
||||||
# Build prompt combining goal and extraction goal
|
|
||||||
prompt = goal
|
|
||||||
if data_extraction_goal:
|
|
||||||
prompt += f"\n\nExtract the following: {data_extraction_goal}"
|
|
||||||
|
|
||||||
payload: dict = {
|
payload: dict = {
|
||||||
"prompt": prompt,
|
|
||||||
"url": url,
|
"url": url,
|
||||||
"engine": "skyvern-v2",
|
"navigation_goal": goal,
|
||||||
|
"data_extraction_goal": data_extraction_goal or goal,
|
||||||
}
|
}
|
||||||
if extraction_schema:
|
if extraction_schema:
|
||||||
if isinstance(extraction_schema, str):
|
if isinstance(extraction_schema, str):
|
||||||
extraction_schema = json.loads(extraction_schema)
|
extraction_schema = json.loads(extraction_schema)
|
||||||
payload["data_extraction_schema"] = extraction_schema
|
payload["extracted_information_schema"] = extraction_schema
|
||||||
if credential_id:
|
if credential_id:
|
||||||
payload["credential_id"] = credential_id
|
payload["credential_id"] = credential_id
|
||||||
if totp_identifier:
|
if totp_identifier:
|
||||||
|
|||||||
Reference in New Issue
Block a user