INNER CODE UNIT · Python
do_action
eidolon-ai/eidolon · browser-service/eidolon_browser_service/main.py:63
async def do_action(
context_id: str, page_id: str, action: str, request: PlaywrightActionRequest
) -> PlaywrightActionResponse:
context = await browser_service.get_or_create_context(context_id)
page = context.get_page(page_id)
if not hasattr(page.page, action):
raise HTTPException(status_code=404, detail="action not found")
method = getattr(page.page, action)
if not callable(method):
raise HTTPException(status_code=404, detail="action is not callable")
try:
maybe_awaitable = method(*request.args, **request.kwargs)
result = (
await maybe_awaitable
if inspect.isawaitable(maybe_awaitable)
else maybe_awaitable
)
try: