mirror of
https://github.com/hwchase17/langchain
synced 2024-11-02 09:40:22 +00:00
Introduce search_kwargs for Custom Parameters in BingSearchAPIWrapper (#13525)
Added a `search_kwargs` field to BingSearchAPIWrapper in `bing_search.py,` enabling users to include extra keyword arguments in Bing search queries. This update, like specifying language preferences, adds more customization to searches. The `search_kwargs` seamlessly merge with standard parameters in `_bing_search_results` method. --------- Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
parent
ad0c3b9479
commit
7100d586ef
@ -7,7 +7,7 @@ from typing import Dict, List
|
||||
|
||||
import requests
|
||||
|
||||
from langchain.pydantic_v1 import BaseModel, Extra, root_validator
|
||||
from langchain.pydantic_v1 import BaseModel, Extra, Field, root_validator
|
||||
from langchain.utils import get_from_dict_or_env
|
||||
|
||||
|
||||
@ -21,6 +21,8 @@ class BingSearchAPIWrapper(BaseModel):
|
||||
bing_subscription_key: str
|
||||
bing_search_url: str
|
||||
k: int = 10
|
||||
search_kwargs: dict = Field(default_factory=dict)
|
||||
"""Additional keyword arguments to pass to the search request."""
|
||||
|
||||
class Config:
|
||||
"""Configuration for this pydantic object."""
|
||||
@ -34,6 +36,7 @@ class BingSearchAPIWrapper(BaseModel):
|
||||
"count": count,
|
||||
"textDecorations": True,
|
||||
"textFormat": "HTML",
|
||||
**self.search_kwargs,
|
||||
}
|
||||
response = requests.get(
|
||||
self.bing_search_url,
|
||||
|
Loading…
Reference in New Issue
Block a user