feat: add websearch endpoint to RAG API

fix: google PSE endpoint uses GET

fix: google PSE returns link, not url

fix: serper wrong field
This commit is contained in:
Jun Siang Cheah
2024-05-06 17:09:04 +08:00
parent 501ff7a98b
commit 99e4edd364
4 changed files with 76 additions and 38 deletions
+4 -2
View File
@@ -30,14 +30,16 @@ def search_google_pse(
"num": 5,
}
response = requests.request("POST", url, headers=headers, params=params)
response = requests.request("GET", url, headers=headers, params=params)
response.raise_for_status()
json_response = response.json()
results = json_response.get("items", [])
return [
SearchResult(
link=result["url"], title=result.get("title"), snippet=result.get("snippet")
link=result["link"],
title=result.get("title"),
snippet=result.get("snippet"),
)
for result in results
]