fix tests/metagpt/learn/test_google_search.py error

This commit is contained in:
shenchucheng 2024-01-31 15:58:26 +08:00
parent 16f54abb3d
commit fc412e55a3
6 changed files with 135 additions and 17 deletions

View file

@ -61,9 +61,11 @@ class SerpAPIWrapper(BaseModel):
if not self.aiosession:
async with aiohttp.ClientSession() as session:
async with session.get(url, params=params) as response:
response.raise_for_status()
res = await response.json()
else:
async with self.aiosession.get(url, params=params) as response:
response.raise_for_status()
res = await response.json()
return res

View file

@ -55,9 +55,11 @@ class SerperWrapper(BaseModel):
if not self.aiosession:
async with aiohttp.ClientSession() as session:
async with session.post(url, data=payloads, headers=headers) as response:
response.raise_for_status()
res = await response.json()
else:
async with self.aiosession.get.post(url, data=payloads, headers=headers) as response:
response.raise_for_status()
res = await response.json()
return res