mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-08 15:05:17 +02:00
Merge branch 'feature-search-config' into mgx_ops
This commit is contained in:
commit
15892b56dd
2 changed files with 5 additions and 3 deletions
|
|
@ -7,7 +7,7 @@
|
|||
"""
|
||||
from typing import Callable, Optional
|
||||
|
||||
from pydantic import Field
|
||||
from pydantic import ConfigDict, Field
|
||||
|
||||
from metagpt.tools import SearchEngineType
|
||||
from metagpt.utils.yaml_model import YamlModel
|
||||
|
|
@ -16,10 +16,11 @@ from metagpt.utils.yaml_model import YamlModel
|
|||
class SearchConfig(YamlModel):
|
||||
"""Config for Search"""
|
||||
|
||||
model_config = ConfigDict(extra="allow")
|
||||
|
||||
api_type: SearchEngineType = SearchEngineType.DUCK_DUCK_GO
|
||||
api_key: str = ""
|
||||
cse_id: str = "" # for google
|
||||
discovery_service_url: str = "" # for google
|
||||
search_func: Optional[Callable] = None
|
||||
params: dict = Field(
|
||||
default_factory=lambda: {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ class SerperWrapper(BaseModel):
|
|||
"To use serper search engine, make sure you provide the `api_key` when constructing an object. You can obtain "
|
||||
"an API key from https://serper.dev/."
|
||||
)
|
||||
|
||||
return values
|
||||
|
||||
async def run(self, query: str, max_results: int = 8, as_string: bool = True, **kwargs: Any) -> str:
|
||||
|
|
@ -56,7 +57,7 @@ class SerperWrapper(BaseModel):
|
|||
response.raise_for_status()
|
||||
res = await response.json()
|
||||
else:
|
||||
async with self.aiosession.get.post(self.url, data=payloads, headers=headers, proxy=self.proxy) as response:
|
||||
async with self.aiosession.post(self.url, data=payloads, headers=headers, proxy=self.proxy) as response:
|
||||
response.raise_for_status()
|
||||
res = await response.json()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue