mirror of
https://github.com/open-webui/open-webui.git
synced 2026-09-14 23:22:44 +00:00
fix: robustly detect HTTP proxy for DuckDuckGo search across ddgs versions
The previous proxy detection only read lowercase https_proxy/http_proxy env vars and passed them to DDGS(proxy=...). This broke silently when the ddgs package was updated (open-webui:main image repulled): newer versions use a different internal httpx client configuration that requires uppercase env vars (HTTPS_PROXY/HTTP_PROXY) to reliably pick up proxy settings. Changes: - Read proxy from all four env var variants (https_proxy, HTTPS_PROXY, http_proxy, HTTP_PROXY) with lowercase taking priority. - Use os.environ.setdefault() to ensure uppercase HTTPS_PROXY/HTTP_PROXY are set before DDGS is instantiated, so httpx picks up the proxy automatically regardless of which ddgs version is installed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4b610a3e1c
commit
cfca838549
1 changed files with 12 additions and 1 deletions
|
|
@ -26,7 +26,18 @@ def search_duckduckgo(
|
|||
Returns:
|
||||
list[SearchResult]: A list of search results
|
||||
"""
|
||||
proxy = os.environ.get("https_proxy") or os.environ.get("http_proxy")
|
||||
proxy = (
|
||||
os.environ.get("https_proxy")
|
||||
or os.environ.get("HTTPS_PROXY")
|
||||
or os.environ.get("http_proxy")
|
||||
or os.environ.get("HTTP_PROXY")
|
||||
)
|
||||
# httpx (used internally by ddgs) reliably reads uppercase env vars;
|
||||
# ensure they are set so the proxy is picked up regardless of ddgs version
|
||||
if proxy:
|
||||
os.environ.setdefault("HTTPS_PROXY", proxy)
|
||||
os.environ.setdefault("HTTP_PROXY", proxy)
|
||||
|
||||
# Use the DDGS context manager to create a DDGS object
|
||||
search_results = []
|
||||
with DDGS(proxy=proxy) as ddgs:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue