diff --git a/cron/browser_executor.py b/cron/browser_executor.py index 6106667..e00d597 100644 --- a/cron/browser_executor.py +++ b/cron/browser_executor.py @@ -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, diff --git a/pipelines/steps/skyvern.py b/pipelines/steps/skyvern.py index 0cd3c24..f7f76f4 100644 --- a/pipelines/steps/skyvern.py +++ b/pipelines/steps/skyvern.py @@ -42,20 +42,15 @@ async def execute_skyvern(config: dict, send_text=None, target_room: str = "", * if not url or not goal: 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 = { - "prompt": prompt, "url": url, - "engine": "skyvern-v2", + "navigation_goal": goal, + "data_extraction_goal": data_extraction_goal or goal, } if extraction_schema: if isinstance(extraction_schema, str): extraction_schema = json.loads(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: