mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-05 18:38:17 -05:00
fix: bocha filter list
Co-Authored-By: zengxy <11961641+zengxy@users.noreply.github.com>
This commit is contained in:
@@ -9,13 +9,13 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _parse_response(response):
|
||||
result = {}
|
||||
results = []
|
||||
if "data" in response:
|
||||
data = response["data"]
|
||||
if "webPages" in data:
|
||||
webPages = data["webPages"]
|
||||
if "value" in webPages:
|
||||
result["webpage"] = [
|
||||
results = [
|
||||
{
|
||||
"id": item.get("id", ""),
|
||||
"name": item.get("name", ""),
|
||||
@@ -29,7 +29,7 @@ def _parse_response(response):
|
||||
}
|
||||
for item in webPages["value"]
|
||||
]
|
||||
return result
|
||||
return results
|
||||
|
||||
|
||||
def search_bocha(
|
||||
@@ -51,7 +51,7 @@ def search_bocha(
|
||||
response = requests.post(url, headers=headers, data=payload, timeout=5)
|
||||
response.raise_for_status()
|
||||
results = _parse_response(response.json())
|
||||
print(results)
|
||||
|
||||
if filter_list:
|
||||
results = get_filtered_results(results, filter_list)
|
||||
|
||||
@@ -59,5 +59,5 @@ def search_bocha(
|
||||
SearchResult(
|
||||
link=result["url"], title=result.get("name"), snippet=result.get("summary")
|
||||
)
|
||||
for result in results.get("webpage", [])[:count]
|
||||
for result in results[:count]
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user