Skip to content

Commit 2d3fb2d

Browse files
committed
change to httpx
1 parent f958e54 commit 2d3fb2d

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ dependencies = [
2525
"playwright>=1.40.0",
2626
"pydantic>=2.0.0",
2727
"jsonschema>=4.0.0",
28-
"requests>=2.31.0", # For server-side API calls
29-
"aiohttp>=3.9.0", # For async API calls
28+
"requests>=2.31.0", # For server-side API calls (sync)
29+
"httpx>=0.25.0", # For async API calls
3030
"playwright-stealth>=1.0.6", # Bot evasion and stealth mode
3131
"markdownify>=0.11.6", # Enhanced HTML to Markdown conversion
3232
]

sentience/snapshot.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -467,18 +467,17 @@ async def _snapshot_via_api_async(
467467
}
468468

469469
try:
470-
# Lazy import aiohttp - only needed for async API calls
471-
import aiohttp
470+
# Lazy import httpx - only needed for async API calls
471+
import httpx
472472

473-
async with aiohttp.ClientSession() as session:
474-
async with session.post(
473+
async with httpx.AsyncClient(timeout=30.0) as client:
474+
response = await client.post(
475475
f"{browser.api_url}/v1/snapshot",
476-
data=payload_json,
476+
content=payload_json,
477477
headers=headers,
478-
timeout=aiohttp.ClientTimeout(total=30),
479-
) as response:
480-
response.raise_for_status()
481-
api_result = await response.json()
478+
)
479+
response.raise_for_status()
480+
api_result = response.json()
482481

483482
# Merge API result with local data
484483
snapshot_data = {
@@ -509,9 +508,9 @@ async def _snapshot_via_api_async(
509508

510509
return Snapshot(**snapshot_data)
511510
except ImportError:
512-
# Fallback to requests if aiohttp not available (shouldn't happen in async context)
511+
# Fallback to requests if httpx not available (shouldn't happen in async context)
513512
raise RuntimeError(
514-
"aiohttp is required for async API calls. Install it with: pip install aiohttp"
513+
"httpx is required for async API calls. Install it with: pip install httpx"
515514
)
516515
except Exception as e:
517516
raise RuntimeError(f"API request failed: {e}")

0 commit comments

Comments
 (0)