mirror of
https://github.com/open-webui/open-webui.git
synced 2025-12-12 04:15:25 +00:00
enh/fix: google pse referer header
This commit is contained in:
parent
03f207b803
commit
a4fd26b478
2 changed files with 6 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ def search_google_pse(
|
|||
query: str,
|
||||
count: int,
|
||||
filter_list: Optional[list[str]] = None,
|
||||
referer: Optional[str] = None,
|
||||
) -> list[SearchResult]:
|
||||
"""Search using Google's Programmable Search Engine API and return the results as a list of SearchResult objects.
|
||||
Handles pagination for counts greater than 10.
|
||||
|
|
@ -30,7 +31,11 @@ def search_google_pse(
|
|||
list[SearchResult]: A list of SearchResult objects.
|
||||
"""
|
||||
url = "https://www.googleapis.com/customsearch/v1"
|
||||
|
||||
headers = {"Content-Type": "application/json"}
|
||||
if referer:
|
||||
headers["Referer"] = referer
|
||||
|
||||
all_results = []
|
||||
start_index = 1 # Google PSE start parameter is 1-based
|
||||
|
||||
|
|
|
|||
|
|
@ -1875,6 +1875,7 @@ def search_web(request: Request, engine: str, query: str) -> list[SearchResult]:
|
|||
query,
|
||||
request.app.state.config.WEB_SEARCH_RESULT_COUNT,
|
||||
request.app.state.config.WEB_SEARCH_DOMAIN_FILTER_LIST,
|
||||
referer=request.app.state.config.WEBUI_URL,
|
||||
)
|
||||
else:
|
||||
raise Exception(
|
||||
|
|
|
|||
Loading…
Reference in a new issue