mirror of
https://github.com/open-webui/open-webui.git
synced 2026-01-02 06:35:20 +00:00
fix: retry Brave Search on HTTP 429 rate limit with 1s delay (#20255)
* Update brave.py * Update brave.py
This commit is contained in:
parent
95ce70c4fd
commit
464846d4a3
1 changed files with 9 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import time
|
||||
from typing import Optional
|
||||
|
||||
import requests
|
||||
|
|
@ -25,6 +26,14 @@ def search_brave(
|
|||
params = {"q": query, "count": count}
|
||||
|
||||
response = requests.get(url, headers=headers, params=params)
|
||||
|
||||
# Handle 429 rate limiting - Brave free tier allows 1 request/second
|
||||
# If rate limited, wait 1 second and retry once before failing
|
||||
if response.status_code == 429:
|
||||
log.info("Brave Search API rate limited (429), retrying after 1 second...")
|
||||
time.sleep(1)
|
||||
response = requests.get(url, headers=headers, params=params)
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
json_response = response.json()
|
||||
|
|
|
|||
Loading…
Reference in a new issue