mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
fix search_engine_serper arbitrary types error
This commit is contained in:
parent
38015322b6
commit
269750e616
3 changed files with 6 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ class SerpAPIWrapper(BaseModel):
|
|||
|
||||
search_engine: Any = None #: :meta private:
|
||||
params: dict = Field(
|
||||
default={
|
||||
default_factory=lambda: {
|
||||
"engine": "google",
|
||||
"google_domain": "google.com",
|
||||
"gl": "us",
|
||||
|
|
|
|||
|
|
@ -9,14 +9,16 @@ import json
|
|||
from typing import Any, Dict, Optional, Tuple
|
||||
|
||||
import aiohttp
|
||||
from pydantic import BaseModel, Field, field_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from metagpt.config import CONFIG
|
||||
|
||||
|
||||
class SerperWrapper(BaseModel):
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
search_engine: Any = None #: :meta private:
|
||||
payload: dict = Field(default={"page": 1, "num": 10})
|
||||
payload: dict = Field(default_factory=lambda: {"page": 1, "num": 10})
|
||||
serper_api_key: Optional[str] = Field(default=None, validate_default=True)
|
||||
aiosession: Optional[aiohttp.ClientSession] = None
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ async def test_search_engine(search_engine_type, run_func: Callable, max_results
|
|||
assert isinstance(rsp, str)
|
||||
else:
|
||||
assert isinstance(rsp, list)
|
||||
assert len(rsp) == max_results
|
||||
assert len(rsp) <= max_results
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue