mirror of
https://github.com/open-webui/open-webui.git
synced 2026-01-03 23:25:21 +00:00
fix: bocha filter list
Co-Authored-By: zengxy <11961641+zengxy@users.noreply.github.com>
This commit is contained in:
parent
823b9a6dd9
commit
b5bd8704fe
1 changed files with 5 additions and 5 deletions
|
|
@ -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]
|
||||
]
|
||||
|
|
|
|||
Loading…
Reference in a new issue