mirror of
https://github.com/open-webui/open-webui.git
synced 2026-06-14 03:30:25 +00:00
Update Kagi API endpoint and request method (#25015)
Co-authored-by: russelg <russelg@users.noreply.github.com>
This commit is contained in:
@@ -17,21 +17,20 @@ def search_kagi(api_key: str, query: str, count: int, filter_list: Optional[list
|
|||||||
query (str): The query to search for
|
query (str): The query to search for
|
||||||
count (int): The number of results to return
|
count (int): The number of results to return
|
||||||
"""
|
"""
|
||||||
url = 'https://kagi.com/api/v0/search'
|
url = 'https://kagi.com/api/v1/search'
|
||||||
headers = {
|
headers = {
|
||||||
'Authorization': f'Bot {api_key}',
|
'Authorization': f'Bearer {api_key}',
|
||||||
}
|
}
|
||||||
params = {'q': query, 'limit': count}
|
params = {'query': query, 'limit': count}
|
||||||
|
|
||||||
response = requests.get(url, headers=headers, params=params)
|
response = requests.post(url, headers=headers, json=params)
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
json_response = response.json()
|
json_response = response.json()
|
||||||
search_results = json_response.get('data', [])
|
search_results = json_response.get('data', {}).get('search', [])
|
||||||
|
|
||||||
results = [
|
results = [
|
||||||
SearchResult(link=result['url'], title=result['title'], snippet=result.get('snippet'))
|
SearchResult(link=result['url'], title=result['title'], snippet=result.get('snippet'))
|
||||||
for result in search_results
|
for result in search_results
|
||||||
if result['t'] == 0
|
|
||||||
]
|
]
|
||||||
|
|
||||||
print(results)
|
print(results)
|
||||||
|
|||||||
Reference in New Issue
Block a user