diff --git a/npiai/core/__test__/captcha_detection.py b/npiai/core/__test__/captcha_detection.py index 4f4e60c..4457b97 100644 --- a/npiai/core/__test__/captcha_detection.py +++ b/npiai/core/__test__/captcha_detection.py @@ -2,6 +2,7 @@ from typing import Literal from npiai import BrowserTool, HITL +from npiai.core import PlaywrightContext from npiai.utils.test_utils import DebugContext @@ -40,6 +41,7 @@ async def web_interaction( message: str, url: str, action: Literal["captcha", "login"], + playwright: PlaywrightContext, ) -> str: print(f"[HITL] web_interaction: {message=}, {url=}, {action=}") return "web_interaction" diff --git a/npiai/core/hitl.py b/npiai/core/hitl.py index add4e23..1a2d932 100644 --- a/npiai/core/hitl.py +++ b/npiai/core/hitl.py @@ -2,6 +2,7 @@ from typing import List, Literal from npiai.context import Context +from npiai.core import PlaywrightContext class HITL(ABC): @@ -42,4 +43,5 @@ async def web_interaction( message: str, url: str, action: Literal["captcha", "login"], + playwright: PlaywrightContext, ) -> str: ... diff --git a/npiai/core/tool/_browser.py b/npiai/core/tool/_browser.py index 9433c45..1814013 100644 --- a/npiai/core/tool/_browser.py +++ b/npiai/core/tool/_browser.py @@ -306,6 +306,7 @@ async def handle_captcha(captcha_type: Literal["none", "captcha", "login"]): message="Would you please help me solve the captcha?", url=url, action="captcha", + playwright=self.playwright, ) case "login": await ctx.hitl.web_interaction( @@ -313,6 +314,7 @@ async def handle_captcha(captcha_type: Literal["none", "captcha", "login"]): message="Would you please help me login to the website?", url=url, action="login", + playwright=self.playwright, ) return captcha_type diff --git a/npiai/tools/scrapers/web/__test__/interactive.py b/npiai/tools/scrapers/web/__test__/interactive.py index 17be77f..c69386a 100644 --- a/npiai/tools/scrapers/web/__test__/interactive.py +++ b/npiai/tools/scrapers/web/__test__/interactive.py @@ -1,6 +1,7 @@ import asyncio from typing import Literal +from npiai.core import PlaywrightContext from npiai.utils.test_utils import DebugContext # from npiai import Context @@ -44,6 +45,7 @@ async def web_interaction( message: str, url: str, action: Literal["captcha", "login"], + playwright: PlaywrightContext, ) -> str: print(f"[HITL] web_interaction: {message=}, {url=}, {action=}") return "web_interaction"