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
|
||||
|
||||
|
||||
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:
|
||||
"""Create a Skyvern task and return the run_id."""
|
||||
"""Create a Skyvern task and return the task_id."""
|
||||
payload: dict = {
|
||||
"prompt": goal,
|
||||
"url": url,
|
||||
"engine": "skyvern-v2",
|
||||
"navigation_goal": goal,
|
||||
"data_extraction_goal": extraction_goal or goal,
|
||||
}
|
||||
if extraction_schema:
|
||||
payload["data_extraction_schema"] = extraction_schema
|
||||
payload["extracted_information_schema"] = extraction_schema
|
||||
if credential_id:
|
||||
payload["credential_id"] = credential_id
|
||||
if totp_identifier:
|
||||
@@ -82,10 +83,8 @@ async def execute_browser_scrape(job: dict, send_text, **_kwargs) -> dict:
|
||||
target_room = job["targetRoom"]
|
||||
config = job.get("config", {})
|
||||
url = config.get("url", "")
|
||||
extraction_goal = config.get("extractionGoal", "")
|
||||
goal = config.get("goal", config.get("query", f"Scrape content from {url}"))
|
||||
if extraction_goal:
|
||||
goal += f"\n\nExtract the following: {extraction_goal}"
|
||||
extraction_goal = config.get("extractionGoal", "") or goal
|
||||
extraction_schema = config.get("extractionSchema")
|
||||
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(
|
||||
url=url,
|
||||
goal=goal,
|
||||
extraction_goal=extraction_goal,
|
||||
extraction_schema=extraction_schema,
|
||||
credential_id=credential_id,
|
||||
totp_identifier=totp_identifier,
|
||||
|
||||
Reference in New Issue
Block a user